From 2ad527f4b35f3ab3c8b752194cb928741b0186c4 Mon Sep 17 00:00:00 2001 From: keegansmith21 Date: Mon, 13 Nov 2023 12:13:47 +0800 Subject: [PATCH] Added more logs --- .gitignore | 3 ++- main.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 7fa071a..8967893 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea .vscode -*.zip \ No newline at end of file +*.zip +*.pyc diff --git a/main.py b/main.py index c873d46..57bc4a4 100644 --- a/main.py +++ b/main.py @@ -62,13 +62,12 @@ def download(request): # download oapen access stats and replace ip addresses file_path = "/tmp/oapen_access_stats.jsonl.gz" - print( - f"Downloading oapen access stats for month: {release_date}" - ) + print(f"Downloading oapen access stats for month: {release_date}") if datetime.strptime(release_date, "%Y-%m") >= datetime(2020, 4, 1): print(f"publisher UUID(s): {publisher_uuid_v5}") - entries = download_access_stats_new(file_path, release_date, username, password, publisher_uuid_v5, - geoip_client) + entries = download_access_stats_new( + file_path, release_date, username, password, publisher_uuid_v5, geoip_client + ) else: print(f"Publisher name(s): {publisher_name_v4}") entries, unprocessed_publishers = download_access_stats_old( @@ -85,10 +84,13 @@ def download(request): # upload oapen access stats to bucket success = upload_file_to_storage_bucket(file_path, bucket_name, blob_name) - if not success: + if success: + print(f"Uploaded blob: {blob_name}") + else: raise RuntimeError("Uploading file to storage bucket unsuccessful") data = {"entries": entries, "unprocessed_publishers": unprocessed_publishers} + print(f"Returning data: {data}") return json.dumps(data), 200, {"Content-Type": "application/json"}