Access test plopped into function

This commit is contained in:
Fierelier 2019-01-07 00:07:32 +01:00
parent 4d23c17586
commit c5a95d5868

View File

@ -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