add custom exception and barebones error handling to launcher detection
This commit is contained in:
parent
7ce1216f71
commit
b727633f74
17
installer.py
17
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!------------------------
|
||||||
@ -138,8 +146,11 @@ global modfolder
|
|||||||
if platform.system() == "Linux":
|
if platform.system() == "Linux":
|
||||||
print("Operating system detected: Linux")
|
print("Operating system detected: Linux")
|
||||||
|
|
||||||
|
try:
|
||||||
|
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")
|
check_for_launcher_files(str(Path.cwd()) + "/.var/app/org.prismlauncher.Prism.Launcher", "PrismLauncherFlatpak")
|
||||||
check_for_launcher_files(str(Path.cwd()) + "/.local/share/PrismLauncher/prismlauncher.cfg", "PrismLauncherPackage")
|
except customerror as e:
|
||||||
|
pass
|
||||||
|
|
||||||
os.chdir(".minecraft")
|
os.chdir(".minecraft")
|
||||||
mcfolder = str(Path.cwd())
|
mcfolder = str(Path.cwd())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user