From 8ddc735d3f70e1b6c94e9806bdb9887a1289d9d3 Mon Sep 17 00:00:00 2001 From: maglore9900 Date: Thu, 29 Aug 2024 12:57:33 -0400 Subject: [PATCH] Update app_launcher.py added try to find_and_open_app in app_launcher.py --- modules/app_launcher.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/app_launcher.py b/modules/app_launcher.py index 52c6798..92b026e 100644 --- a/modules/app_launcher.py +++ b/modules/app_launcher.py @@ -55,13 +55,16 @@ class AppLauncher: self.index_applications() def find_and_open_app(self, app_name): - match = get_close_matches(app_name.lower(), self.index.keys(), n=1, cutoff=0.6) + try: + match = get_close_matches(app_name.lower(), self.index.keys(), n=1, cutoff=0.6) - if match: - app_path = self.index[match[0]]['path'] - subprocess.Popen(app_path) # Use Popen instead of run - print(f"Opening {match[0]} at {app_path}") - else: - print(f"No matching application found for '{app_name}'") + if match: + app_path = self.index[match[0]]['path'] + subprocess.Popen(app_path) # Use Popen instead of run + print(f"Opening {match[0]} at {app_path}") + else: + print(f"No matching application found for '{app_name}'") + except (FileNotFoundError, ValueError, KeyError): + print(f"Error opening application: {app_name}")