Skip to content

Commit

Permalink
Merge pull request #1 from seba7236/seba7236-patch-1
Browse files Browse the repository at this point in the history
Error handling
  • Loading branch information
seba7236 authored Oct 21, 2024
2 parents 18b1d53 + 06bac80 commit 307ff84
Show file tree
Hide file tree
Showing 6 changed files with 271 additions and 90 deletions.
56 changes: 42 additions & 14 deletions lib/brave.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down Expand Up @@ -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"])

Expand All @@ -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"])

Expand All @@ -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"])

Expand All @@ -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:
Expand All @@ -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(
[
Expand Down Expand Up @@ -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(
[
Expand Down
56 changes: 42 additions & 14 deletions lib/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down Expand Up @@ -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"])

Expand All @@ -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"])

Expand All @@ -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"])

Expand All @@ -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:
Expand All @@ -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(
[
Expand Down Expand Up @@ -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(
[
Expand Down Expand Up @@ -275,6 +302,7 @@ class ClosedReason:
chromeWriter.write_json("notifications", output)
except Exception as e:
print(e)
return 0


def parse_extensions(path):
Expand Down
57 changes: 43 additions & 14 deletions lib/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand Down Expand Up @@ -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"])

Expand All @@ -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"])

Expand All @@ -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"])

Expand All @@ -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:
Expand All @@ -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(
[
Expand Down Expand Up @@ -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(
[
Expand Down
Loading

0 comments on commit 307ff84

Please sign in to comment.