super-rsu: improve error handling for subprocesses
* add 'fpgasupdate' to the list of executables to check for in the
`check_requirements` method
* add try/except around spawning a subprocess task (calling the task())
@@ -730,7 +730,12 @@ class pac(object):
while tasks:
# get the next task...
task, flashfile = tasks.pop(0)
+ try:
p = task()
+ except OSError as err:
+ LOG.error('Error (%s) calling process: %s', err, task.cmd)
+ self._errors += 1
+ else:
while p.poll() is None:
if self._terminate:
task.terminate(FLASH_TIMEOUT)
@@ -739,7 +744,8 @@ class pac(object):
break
time.sleep(0.1)
if p.returncode:
- LOG.warning('%s exited with code: %s', task.cmd, p.returncode)
+ LOG.warning('%s exited with code: %s', task.cmd,
+ p.returncode)
self._errors += 1
LOG.debug('task completed in %s', timedelta(
@@ -1198,7 +1204,7 @@ def check_requirements(boards, args, rsu_config):
return False
missing = []
- callables = ['fpgaflash']
+ callables = ['fpgaflash', 'fpgasupdate']
if 'nvmupdate' in rsu_config:
if not os.path.exists(OPAE_NVMUPDATE_EXE):
LOG.debug("missing '%s'", NVMUPDATE_EXE)
