add custom exception and barebones error handling to launcher detection
This commit is contained in:
parent
7ce1216f71
commit
b727633f74
23
installer.py
23
installer.py
@ -29,6 +29,11 @@ from pathlib import Path
|
|||||||
# as far as i can tell, i wanted to add an "option" to the function that toggled the warning m-
|
# as far as i can tell, i wanted to add an "option" to the function that toggled the warning m-
|
||||||
# -essage, so i dont have to use all this space here defining functions i dont really need.
|
# -essage, so i dont have to use all this space here defining functions i dont really need.
|
||||||
|
|
||||||
|
class customerror(Exception):
|
||||||
|
def __init__(self, message):
|
||||||
|
self.message = message
|
||||||
|
super().__init__(self.message)
|
||||||
|
|
||||||
def delete_directory_warn(directory_to_delete, warn=False):
|
def delete_directory_warn(directory_to_delete, warn=False):
|
||||||
#this defines a function to delete a directory (no shit)
|
#this defines a function to delete a directory (no shit)
|
||||||
try:
|
try:
|
||||||
@ -115,13 +120,16 @@ def check_if_exists_and_delete_file(filepath):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
global detectedlauncher
|
||||||
|
detectedlauncher = "null"
|
||||||
|
|
||||||
def check_for_launcher_files(filepath, launchername):
|
def check_for_launcher_files(filepath, launchername):
|
||||||
#checks for evidence of 3rd party launchers and sets a variable flag if a launcher is installed
|
#checks for evidence of 3rd party launchers and sets a variable flag if a launcher is installed
|
||||||
if os.path.exists(filepath):
|
if os.path.exists(filepath):
|
||||||
print("Alternative Minecraft launcher detected: " + str(launchername))
|
print("[INFO]: Detected Minecraft launcher: " + str(launchername))
|
||||||
detectedlauncher = str(launchername)
|
detectedlauncher = str(launchername)
|
||||||
else:
|
else:
|
||||||
pass
|
raise customerror("[ERR!]: File not detected.")
|
||||||
|
|
||||||
|
|
||||||
# --------------------the real shit!------------------------
|
# --------------------the real shit!------------------------
|
||||||
@ -133,13 +141,16 @@ os.chdir(homedir)
|
|||||||
|
|
||||||
global mcfolder
|
global mcfolder
|
||||||
global modfolder
|
global modfolder
|
||||||
# `global` sets these variables to exist outside of the scope of these specific `if` statements.
|
# `global` sets these variables to exist outside of the scope of these specific `if` statements.
|
||||||
|
|
||||||
if platform.system() == "Linux":
|
if platform.system() == "Linux":
|
||||||
print("Operating system detected: Linux")
|
print("Operating system detected: Linux")
|
||||||
|
|
||||||
check_for_launcher_files(str(Path.cwd()) + "/.var/app/org.prismlauncher.Prism.Launcher", "PrismLauncherFlatpak")
|
try:
|
||||||
check_for_launcher_files(str(Path.cwd()) + "/.local/share/PrismLauncher/prismlauncher.cfg", "PrismLauncherPackage")
|
check_for_launcher_files(str(Path.cwd()) + "/.local/share/PrismLauncher", "PrismLauncherPackage")
|
||||||
|
check_for_launcher_files(str(Path.cwd()) + "/.var/app/org.prismlauncher.Prism.Launcher", "PrismLauncherFlatpak")
|
||||||
|
except customerror as e:
|
||||||
|
pass
|
||||||
|
|
||||||
os.chdir(".minecraft")
|
os.chdir(".minecraft")
|
||||||
mcfolder = str(Path.cwd())
|
mcfolder = str(Path.cwd())
|
||||||
@ -160,7 +171,7 @@ elif platform.system() == "Windows":
|
|||||||
mcfolder = str(Path.cwd())
|
mcfolder = str(Path.cwd())
|
||||||
print("Changed current working directory to '" + str(mcfolder) + "'")
|
print("Changed current working directory to '" + str(mcfolder) + "'")
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print(); print("Backing up minecraft install...")
|
print(); print("Backing up minecraft install...")
|
||||||
print("Don't close the window! This'll take a moment...")
|
print("Don't close the window! This'll take a moment...")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user