polish subprocess command
This commit is contained in:
parent
227bd99fb4
commit
f1365f21ae
@ -10,20 +10,29 @@ import subprocess, os
|
|||||||
class command():
|
class command():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
def initialize(self, environment, scriptPaht=''):
|
def initialize(self, environment, scriptPath=''):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
self.scriptPath = scriptPath
|
self.scriptPath = scriptPath
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'script: '+ self.scriptPath
|
return 'script: ' + os.path.basename(self.scriptPath) + ' fullpath: '+ self.scriptPath
|
||||||
def run(self):
|
def run(self):
|
||||||
|
if not os.path.exists(self.scriptPath):
|
||||||
|
self.env['runtime']['outputManager'].presentText('scriptfile does not exist' , soundIcon='', interrupt=False)
|
||||||
|
return
|
||||||
|
if not os.path.isfile(self.scriptPath):
|
||||||
|
self.env['runtime']['outputManager'].presentText('scriptfile is not a file' , soundIcon='', interrupt=False)
|
||||||
|
return
|
||||||
|
if not os.access(self.scriptPath, os.X_OK):
|
||||||
|
self.env['runtime']['outputManager'].presentText('scriptfile is not executable' , soundIcon='', interrupt=False)
|
||||||
|
return
|
||||||
p = Popen(self.scriptPath , stdout=PIPE, stderr=PIPE, shell=True)
|
p = Popen(self.scriptPath , stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
self.env['runtime']['outputManager'].interruptOutput()
|
self.env['runtime']['outputManager'].interruptOutput()
|
||||||
if stderr != '':
|
if stderr != '':
|
||||||
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False)
|
||||||
if stdout != ''
|
if stdout != '':
|
||||||
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user