processGraph: check return code of the subprocess

This commit is contained in:
Fabien Castan 2017-09-20 00:55:06 +02:00
parent ff2a65685c
commit f54c765b30

View file

@ -367,11 +367,18 @@ class Node:
statThread = StatisticsThread(self) statThread = StatisticsThread(self)
statThread.start() statThread.start()
try: try:
returnCode = 1
with open(self.logFile(), 'w') as logF: with open(self.logFile(), 'w') as logF:
cmd = self.commandLine() cmd = self.commandLine()
print(' =====> commandLine: ', cmd) print('\n =====> commandLine:\n', cmd, '\n')
print(' - logFile: ', self.logFile()) print(' - logFile: ', self.logFile())
subprocess.call(cmd, stdout=logF, stderr=logF, shell=True) returnCode = subprocess.call(cmd, stdout=logF, stderr=logF, shell=True)
if returnCode != 0:
logContent = ''
with open(self.logFile(), 'r') as logF:
logContent = ''.join(logF.readlines())
self.upgradeStatusTo(pg.Status.ERROR)
raise RuntimeError('Error on node "{}":\nLog:\n{}'.format(self.name, logContent))
except: except:
self.upgradeStatusTo(pg.Status.ERROR) self.upgradeStatusTo(pg.Status.ERROR)
raise raise