decode subprocess call correctly

This commit is contained in:
chrys 2016-10-18 22:24:10 +02:00
parent 303c5125f4
commit e44bbc6c07

View File

@ -28,14 +28,19 @@ class command():
if not os.access(self.scriptPath, os.X_OK): if not os.access(self.scriptPath, os.X_OK):
self.env['runtime']['outputManager'].presentText('scriptfile is not executable' , soundIcon='', interrupt=False) self.env['runtime']['outputManager'].presentText('scriptfile is not executable' , soundIcon='', interrupt=False)
return return
p = Popen(self.scriptPath , stdout=PIPE, stderr=PIPE, shell=True) try:
stdout, stderr = p.communicate() p = Popen(self.scriptPath , stdout=PIPE, stderr=PIPE, shell=True)
self.env['runtime']['outputManager'].interruptOutput() stdout, stderr = p.communicate()
stderr = str(stderr) self.env['runtime']['outputManager'].interruptOutput()
stdout = str(stdout) screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding')
if stderr != '': stderr = stderr.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False) stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
if stdout != '': if stderr != '':
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False) self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False)
if stdout != '':
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False)
except Exception as e:
self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False)
def setCallback(self, callback): def setCallback(self, callback):
pass pass