update.py: fix Ctrl+C behaviour

If the user hit Ctrl+C during the initial info gathering then it didn't
break out of the loop in update.py, so you had to hit Ctrl+C for as many
layers as were involved in the update. Look for exit code 254 from
update_layer.py and stop if it is returned since that indicates Ctrl+C
has been used.

Additionally, ensure we return exit code 254 and print a message from
the main update script when it is interrupted in this way.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-02-12 15:46:44 +13:00
parent f5922091b4
commit b614cba817

View File

@ -337,7 +337,11 @@ def main():
logger.debug('Running layer update command: %s' % cmd)
ret, output = run_command_interruptible(cmd)
logger.debug('output: %s' % output)
if ret != 0:
if ret == 254:
# Interrupted by user, break out of loop
logger.info('Update interrupted, exiting')
sys.exit(254)
elif ret != 0:
continue
col = re.search("^BBFILE_COLLECTIONS = \"(.*)\"", output, re.M).group(1) or ''
ver = re.search("^LAYERVERSION = \"(.*)\"", output, re.M).group(1) or ''
@ -418,10 +422,14 @@ def main():
if ret == 254:
# Interrupted by user, break out of loop
break
logger.info('Update interrupted, exiting')
sys.exit(254)
finally:
utils.unlock_file(lockfile)
except KeyboardInterrupt:
logger.info('Update interrupted, exiting')
sys.exit(254)
finally:
update.log = ''.join(listhandler.read())
update.finished = datetime.now()