Fix broke running with "xdg-su" in exec field (#200)

This commit is contained in:
Andrew 2019-01-21 18:50:58 +03:00 committed by Clement Lefebvre
parent df1460d7c5
commit 20a98cd287
2 changed files with 27 additions and 32 deletions

View File

@ -377,7 +377,7 @@ class ApplicationLauncher( easyButton ):
cmd = "mate-terminal -e \"" + self.appExec + "\""
Execute(cmd, self.appPath)
else:
Execute(self.appExec, self.appPath)
Execute(None, desktopFile=self.desktopFile)
def uninstall (self, *args ):
Execute("mint-remove-application " + self.desktopFile)

View File

@ -1,46 +1,41 @@
#!/usr/bin/python2
import os
from gi.repository import Gio
def RemoveArgs(Execline):
NewExecline = []
Specials=["\"%c\"", "%f","%F","%u","%U","%d","%D","%n","%N","%i","%c","%k","%v","%m","%M", "-caption", "/bin/sh", "sh", "-c", "STARTED_FROM_MENU=yes"]
for elem in Execline:
elem = elem.replace("'","")
elem = elem.replace("\"", "")
if elem not in Specials:
print elem
NewExecline.append(elem)
return NewExecline
if isinstance(Execline, list):
Execline = ' '.join(Execline)
Specials = ["%f", "%F", "%u", "%U", "%d", "%D", "%n", "%N", "%i", "%c", "%k", "%v", "%m", "%M",
"STARTED_FROM_MENU=yes"]
for spec in Specials:
if spec in Execline:
Execline = Execline.replace(spec, "")
return Execline
# Actually execute the command
def Execute( cmd , commandCwd=None):
if not commandCwd:
cwd = os.path.expanduser( "~" );
else:
tmpCwd = os.path.expanduser( commandCwd );
def Execute(cmd , commandCwd=None, desktopFile=None):
if desktopFile:
launcher = Gio.DesktopAppInfo.new_from_filename(desktopFile)
retval = launcher.launch_uris()
return retval
cwd = os.path.expanduser("~")
if commandCwd:
tmpCwd = os.path.expanduser(commandCwd)
if (os.path.exists(tmpCwd)):
cwd = tmpCwd
if isinstance( cmd, str ) or isinstance( cmd, unicode):
if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("xdg-su") >= 0) or (cmd.find("\"") >= 0):
print "running manually..."
try:
os.chdir(cwd)
os.system(cmd + " &")
return True
except Exception, detail:
print detail
return False
cmd = cmd.split()
cmd = RemoveArgs(cmd)
try:
os.chdir( cwd )
string = ' '.join(cmd)
string = string + " &"
os.system(string)
os.chdir(cwd)
os.system(cmd + " &")
return True
except Exception, detail:
print detail
except Exception as err:
print err
return False