[yocto] [layerindex-web][PATCH 1/6] update.py: fix Ctrl+C behaviour
Paul Eggleton
paul.eggleton at linux.intel.com
Mon Feb 19 19:45:53 PST 2018
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 at linux.intel.com>
---
layerindex/update.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/layerindex/update.py b/layerindex/update.py
index 5c83b00..f60b943 100755
--- a/layerindex/update.py
+++ b/layerindex/update.py
@@ -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()
--
2.14.3
More information about the yocto
mailing list