Merge branch 'cwd-fix' of https://github.com/xwizard/mintmenu into xwizard-cwd-fix

Conflicts:
	usr/lib/linuxmint/mintMenu/plugins/execute.py
This commit is contained in:
Clement Lefebvre 2013-11-25 12:58:37 +00:00
commit 0211675202
2 changed files with 14 additions and 4 deletions

View File

@ -299,6 +299,7 @@ class ApplicationLauncher( easyButton ):
self.appCategories = desktopItem.getCategories() self.appCategories = desktopItem.getCategories()
self.appGnomeDocPath = desktopItem.get( "X-MATE-DocPath" ) or "" self.appGnomeDocPath = desktopItem.get( "X-MATE-DocPath" ) or ""
self.useTerminal = desktopItem.getTerminal() self.useTerminal = desktopItem.getTerminal()
self.appPath = desktopItem.getPath()
if not self.appGnomeDocPath: if not self.appGnomeDocPath:
self.appKdeDocPath = desktopItem.getDocPath() or "" self.appKdeDocPath = desktopItem.getDocPath() or ""
@ -384,9 +385,9 @@ class ApplicationLauncher( easyButton ):
if self.appExec: if self.appExec:
if self.useTerminal: if self.useTerminal:
cmd = "x-terminal-emulator -e \"" + self.appExec + "\"" cmd = "x-terminal-emulator -e \"" + self.appExec + "\""
Execute(cmd) Execute(cmd, self.appPath)
else: else:
Execute(self.appExec) Execute(self.appExec, self.appPath)
def uninstall (self, *args ): def uninstall (self, *args ):
Execute("gksu /usr/lib/linuxmint/mintMenu/mintRemove.py " + self.desktopFile) Execute("gksu /usr/lib/linuxmint/mintMenu/mintRemove.py " + self.desktopFile)

View File

@ -13,16 +13,25 @@ def RemoveArgs(Execline):
return NewExecline return NewExecline
# Actually execute the command # Actually execute the command
def Execute( cmd ): 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
if isinstance( cmd, str ) or isinstance( cmd, unicode): if isinstance( cmd, str ) or isinstance( cmd, unicode):
if (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0): if (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0):
print "running manually..." print "running manually..."
os.chdir(cwd)
os.system(cmd + " &") os.system(cmd + " &")
return True return True
cmd = cmd.split() cmd = cmd.split()
cmd = RemoveArgs(cmd) cmd = RemoveArgs(cmd)
try: try:
os.chdir( os.path.expanduser( "~" ) ) os.chdir( cwd )
subprocess.Popen( cmd ) subprocess.Popen( cmd )
return True return True
except Exception, detail: except Exception, detail: