All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: yocto@yoctoproject.org
Subject: [layerindex-web][PATCH 1/6] update.py: fix Ctrl+C behaviour
Date: Tue, 20 Feb 2018 16:45:53 +1300	[thread overview]
Message-ID: <20180220034558.14341-1-paul.eggleton@linux.intel.com> (raw)

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>
---
 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



             reply	other threads:[~2018-02-20  3:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20  3:45 Paul Eggleton [this message]
2018-02-20  3:45 ` [layerindex-web][PATCH 2/6] Add statistics page Paul Eggleton
2018-02-20  3:45 ` [layerindex-web][PATCH 3/6] Show layer description with newlines in layer detail Paul Eggleton
2018-02-20  3:45 ` [layerindex-web][PATCH 4/6] requirements.txt: add missing dependencies Paul Eggleton
2018-02-20  3:45 ` [layerindex-web][PATCH 5/6] requirements.txt: update some dependency versions Paul Eggleton
2018-02-20  3:45 ` [layerindex-web][PATCH 6/6] README: update " Paul Eggleton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180220034558.14341-1-paul.eggleton@linux.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.