2015-06-26 01:36:36 +01:00
|
|
|
#!/usr/bin/python2
|
2014-03-28 15:44:13 +00:00
|
|
|
|
2009-07-27 11:45:34 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# Actually execute the command
|
2013-02-10 16:31:00 +00:00
|
|
|
def Execute( cmd , commandCwd=None):
|
|
|
|
if not commandCwd:
|
|
|
|
cwd = os.path.expanduser( "~" );
|
|
|
|
else:
|
|
|
|
tmpCwd = os.path.expanduser( commandCwd );
|
|
|
|
if (os.path.exists(tmpCwd)):
|
|
|
|
cwd = tmpCwd
|
|
|
|
|
2013-02-17 02:52:18 +00:00
|
|
|
if isinstance( cmd, str ) or isinstance( cmd, unicode):
|
2015-06-14 12:37:04 +01:00
|
|
|
if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0):
|
2009-07-27 11:45:34 +01:00
|
|
|
print "running manually..."
|
2014-01-20 15:08:35 +00:00
|
|
|
try:
|
|
|
|
os.chdir(cwd)
|
|
|
|
os.system(cmd + " &")
|
|
|
|
return True
|
|
|
|
except Exception, detail:
|
|
|
|
print detail
|
|
|
|
return False
|
2009-07-27 11:45:34 +01:00
|
|
|
cmd = cmd.split()
|
|
|
|
cmd = RemoveArgs(cmd)
|
2013-02-10 16:31:00 +00:00
|
|
|
|
2009-07-27 11:45:34 +01:00
|
|
|
try:
|
2013-02-10 16:31:00 +00:00
|
|
|
os.chdir( cwd )
|
2013-11-25 14:04:49 +00:00
|
|
|
string = ' '.join(cmd)
|
|
|
|
string = string + " &"
|
|
|
|
os.system(string)
|
2009-07-27 11:45:34 +01:00
|
|
|
return True
|
|
|
|
except Exception, detail:
|
|
|
|
print detail
|
|
|
|
return False
|
|
|
|
|