Ejemplo n.º 1
0
def main(argv):
    o = options.Options(optspec)
    opt, flags, extra = o.parse_bytes(argv[1:])

    if len(extra) != 1:
        o.fatal("exactly one argument expected")

    total = parse_num(extra[0])

    handle_ctrl_c()

    if opt.force or not istty1:
        _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)
Ejemplo n.º 2
0
bup_python="$(dirname "$0")/bup-python" || exit $?
exec "$bup_python" "$0" ${1+"$@"}
"""
# end of bup preamble
import sys
from bup import options, _helpers
from bup.helpers import *

optspec = """
bup random [-S seed] <numbytes>
--
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(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])

if len(extra) != 1:
    o.fatal("exactly one argument expected")

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):
    _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)
Ejemplo n.º 3
0
Archivo: tvfs.py Proyecto: bup/bup
def write_sized_random_content(parent_dir, size, seed):
    verbose = 0
    with open('%s/%d' % (parent_dir, size), 'wb') as f:
        write_random(f.fileno(), size, seed, verbose)
Ejemplo n.º 4
0
def write_sized_random_content(parent_dir, size, seed):
    verbose = 0
    with open('%s/%d' % (parent_dir, size), 'wb') as f:
        write_random(f.fileno(), size, seed, verbose)
Ejemplo n.º 5
0
#!/usr/bin/env python
import sys
from bup import options, _helpers
from bup.helpers import *

optspec = """
bup random [-S seed] <numbytes>
--
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(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])

if len(extra) != 1:
    o.fatal("exactly one argument expected")

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):
    _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)