Skip to content

Commit

Permalink
Merge pull request #664 from ScilifelabDataCentre/dev
Browse files Browse the repository at this point in the history
Minor fix prior to release in order to get debugging info
  • Loading branch information
i-oden authored Oct 24, 2023
2 parents 1436744 + 1e1cf80 commit b2e873e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
5 changes: 3 additions & 2 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ _Nothing merged in CLI during this sprint_

# 2023-10-16 - 2023-10-27

- Change "Checksum verification successful. File integrity verified." logging level from INFO to DEBUG in order to not print for all files ([#662](https://github.com/ScilifelabDataCentre/dds_cli/pull/662)
- New command `dds project status extend` to allow extension of project deadline ([#661](https://github.com/ScilifelabDataCentre/dds_cli/pull/661)
- Change "Checksum verification successful. File integrity verified." logging level from INFO to DEBUG in order to not print for all files ([#662](https://github.com/ScilifelabDataCentre/dds_cli/pull/662))
- New command `dds project status extend` to allow extension of project deadline ([#661](https://github.com/ScilifelabDataCentre/dds_cli/pull/661))
- New version: 2.5.2 ([#660](https://github.com/ScilifelabDataCentre/dds_cli/pull/660))
- Catch `ApiRequestError` in `update_db` in order to get more error information ([#663](https://github.com/ScilifelabDataCentre/dds_cli/pull/663))
25 changes: 15 additions & 10 deletions dds_cli/data_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,20 @@ def update_db(self, file):
params = {"project": self.project}

# Send file info to API
response_json, _ = dds_cli.utils.perform_request(
DDSEndpoint.FILE_UPDATE,
method="put",
params=params,
json=filename,
headers=self.token,
error_message="Failed to update file information",
)

updated_in_db, message = (True, response_json["message"])
try:
response_json, _ = dds_cli.utils.perform_request(
DDSEndpoint.FILE_UPDATE,
method="put",
params=params,
json=filename,
headers=self.token,
error_message="Failed to update file information",
)
except dds_cli.exceptions.ApiRequestError as err:
updated_in_db = False
message = str(err)
else:
updated_in_db = True
message = response_json["message"]

return updated_in_db, message
4 changes: 2 additions & 2 deletions dds_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ def transform_paths(json_input):
)
except requests.exceptions.RequestException as err:
if isinstance(err, requests.exceptions.ConnectionError):
error_message += ": The database seems to be down."
error_message += f": The database seems to be down -- \n{err}"
elif isinstance(err, requests.exceptions.Timeout):
error_message += ": The request timed out."
else:
error_message += f": Unknown request error -- \n {err}"
error_message += f": Unknown request error -- \n{err}"
raise dds_cli.exceptions.ApiRequestError(message=error_message)

# Get and parse project specific errors
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_perform_request_request_exception() -> None:
)

assert len(exc_info.value.args) == 1
assert exc_info.value.args[0] == "API Request failed.: The database seems to be down."
assert "API Request failed.: The database seems to be down" in exc_info.value.args[0]


def test_perform_request_api_response_error_internal_server_error() -> None:
Expand Down

0 comments on commit b2e873e

Please sign in to comment.