From 54940dfebd84a2c05acc65c9a592de4ff998df2a Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 14 Sep 2024 08:43:21 -0500 Subject: [PATCH] Catch and log archive.org key errors --- netkan/netkan/download_counter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netkan/netkan/download_counter.py b/netkan/netkan/download_counter.py index 6fa7098..a2dba32 100644 --- a/netkan/netkan/download_counter.py +++ b/netkan/netkan/download_counter.py @@ -202,7 +202,11 @@ def get_result(self, counts: Optional[Dict[str, int]] = None) -> Dict[str, int]: result = requests.get(self.IARCHIVE_API + ','.join(self.ids.values()), timeout=60).json() for ckan_ident, ia_ident in self.ids.items(): - counts[ckan_ident] = counts.get(ckan_ident, 0) + result[ia_ident]['all_time'] + try: + counts[ckan_ident] = counts.get(ckan_ident, 0) + result[ia_ident]['all_time'] + except KeyError as exc: + logging.error('InternetArchive id not found in downloads result: %s', + ia_ident, exc_info=exc) return counts