Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
Now the installer checks for uncompatible files
Browse files Browse the repository at this point in the history
  • Loading branch information
Izheil committed May 14, 2021
1 parent 25fd4b9 commit c5e90bd
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 10 deletions.
37 changes: 33 additions & 4 deletions Installers/Multirow & other functions/Builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def SystemOS():
accRoot = True

elif OSinUse == "Windows" and ctypes.windll.shell32.IsUserAnAdmin() == 0:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
print("Not running as admin, restarting as admin...")
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, subprocess.list2cmdline(sys.argv), None, 1)
sys.exit()

def readProfiles(profile):
Expand Down Expand Up @@ -368,16 +369,44 @@ def fullPatcher(FFversion, FFprofile):
"This method patches both the root and profile folders"
try:
if FFversion != None:

configFiles = []
removeAltConfig = False
for r, d, f in os.walk(os.path.normpath(FFversion + "/defaults/pref")):
for file in f:
configFiles.append(os.path.join(r, file))

# Removes non-standard configuration files if required
for conFile in configFiles:
if (conFile != os.path.normpath(FFversion + "/defaults/pref/channel-prefs.js") and
conFile != os.path.normpath(FFversion + "/defaults/pref/config-prefs.js")):
confError = ("A non-standard configuration file was detected on Firefox root folder " +
"which might prevent the functions to work properly.\n" +
"\nWould you like to remove the following configuration file " +
"to fix the issue?\n\n" + conFile)
if not argumentsInUse:
removeAltConfig = messagebox.askyesno("Alternative configuration detected", confError)
if removeAltConfig:
os.remove(conFile)
else:
messagebox.showwarning("Possible compatibility problem",
"It is possible that the installed functions won't work until " +
"you remove the non-standard configuration files inside this path:\n" +
os.path.normpath(FFversion + "/defaults/pref"))
else:
print("The file " + conFile + " might prevent the functions from working as they should.\n" +
"If you added this file, remove it or merge it with 'config-prefs.js' in the same location.")

# We first define the location of the files
ConfPref = os.path.normpath(FFversion + "/defaults/pref/config-prefs.js")
ConfJS = os.path.normpath(FFversion + "/config.js")

# We patch the root folder here
if os.access(ConfJS, os.F_OK) and os.access(ConfPref, os.F_OK):

distutils.file_util.copy_file(os.path.normpath(sys._MEIPASS + "/root/defaults/pref/config-prefs.js"),
distutils.file_util.copy_file(os.path.normpath(sys._MEIPASS + "/root/defaults/pref/config-prefs.js"),
os.path.normpath(FFversion + "/defaults/pref/"), update=True)
distutils.file_util.copy_file(os.path.normpath(sys._MEIPASS + "/root/config.js"),
distutils.file_util.copy_file(os.path.normpath(sys._MEIPASS + "/root/config.js"),
FFversion, update=True)

elif os.access(os.path.normpath(FFversion + "/config.js"), os.F_OK) or \
Expand Down Expand Up @@ -413,7 +442,7 @@ def fullPatcher(FFversion, FFprofile):
os.path.normpath(FFprofile + "/chrome/utils"), update=True)

else:
shutil.copytree(os.path.normpath(sys._MEIPASS + "/utils"),
shutil.copytree(os.path.normpath(sys._MEIPASS + "/utils"),
os.path.normpath(FFprofile + "/chrome/utils"))

if OSinUse == "Linux":
Expand Down
42 changes: 36 additions & 6 deletions Installers/Multirow & other functions/Quantum-Nox-Installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def SystemOS():
accRoot = True

elif OSinUse == "Windows" and ctypes.windll.shell32.IsUserAnAdmin() == 0:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
# Only required to prevent double windows on build
# sys.exit()
print("Not running as admin, restarting as admin...")
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, subprocess.list2cmdline(sys.argv), None, 1)
sys.exit()

def readProfiles(profile):
"Fetches the profile folders"
Expand Down Expand Up @@ -372,7 +372,36 @@ def DPFinder():
def fullPatcher(FFversion, FFprofile):
"This method patches both the root and profile folders"
try:
# Check that the provided Firefox path is not empty
if FFversion is not None:

configFiles = []
removeAltConfig = False
for r, d, f in os.walk(os.path.normpath(FFversion + "/defaults/pref")):
for file in f:
configFiles.append(os.path.join(r, file))

# Removes non-standard configuration files if required
for conFile in configFiles:
if (conFile != os.path.normpath(FFversion + "/defaults/pref/channel-prefs.js") and
conFile != os.path.normpath(FFversion + "/defaults/pref/config-prefs.js")):
confError = ("A non-standard configuration file was detected on Firefox root folder " +
"which might prevent the functions to work properly.\n" +
"\nWould you like to remove the following configuration file " +
"to fix the issue?\n\n" + conFile)
if not argumentsInUse:
removeAltConfig = messagebox.askyesno("Alternative configuration detected", confError)
if removeAltConfig:
os.remove(conFile)
else:
messagebox.showwarning("Possible compatibility problem",
"It is possible that the installed functions won't work until " +
"you remove the non-standard configuration files inside this path:\n" +
os.path.normpath(FFversion + "/defaults/pref"))
else:
print("The file " + conFile + " might prevent the functions from working as they should.\n" +
"If you added this file, remove it or merge it with 'config-prefs.js' in the same location.")

# We first define the location of the files
ConfPref = os.path.normpath(FFversion + "/defaults/pref/config-prefs.js")
ConfJS = os.path.normpath(FFversion + "/config.js")
Expand Down Expand Up @@ -405,7 +434,8 @@ def fullPatcher(FFversion, FFprofile):
shutil.chown(ConfJS, rootUser, rootGroup)
os.chmod(ConfJS, 0o775)

if FFprofile != None:
# Check that the provided profile path is not empty
if FFprofile is not None:

# We patch the profile folder here
if os.access(os.path.normpath(FFprofile + "/chrome/utils"), os.F_OK):
Expand Down Expand Up @@ -433,8 +463,8 @@ def fullPatcher(FFversion, FFprofile):
shutil.chown(file, rootUser, rootGroup)
os.chmod(file, 0o775)

except IOError:
errorMessage = "You need higher privileges to apply the patch."
except IOError as err:
errorMessage = "You need higher privileges to apply the patch.\n\n" + str(err)
if not argumentsInUse:
messagebox.showerror("Error", errorMessage)
else:
Expand Down

0 comments on commit c5e90bd

Please sign in to comment.