From c5a95d586818e398f8c9056d5fc138c71a768362 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Mon, 7 Jan 2019 00:07:32 +0100 Subject: [PATCH] Access test plopped into function --- UniversalModloader.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/UniversalModloader.py b/UniversalModloader.py index be5129b..eaff89e 100644 --- a/UniversalModloader.py +++ b/UniversalModloader.py @@ -42,6 +42,13 @@ def openFileWithStandardApp(path): else: subprocess.call(['xdg-open', path]) +def testAccess(path): + try: + os.rename(path,path) + return True + except: + return False + def exceptionCleanup(): success = True print("Attempting cleanup.") @@ -138,9 +145,7 @@ def loadMods(output = False, fast = False): print("Claiming mod folder...") claimFolder(modPath) print("Testing access...") - try: - os.rename(appPath,appPath) - except Exception as e: + if testAccess(appPath) == False: if output: print("Can't access folder! Is it in use?") return print("Cloning app folder...") @@ -153,9 +158,7 @@ def loadMods(output = False, fast = False): os.rename(tmpAppPath,appPath) else: print("Testing access...") - try: - os.rename(appPath,appPath) - except Exception as e: + if testAccess(appPath) == False: if output: print("Can't access folder! Is it in use?") return os.rename(appPath,tmpAppPath) @@ -173,9 +176,7 @@ def unloadMods(output = False): return True print("Testing access...") - try: - os.rename(appPath,appPath) - except Exception as e: + if testAccess(appPath) == False: if output: print("Can't access folder! Is it in use?") return