3838import sys
3939import subprocess
4040from PyQt5 import QtWidgets
41+ from . import gen
4142
4243
4344def isUserAdmin ():
@@ -46,7 +47,7 @@ def isUserAdmin():
4647 (root on Unix), otherwise False.
4748
4849 Warning: The inner function fails unless you have Windows XP SP2 or
49- higher. The failure causes a traceback to be printed and this
50+ higher. The failure causes a traceback to be gen.loged and this
5051 function to return False.
5152 """
5253
@@ -57,7 +58,7 @@ def isUserAdmin():
5758 return ctypes .windll .shell32 .IsUserAnAdmin ()
5859 except :
5960 traceback .print_exc ()
60- print ("Admin check failed, assuming not an admin." )
61+ gen . log ("Admin check failed, assuming not an admin." )
6162 return False
6263 elif platform .system () == "Linux" :
6364 return os .getuid () == 0
@@ -103,7 +104,7 @@ def runAsAdmin(cmdLine=None, wait=True):
103104 #showCmd = win32con.SW_HIDE
104105 lpVerb = 'runas' # causes UAC elevation prompt.
105106
106- #print ("Running", cmd, params)
107+ #gen.log ("Running", cmd, params)
107108
108109 # ShellExecute() doesn't seem to allow us to fetch the PID or handle
109110 # of the process, so we can't get anything useful from it. Therefore
@@ -121,7 +122,7 @@ def runAsAdmin(cmdLine=None, wait=True):
121122 procHandle = procInfo ['hProcess' ]
122123 obj = win32event .WaitForSingleObject (procHandle , win32event .INFINITE )
123124 rc = win32process .GetExitCodeProcess (procHandle )
124- #print "Process handle %s returned code %s" % (procHandle, rc)
125+ #gen.log "Process handle %s returned code %s" % (procHandle, rc)
125126 else :
126127 rc = None
127128
@@ -157,10 +158,10 @@ def adminCmd(cmd, fork=False, gui=False):
157158 'Could not find any of: pkexec, sudo, gksu, kdesu, gksudo, or kdesudo. Please install one then restart multibootusb.' )
158159 sys .exit (0 )
159160 final_cmd = ' ' .join (sudo_cmd + ['"' + ' ' .join (cmd ).replace ('"' , '\\ "' ) + '"' ])
160- print ("Executing ==> " + final_cmd )
161+ gen . log ("Executing ==> " + final_cmd )
161162 if fork :
162163 return subprocess .Popen (final_cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE , bufsize = 1 , shell = True )
163164 else :
164165 ret = subprocess .call (final_cmd , shell = True )
165- print ("Process returned ==> " + str (ret ))
166+ gen . log ("Process returned ==> " + str (ret ))
166167 return ret
0 commit comments