From f1365f21ae47eebc73d1cdc1d574507c49998c4b Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 18 Oct 2016 19:16:58 +0200 Subject: [PATCH] polish subprocess command --- src/fenrir/commands/commands/subprocess.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/fenrir/commands/commands/subprocess.py b/src/fenrir/commands/commands/subprocess.py index 183c52c9..4e004c36 100644 --- a/src/fenrir/commands/commands/subprocess.py +++ b/src/fenrir/commands/commands/subprocess.py @@ -10,20 +10,29 @@ import subprocess, os class command(): def __init__(self): pass - def initialize(self, environment, scriptPaht=''): + def initialize(self, environment, scriptPath=''): self.env = environment self.scriptPath = scriptPath def shutdown(self): pass def getDescription(self): - return 'script: '+ self.scriptPath + return 'script: ' + os.path.basename(self.scriptPath) + ' fullpath: '+ self.scriptPath 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) stdout, stderr = p.communicate() self.env['runtime']['outputManager'].interruptOutput() if stderr != '': self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False) - if stdout != '' + if stdout != '': self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False) def setCallback(self, callback): pass