]> arthur.barton.de Git - bup.git/blobdiff - cmd/random-cmd.py
Skip dependent tests if we can't load loop or fuse
[bup.git] / cmd / random-cmd.py
index 34035d57cda3ad7160f9af93ea23d2dae66f0c20..4be366063c18c2792baab50fc55606d03703c795 100755 (executable)
@@ -1,15 +1,16 @@
 #!/usr/bin/env python
-import sys, mmap
-from bup import options, _hashsplit
+import sys
+from bup import options, _helpers
 from bup.helpers import *
 
 optspec = """
 bup random [-S seed] <numbytes>
 --
-S,seed=   optional random number seed (default 1)
+S,seed=   optional random number seed [1]
 f,force   print random data to stdout even if it's a tty
+v,verbose print byte counter to stderr
 """
-o = options.Options('bup random', optspec)
+o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 
 if len(extra) != 1:
@@ -17,9 +18,12 @@ if len(extra) != 1:
 
 total = parse_num(extra[0])
 
+handle_ctrl_c()
+
 if opt.force or (not os.isatty(1) and
                  not atoi(os.environ.get('BUP_FORCE_TTY')) & 1):
-    _hashsplit.write_random(sys.stdout.fileno(), total, opt.seed or 0)
+    _helpers.write_random(sys.stdout.fileno(), total, opt.seed,
+                          opt.verbose and 1 or 0)
 else:
     log('error: not writing binary data to a terminal. Use -f to force.\n')
     sys.exit(1)