Skip to content

Commit

Permalink
Added exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
StDensity committed Sep 12, 2023
1 parent d1f2f6b commit 94cfcf8
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions GUI_v0.2.0.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def start_search():
# Call the execute_search function
execute_search(total_searches, browser_open_delay, inspect_element_delay, search_delay)

# Re-enable Start Button
start_button['state'] = 'enabled'

# Disable Browser Close Check box
browser_close_checkbox.config(state="enabled")


# Function to close the application
def close_app():
Expand Down Expand Up @@ -114,10 +120,18 @@ def execute_search(total_searches, browser_open_delay, inspect_element_delay, se
# path_file = open('path.txt', 'r')
# browser_path = path_file.read()

path = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
path = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge1.exe"

# An exception is raised if the browser is not found.
try:
# Open Microsoft Edge Canary using the specified shortcut
os.startfile(path)
except FileNotFoundError as e:
show_alert("Browser Not Found", "Please ensure that edge is installed in: \n" + path)
return
except Exception as e:
show_alert("Error", "An error occurred while opening the browser. Error code: " + str(e))

# Open Microsoft Edge Canary using the specified shortcut
os.startfile(path)

# Pause the script execution for the specified browser open delay
time.sleep(browser_open_delay)
Expand Down Expand Up @@ -198,11 +212,7 @@ def execute_search(total_searches, browser_open_delay, inspect_element_delay, se
# Closes Inspect Elements
auto.hotkey('ctrl', 'shift', 'i')

# Re-enable Start Button
start_button['state'] = 'enabled'

# Disable Browser Close Check box
browser_close_checkbox.config(state="enabled")


# Run the Tkinter main loop
Expand Down

0 comments on commit 94cfcf8

Please sign in to comment.