]> arthur.barton.de Git - bup.git/commitdiff
cmd/{index,save}: handle ctrl-c without printing a big exception trace. bup-0.12a
authorAvery Pennarun <apenwarr@gmail.com>
Sat, 13 Mar 2010 01:40:46 +0000 (20:40 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Sat, 13 Mar 2010 02:47:39 +0000 (21:47 -0500)
It's not very exciting to look at a whole stack trace just because someone
hit ctrl-c, especially since that's designed to work fine.  Trim it down in
that case.

cmd/index-cmd.py
cmd/save-cmd.py
lib/bup/helpers.py

index 683989007988e5a38a48a27256dd33a8efd106b9..c3d9090884f28d01ccf29299d8281eaa63f4143f 100755 (executable)
@@ -142,6 +142,8 @@ if opt.fake_valid and opt.fake_invalid:
 git.check_repo_or_die()
 indexfile = opt.indexfile or git.repo('bupindex')
 
+handle_ctrl_c()
+
 if opt.check:
     log('check: starting initial check.\n')
     check_index(index.Reader(indexfile))
index cdae7f683f91282320a3ae8487d58da1774f6d55..b97baa3b50cd4851c413112e25e0a735c0e0ffca 100755 (executable)
@@ -37,6 +37,8 @@ else:
     oldref = refname and git.read_ref(refname) or None
     w = git.PackWriter()
 
+handle_ctrl_c()
+
 
 def eatslash(dir):
     if dir.endswith('/'):
index 0aa69458cd074247698b098b7f403b3551fdc081..ba71727a66d165c2d35b915569f10fdb9a025847 100644 (file)
@@ -284,3 +284,13 @@ istty = os.isatty(2) or atoi(os.environ.get('BUP_FORCE_TTY'))
 def progress(s):
     if istty:
         log(s)
+
+
+def handle_ctrl_c():
+    oldhook = sys.excepthook
+    def newhook(exctype, value, traceback):
+        if exctype == KeyboardInterrupt:
+            log('Interrupted.\n')
+        else:
+            return oldhook(exctype, value, traceback)
+    sys.excepthook = newhook