Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logs #9

Merged
merged 2 commits into from
Oct 9, 2024
Merged
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
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
Loading