From a2f97eb0c6022ed7998ab369b47ff52acee17820 Mon Sep 17 00:00:00 2001 From: Supercam19 <79729769+supercam19@users.noreply.github.com> Date: Sat, 23 Mar 2024 21:58:23 -0400 Subject: [PATCH] Fix error popup when --launch-game is used --- gmutils.py | 3 ++- main.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gmutils.py b/gmutils.py index 22f6ea3..6b86d64 100644 --- a/gmutils.py +++ b/gmutils.py @@ -1,6 +1,7 @@ import json import os import subprocess +import sys import customtkinter import requests @@ -45,7 +46,7 @@ def check_files(): # print("displayz.exe downloaded") except Exception as e: popup("Error", f"Could not download required file displayz.exe. Submit an issue to the GitHub if you believe this is a bug:\n\n {e}") - exit(0) + sys.exit(0) if not os.path.isfile("settings.json"): with open("settings.json", "w") as f: f.write('{"default_monitor": 0, "games": []}') diff --git a/main.py b/main.py index 23fd117..2aefb4b 100644 --- a/main.py +++ b/main.py @@ -256,7 +256,7 @@ def launch_game(game_name): time.sleep(2) os.system(game_name) set_monitor(default_monitor) - exit(0) + sys.exit(0) else: for game in games: if game.get("name") == game_name: @@ -265,7 +265,7 @@ def launch_game(game_name): os.chdir(os.path.dirname(game.get('path'))) os.system(f"\"{game.get('process_name')}\"") set_monitor(default_monitor) - exit(0) + sys.exit(0) def load_games(window): @@ -316,6 +316,8 @@ def main(open_window): launch_game(sys.argv[i + 1]) main(show_on_startup) + except SystemExit: + pass except Exception as e: popup("Error", f"An error occurred. If you believe this to be a bug, please submit an issue at github.com/supercam19/GameMonitor/issues with the error message:\n\n{e}")