From 1f3dbea29ba939dddabafc46164f66a8d87b0e64 Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Sat, 22 Jun 2024 11:00:17 -0700 Subject: [PATCH] Update NSLGameScanner.py --- NSLGameScanner.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/NSLGameScanner.py b/NSLGameScanner.py index 804bc78..f7b2f6b 100644 --- a/NSLGameScanner.py +++ b/NSLGameScanner.py @@ -197,17 +197,13 @@ hero64 = "" shortcuts_file = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf" # Check if the file exists and is not executable -if os.path.exists(shortcuts_file): - # Check if the file is not executable - if not os.access(shortcuts_file, os.X_OK): - print("The file exists but is not executable. Making it executable.") - # Set the file permissions to 755 - os.chmod(shortcuts_file, 0o755) +if os.path.exists(shortcuts_file) and not os.access(shortcuts_file, os.X_OK): + print("The file exists but is not executable. Writing empty shortcuts.") # Write {'shortcuts': {}} to the file with open(shortcuts_file, 'wb') as file: file.write(vdf.binary_dumps({'shortcuts': {}})) shortcuts = {'shortcuts': {}} -else: +elif os.path.exists(shortcuts_file): # Load the existing shortcuts with open(shortcuts_file, 'rb') as file: try: @@ -215,6 +211,9 @@ else: except Exception as e: print(f"Error reading file: {e}") shortcuts = {} +else: + print("The file does not exist. Creating an empty shortcuts dictionary.") + shortcuts = {'shortcuts': {}} # Check if the 'shortcuts' key is in the loaded data