Ditching some junk
This commit is contained in:
parent
36dee2adee
commit
671d8a2a5b
|
@ -34,18 +34,7 @@ modPath = False
|
|||
originalModPath = False
|
||||
api = True
|
||||
|
||||
#Exception Handler
|
||||
def openFileWithStandardApp(path):
|
||||
# Windows
|
||||
if os.name == "nt":
|
||||
os.startfile(path)
|
||||
# Macintosh
|
||||
elif sys.platform == "darwin":
|
||||
subprocess.call(['open', path])
|
||||
# Generic Unix (X11)
|
||||
else:
|
||||
subprocess.call(['xdg-open', path])
|
||||
|
||||
#Modloader
|
||||
def testAccess(path):
|
||||
try:
|
||||
os.rename(path,path)
|
||||
|
@ -53,65 +42,6 @@ def testAccess(path):
|
|||
except:
|
||||
return False
|
||||
|
||||
def exceptionCleanup():
|
||||
success = True
|
||||
print("Attempting cleanup.")
|
||||
print("\nMaking folders visible...")
|
||||
try:
|
||||
#ctypes.windll.kernel32.SetFileAttributesW(appPath,128)
|
||||
#ctypes.windll.kernel32.SetFileAttributesW(originalAppPath,128)
|
||||
pass
|
||||
except Exception as e:
|
||||
success = False
|
||||
print(str(e))
|
||||
|
||||
print("\nUnloading mods...")
|
||||
try:
|
||||
unloadMods()
|
||||
except Exception as e:
|
||||
success = False
|
||||
print(str(e))
|
||||
|
||||
print("\nCleaning up temporary files...")
|
||||
try:
|
||||
cleanUp()
|
||||
except Exception as e:
|
||||
success = False
|
||||
print(str(e))
|
||||
|
||||
if success == False:
|
||||
print("\nCleanup not fully successful. Please review the errors, and go to X for a guide on how to reset your game manually. Sorry for the inconvenience, I tried :(")
|
||||
|
||||
return success
|
||||
|
||||
def logError(logFilePath,textList):
|
||||
logFile = False
|
||||
|
||||
try:
|
||||
logFile = open(logFilePath,"w")
|
||||
except:
|
||||
return False
|
||||
|
||||
try:
|
||||
for line in textList:
|
||||
logFile.write(line + "\n")
|
||||
except:
|
||||
logFile.close()
|
||||
return False
|
||||
|
||||
logFile.close()
|
||||
return True
|
||||
|
||||
def exceptionHandler(exc_type, exc_value, tb):
|
||||
clear()
|
||||
|
||||
print("An error occurred, trying to revert everything...")
|
||||
exceptionCleanup()
|
||||
input()
|
||||
|
||||
#sys.excepthook = exceptionHandler
|
||||
|
||||
#Modloader
|
||||
def cloneMods(modDir):
|
||||
for root,dirs,files in walklevel(modDir,0):
|
||||
for dir in dirs:
|
||||
|
@ -144,10 +74,6 @@ def loadMods(output = False, fast = False):
|
|||
if output: print("Mods are already loaded and could not be unloaded.")
|
||||
return False
|
||||
|
||||
#print("Claiming app folder...")
|
||||
#claimFolder(appPath)
|
||||
#print("Claiming mod folder...")
|
||||
#claimFolder(modPath)
|
||||
print("Testing access...")
|
||||
if testAccess(appPath) == False:
|
||||
if output: print("Can't access folder! Is it in use?")
|
||||
|
@ -259,15 +185,6 @@ def cloneFolder(src,dst,rpl,ignoreMods = True, isMod = False):
|
|||
|
||||
print("")
|
||||
|
||||
def claimFolder(path):
|
||||
os.chmod(path, stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO)
|
||||
for root,dirs,files in os.walk(path):
|
||||
for dir in dirs:
|
||||
os.chmod(os.path.join(root,dir), stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO)
|
||||
|
||||
for file in files:
|
||||
os.chmod(os.path.join(root,file), stat.S_IRWXU| stat.S_IRWXG| stat.S_IRWXO)
|
||||
|
||||
def walklevel(some_dir, level=1):
|
||||
some_dir = some_dir.rstrip(os.path.sep)
|
||||
assert os.path.isdir(some_dir)
|
||||
|
|
Loading…
Reference in New Issue