]> git.ipfire.org Git - thirdparty/linux-firmware.git/commitdiff
trivial: contrib: wrap the process in try/except to catch server issues
authorMario Limonciello <mario.limonciello@amd.com>
Thu, 23 Jan 2025 16:44:10 +0000 (10:44 -0600)
committerMario Limonciello <mario.limonciello@amd.com>
Thu, 23 Jan 2025 16:44:53 +0000 (10:44 -0600)
If lore has load problems, don't bail, just wrap them and try again
on the next cycle.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
contrib/process_linux_firmware.py

index 8c024016852b12cd765c6874bc3cec10fbf7daab..5bb1fd35dccc2d34aa32db481d479dc8d8970761 100755 (executable)
@@ -376,19 +376,23 @@ if __name__ == "__main__":
     logging.getLogger("").addHandler(console)
 
     while True:
-        conn = sqlite3.connect(args.database)
-        # update the database
-        update_database(conn, args.url)
-
         if args.dry:
             remote = ""
         else:
             remote = args.remote
 
-        # process the database
-        process_database(conn, remote)
+        try:
+            conn = sqlite3.connect(args.database)
+
+            # update the database
+            update_database(conn, args.url)
+            # process the database
+            process_database(conn, remote)
 
-        conn.close()
+        except urllib.error.HTTPError as e:
+            logging.error("Failed to fetch URL: {}".format(e))
+        finally:
+            conn.close()
 
         if args.refresh_cycle:
             logging.info("Sleeping for {} minutes".format(args.refresh_cycle))