From a76558e6b82c766445bc48149ecdfef98bf45af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Velschow=20S=C3=B8gaard?= <46562365+seba7236@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:46:56 +0200 Subject: [PATCH 1/6] Update chrome.py Error handling --- lib/chrome.py | 56 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/chrome.py b/lib/chrome.py index 19005b4..58c7b3e 100644 --- a/lib/chrome.py +++ b/lib/chrome.py @@ -33,8 +33,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -78,8 +82,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -101,8 +109,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -119,8 +131,11 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) output = [] output.append(["term", "normalized_term"]) @@ -137,8 +152,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -155,8 +174,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -195,8 +218,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -275,6 +302,7 @@ class ClosedReason: chromeWriter.write_json("notifications", output) except Exception as e: print(e) + return 0 def parse_extensions(path): From 3b03ff84e5f7501fd416df79c7f81282a66fa8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Velschow=20S=C3=B8gaard?= <46562365+seba7236@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:47:36 +0200 Subject: [PATCH 2/6] Update edge.py Error handling --- lib/edge.py | 57 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/lib/edge.py b/lib/edge.py index 6449c79..eb24079 100644 --- a/lib/edge.py +++ b/lib/edge.py @@ -33,8 +33,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -78,8 +82,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -101,8 +109,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -119,8 +131,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -137,8 +153,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -155,8 +175,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -195,8 +219,13 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 + output = [] output.append( [ From 4299ae0a1b01320352b85f04e2c4a723dbc8d465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Velschow=20S=C3=B8gaard?= <46562365+seba7236@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:47:55 +0200 Subject: [PATCH 3/6] Update firefox.py Error handling --- lib/firefox.py | 80 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/lib/firefox.py b/lib/firefox.py index 8557db3..423e149 100644 --- a/lib/firefox.py +++ b/lib/firefox.py @@ -66,8 +66,12 @@ def parse_favicons(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_pages_w_icons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_pages_w_icons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["page_url"]) for entry in entries: @@ -110,8 +114,12 @@ def parse_cookies(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( ["name", "value", "host", "expiry", "lastAccessed", "creationTime"] @@ -139,8 +147,12 @@ def parse_formhistory(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_formhistory") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_formhistory") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( ["fieldname", "value", "timesUsed", "firstUsed", "lastUsed"] @@ -167,8 +179,12 @@ def parse_perms(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_perms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_perms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["origin", "type", "expireTime", "modificationTime"]) for entry in entries: @@ -192,8 +208,12 @@ def parse_bookmarks(database: str): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_bookmarks") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_bookmarks") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["title", "dateAdded", "lastModified"]) for entry in entries: @@ -215,8 +235,12 @@ def parse_inputhistory(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_inputhistory") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_inputhistory") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["places_id", "url", "input"]) for entry in entries: @@ -233,8 +257,12 @@ def parse_history(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_places") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_places") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -290,8 +318,12 @@ def enrich_history(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_historyvisits") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_historyvisits") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] # Defined in the source code # Link: https://searchfox.org/mozilla-central/source/toolkit/components/places/History.sys.mjs Line 762 @@ -322,8 +354,12 @@ def parse_history_metadata(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_places_metadata") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_places_metadata") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -397,8 +433,12 @@ def parse_downloads(database: str, places_dict: dict): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM moz_annos") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM moz_annos") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 entries.sort(key=itemgetter(1)) output = [] # Write names of fields From ca94628e0ad80acbf02b684f990782b8b9afbc99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Velschow=20S=C3=B8gaard?= <46562365+seba7236@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:48:11 +0200 Subject: [PATCH 4/6] Update opera.py Error handling --- lib/opera.py | 56 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/opera.py b/lib/opera.py index 661589e..df566d3 100644 --- a/lib/opera.py +++ b/lib/opera.py @@ -32,8 +32,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -77,8 +81,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -100,8 +108,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -118,8 +130,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -136,8 +152,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -154,8 +174,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -194,8 +218,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ From 954e1a9e8931409608aa95f549b37b95379cc63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Velschow=20S=C3=B8gaard?= <46562365+seba7236@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:48:31 +0200 Subject: [PATCH 5/6] Update yandex.py Error handling --- lib/yandex.py | 56 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/yandex.py b/lib/yandex.py index 1ca0e72..bbcffe0 100644 --- a/lib/yandex.py +++ b/lib/yandex.py @@ -32,8 +32,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -77,8 +81,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -100,8 +108,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -118,8 +130,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -136,8 +152,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -154,8 +174,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -194,8 +218,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ From 06bac80cd59961a65fcdf30d4c5a3a1dedc07ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Velschow=20S=C3=B8gaard?= <46562365+seba7236@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:49:25 +0200 Subject: [PATCH 6/6] Update brave.py Error handling --- lib/brave.py | 56 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/lib/brave.py b/lib/brave.py index b938e33..7b7f0e6 100644 --- a/lib/brave.py +++ b/lib/brave.py @@ -33,8 +33,12 @@ def parse_downloads(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM downloads") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM downloads") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -78,8 +82,12 @@ def parse_history(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM urls") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM urls") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url", "title", "visit_count", "last_visit_time"]) @@ -101,8 +109,12 @@ def parse_visited_links(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM visited_links") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM visited_links") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["top_level_url", "frame_url", "visit_count"]) @@ -119,8 +131,12 @@ def parse_searches(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM keyword_search_terms") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM keyword_search_terms") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["term", "normalized_term"]) @@ -137,8 +153,12 @@ def parse_favicons(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM favicons") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM favicons") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append(["url"]) for entry in entries: @@ -155,8 +175,12 @@ def parse_cookies(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM cookies") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM cookies") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [ @@ -195,8 +219,12 @@ def parse_shortcuts(database): connection = connect_database(database) if not connection: return None - cursor = connection.execute("SELECT * FROM omni_box_shortcuts") - entries = cursor.fetchall() + try: + cursor = connection.execute("SELECT * FROM omni_box_shortcuts") + entries = cursor.fetchall() + except Exception as e: + print(e) + return 0 output = [] output.append( [