Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ jobs:
- name: Test with pytest
run: |
pytest
- name: Run test
run: |
python -m pip install .
fedcloud --version
6 changes: 6 additions & 0 deletions fedcloudclient/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ def init_logger():
def log_and_raise(error_msg: str, exception):
"""
Log error and raise exception

:param error_msg: error message to log (and to use as exception message)
:param exception: either an exception class, which is instantiated with
error_msg, or an exception instance, which is raised as is
"""
LOG.error(error_msg)
if isinstance(exception, BaseException):
raise exception
raise exception(error_msg)


Expand Down
2 changes: 1 addition & 1 deletion fedcloudclient/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def fedcloud_openstack_full(
(__OPENSTACK_CLIENT,) + openstack_command + options,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=my_env, check=True
env=my_env
)

error_code = completed.returncode
Expand Down
7 changes: 4 additions & 3 deletions fedcloudclient/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from urllib.request import Request, urlopen

import click
import pkg_resources
from importlib.resources import files
import yaml
from jsonschema import validate

Expand Down Expand Up @@ -54,8 +54,9 @@ def read_site_schema():

:return: JSON object from schema.json
"""
file = pkg_resources.resource_stream("fedcloudclient", "schema.json")
schema = json.load(file)
# Open the bundled file inside the fedcloudclient package as a binary stream
with files("fedcloudclient").joinpath("schema.json").open("rb") as file:
schema = json.load(file)
return schema


Expand Down
Loading