Skip to content

Commit

Permalink
Merge pull request #9 from okfn/improve_logs
Browse files Browse the repository at this point in the history
Improve logs
  • Loading branch information
avdata99 authored Oct 9, 2024
2 parents 56f8de2 + 9757e5b commit ded7403
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions clamav_service/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def scan_resource(logger, ckan_url, api_key, resource_id):
@job.asynchronous
def scan(task_id, payload):
logger = init_logger(task_id, payload)
logger.info(f"Starting job {task_id}")
logger.info(f"Starting ClamAV job {task_id}")

validate_payload(payload)

Expand All @@ -172,9 +172,21 @@ def scan(task_id, payload):
"description": scan_result.stdout.decode("utf-8"),
}
if scan_result.returncode not in STATUSES:
logger.error(
f"Unknown return code {scan_result.returncode} (not in statuses) "
f"scanning resource {resource_id}"
)
raise util.JobError(json.dumps(response))

response["status_text"] = STATUSES[scan_result.returncode]
if scan_result.returncode == 2:
logger.error(
f"Scan failed for resource {resource_id}: {response['description']}"
)
raise util.JobError(json.dumps(response))
logger.info(f"Completed scanning resource {resource_id}. Submitting result")

final_status_text = response["status_text"]
logger.info(
f"Completed scanning {final_status_text}. Resource {resource_id}. Submitting result"
)
return response
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _get_description():

setup(
name="ckan-clamav-service",
version="0.6.0",
version="0.6.1",
author="OKFN",
license="AGPL-3.0",
url="https://github.com/okfn/ckan-clamav-service",
Expand Down

0 comments on commit ded7403

Please sign in to comment.