summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-08-19 00:05:22 -0600
committerTavian Barnes <tavianator@gmail.com>2011-08-19 00:05:22 -0600
commitc0284b69fe0ee82d1f604a1b6f0511b4f129b919 (patch)
tree921fd2dc329cbf01383cc3cdd4e30e6954318775 /dimension
parent8ba39e9ea0ccfb08edaa9179e4893acb6c478aad (diff)
downloaddimension-c0284b69fe0ee82d1f604a1b6f0511b4f129b919.tar.xz
Support thread cancelation, and handle ^C in the client.
Diffstat (limited to 'dimension')
-rw-r--r--dimension/dimension.in30
1 files changed, 21 insertions, 9 deletions
diff --git a/dimension/dimension.in b/dimension/dimension.in
index 01dc2f3..f0db4fc 100644
--- a/dimension/dimension.in
+++ b/dimension/dimension.in
@@ -111,21 +111,33 @@ from dimension import *
# Display a progress bar
def _progress_bar(str, progress):
- if not _args.quiet:
- print(str, end = ' ')
- _sys.stdout.flush()
+ try:
+ if not _args.quiet:
+ print(str, end = ' ')
+ _sys.stdout.flush()
+
+ term_width = terminal_width()
+ width = term_width - (len(str) + 1)%term_width
+ for i in range(width):
+ progress.wait((i + 1)/width)
+ print('.', end = '')
+ _sys.stdout.flush()
- term_width = terminal_width()
- width = term_width - (len(str) + 1)%term_width
- for i in range(width):
- progress.wait((i + 1)/width)
- print('.', end = '')
+ print()
_sys.stdout.flush()
+ progress.finish()
+ except KeyboardInterrupt:
print()
_sys.stdout.flush()
- progress.finish()
+ progress.cancel()
+ try:
+ progress.finish()
+ except:
+ # Swallow the failure exception
+ pass
+ raise
# --strict option
die_on_warnings(_args.strict)