Update app_launcher.py

added try to find_and_open_app in app_launcher.py
This commit is contained in:
maglore9900 2024-08-29 12:57:33 -04:00
parent ec07b096dc
commit 8ddc735d3f

View File

@ -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}")