Skip to content

Commit

Permalink
Reviewed PR #37
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasgranderubio committed Sep 27, 2018
1 parent ea78171 commit f9e45db
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dagda/analysis/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def evaluate_image(self, image_name, container_id):
DagdaLogger.get_logger().debug('Dependencies from the docker image retrieved')

except Exception as ex:
message = "Unexpected exception of type {0} occured: {1!r}"\
message = "Unexpected exception of type {0} occurred: {1!r}"\
.format(type(ex).__name__, ex.get_message() if type(ex).__name__ == 'DagdaError' else ex.args)
DagdaLogger.get_logger().error(message)
if InternalServer.is_debug_logging_enabled():
Expand Down
2 changes: 1 addition & 1 deletion dagda/analysis/runtime/docker_events_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run(self):
# Nothing to do
pass
except bson.errors.InvalidDocument as ex:
message = "Unexpected exception of type {0} occured: {1!r}" \
message = "Unexpected exception of type {0} occurred: {1!r}" \
.format(type(ex).__name__, ex.get_message() if type(ex).__name__ == 'DagdaError' else ex.args)
DagdaLogger.get_logger().error(message)
if InternalServer.is_debug_logging_enabled():
Expand Down
4 changes: 2 additions & 2 deletions dagda/analysis/static/util/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ def _untar_layers(dir, layers):
tarfile.extract(output[member_name], path=dir, set_attrs=False)
except (ValueError, ReadError) as ex:
if InternalServer.is_debug_logging_enabled():
message = "Unexpected exception of type {0} occured while untaring the docker image: {1!r}" \
message = "Unexpected exception of type {0} occurred while untaring the docker image: {1!r}" \
.format(type(ex).__name__, ex.get_message() if type(ex).__name__ == 'DagdaError' else ex.args)
DagdaLogger.get_logger().debug(message)
except PermissionError as ex:
message = "Unexpected error occured while untaring the docker image: " + \
message = "Unexpected error occurred while untaring the docker image: " + \
"Operation not permitted on {0!r}".format(member_name)
DagdaLogger.get_logger().warn(message)

Expand Down
2 changes: 1 addition & 1 deletion dagda/api/dagda_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _init_or_update_db():
InternalServer.get_mongodb_driver().insert_init_db_process_status(
{'status': 'Updated', 'timestamp': datetime.datetime.now().timestamp()})
except Exception as ex:
message = "Unexpected exception of type {0} occured: {1!r}".format(type(ex).__name__, ex.args)
message = "Unexpected exception of type {0} occurred: {1!r}".format(type(ex).__name__, ex.args)
DagdaLogger.get_logger().error(message)
if InternalServer.is_debug_logging_enabled():
traceback.print_exc()
Expand Down
12 changes: 7 additions & 5 deletions dagda/api/service/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ def check_docker_by_image_name(image_name):
raise DagdaError(msg)
pulled = True
except Exception as ex:
if InternalServer.is_debug_logging_enabled():
message = "Unexpected exception of type {0} occured while pulling the docker image: {1!r}" \
.format(type(ex).__name__, ex.get_message() if type(ex).__name__ == 'DagdaError' else ex.args)
DagdaLogger.get_logger().debug(message)
message = "Unexpected exception of type {0} occurred while pulling the docker image: {1!r}" \
.format(type(ex).__name__, ex.get_message() if type(ex).__name__ == 'DagdaError' else ex.args)
DagdaLogger.get_logger().error(message)
return json.dumps({'err': 404, 'msg': 'Image name not found'}, sort_keys=True), 404

# -- Process request
Expand Down Expand Up @@ -85,7 +84,10 @@ def check_docker_by_container_id(container_id):
# -- Retrieves docker image name
try:
image_name = InternalServer.get_docker_driver().get_docker_image_name_by_container_id(container_id)
except:
except Exception as ex:
message = "Unexpected exception of type {0} occurred while getting the docker image name: {1!r}" \
.format(type(ex).__name__, ex.get_message() if type(ex).__name__ == 'DagdaError' else ex.args)
DagdaLogger.get_logger().error(message)
return json.dumps({'err': 404, 'msg': 'Container Id not found'}, sort_keys=True), 404

# -- Process request
Expand Down
4 changes: 2 additions & 2 deletions dagda/driver/docker_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self):
# those used by the Docker command-line client.
self.cli = docker.from_env(version="auto", timeout=3600).api
except DockerException:
DagdaLogger.get_logger().error('Error while fetching Docker server API version: Assumming Travis CI tests.')
DagdaLogger.get_logger().error('Error while fetching Docker server API version: Assuming Travis CI tests.')
self.cli = None

# Gets the docker image name from a running container
Expand Down Expand Up @@ -78,7 +78,7 @@ def docker_logs(self, container_id, show_stdout, show_stderr, follow):
DagdaLogger.get_logger().error(message)
raise DagdaError(message)
else:
message = "Unexpected exception of type {0} occured: {1!r}" \
message = "Unexpected exception of type {0} occurred: {1!r}" \
.format(type(ex).__name__, str(ex))
DagdaLogger.get_logger().error(message)
raise ex
Expand Down

0 comments on commit f9e45db

Please sign in to comment.