Skip to content

Commit

Permalink
Fix/check url validity (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
margalva authored Sep 26, 2023
1 parent 36cdbe9 commit ee5c378
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ jobs:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
needs: [ style, test, docs-style ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Microsoft Teams Notification
uses: jdcargile/[email protected]
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ jobs:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: 'refs/heads/main'

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
needs: [ nightly_test, nightly_and_upload]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Microsoft Teams Notification
uses: jdcargile/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion codegen/pyadritem.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Item:
self.item_image = None
"""Image object (Image and PNG binary files)"""
self.item_scene = None
"""3D scene (AVZ, PLY, GBT, and STL files)"""
"""3D scene (AVZ, PLY, SCDOC, and STL files)"""
# Attributes for the table items
self.table_attr = table_attr
self.item_table = None
Expand Down
22 changes: 11 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requires = [

[project]
name = "ansys-dynamicreporting-core"
version = "0.5.dev0"
version = "0.6.0.dev0"
authors = [
{name = "ANSYS, Inc.", email = "[email protected]"},
]
Expand Down Expand Up @@ -65,33 +65,33 @@ tests = [
"pyansys-docker==5.0.4",
"numpy==1.25.1",
"psutil==5.9.5",
"pytest==7.4.0",
"pytest==7.4.2",
"pytest-cov==4.1.0",
]
doc = [
"ansys-sphinx-theme==0.10.0",
"ansys-sphinx-theme==0.11.2",
"numpydoc==1.5.0",
"pillow==10.0.0",
"pillow==10.0.1",
"pyansys-docker==5.0.4",
"Sphinx==7.1.1",
"Sphinx==7.2.6",
"sphinx-copybutton==0.5.2",
"sphinx-gallery==0.13.0",
"sphinx-gallery==0.14.0",
]
dev = [
"ipdb",
"ipython",
"whatsonpypi",
"ansys-sphinx-theme==0.10.0",
"ansys-sphinx-theme==0.11.2",
"numpy==1.25.1",
"numpydoc==1.5.0",
"pillow==10.0.0",
"pillow==10.0.1",
"psutil==5.9.5",
"pyansys-docker==5.0.4",
"pytest==7.4.0",
"pytest==7.4.2",
"pytest-cov==4.1.0",
"Sphinx==7.1.1",
"Sphinx==7.2.6",
"sphinx-copybutton==0.5.2",
"sphinx-gallery==0.13.0",
"sphinx-gallery==0.14.0",
]

[tool.pytest.ini_options]
Expand Down
13 changes: 11 additions & 2 deletions src/ansys/dynamicreporting/core/utils/report_remote_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def wrapper(*args, **kwargs):

def print_allowed():
# Note: calling print() from a pythonw interpreter (e.g. template_editor launched
# via the icon) an cause the interpreter to crash. We will allow print, but only
# via the icon) can cause the interpreter to crash. We will allow print, but only
# if this is not a pythonw instance.
return not sys.executable.lower().endswith("pythonw.exe")

Expand Down Expand Up @@ -104,6 +104,14 @@ class Server:
"""

def __init__(self, url=None, username=None, password=None):
# Check on the validity of url formatting
if url is not None:
o = urlparse(url)
is_valid = True if o.scheme and o.netloc else False
if is_valid is False:
if print_allowed():
print("Error: invalid URL. Setting it to None")
url = None
self.cur_url = url
self.cur_username = username
self.cur_password = password
Expand Down Expand Up @@ -935,7 +943,8 @@ def get_pptx_from_report(self, report_guid, directory_name=None, query=None):
continue
self._download_report(link, q_params["filename"], directory_name=directory_name)
except Exception as e:
print(f"Unable to get pptx from report '{report_guid}': {e}")
if print_allowed():
print(f"Unable to get pptx from report '{report_guid}': {e}")
else:
raise Exception(f"The server returned an error code {resp.status_code}")

Expand Down

0 comments on commit ee5c378

Please sign in to comment.