From 2706525fc0f2745083cb3e49e414efeb2e56e59a Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sat, 11 Dec 2010 18:13:58 -0800 Subject: [PATCH] redo-stamp: print a helpful message if stdin is a tty. Otherwise your redo process might just freeze in the middle, and you'll wonder why. --- redo-stamp.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/redo-stamp.py b/redo-stamp.py index 0ae6303..a9b9009 100755 --- a/redo-stamp.py +++ b/redo-stamp.py @@ -7,6 +7,10 @@ if len(sys.argv) > 1: err('%s: no arguments expected.\n' % sys.argv[0]) sys.exit(1) +if os.isatty(0): + err('%s: you must provide the data to stamp on stdin\n' % sys.argv[0]) + sys.exit(1) + # hashlib is only available in python 2.5 or higher, but the 'sha' module # produces a DeprecationWarning in python 2.6 or higher. We want to support # python 2.4 and above without any stupid warnings, so let's try using hashlib @@ -24,8 +28,12 @@ while 1: sh.update(b) if not b: break -f = state.File(name=vars.TARGET) csum = sh.hexdigest() + +if not vars.TARGET: + sys.exit(0) + +f = state.File(name=vars.TARGET) changed = (csum != f.csum) debug2('%s: old = %s\n' % (f.name, f.csum)) debug2('%s: sum = %s (%s)\n' % (f.name, csum,