From: Brian Warner Date: Wed, 18 Apr 2007 19:23:33 +0000 (-0700) Subject: rename bin/fec and bin/unfec to zfec and zunfec X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~65 X-Git-Url: https://git.rkrishnan.org/maximilian?a=commitdiff_plain;h=7c08b5a72fb7d9936f274bf88098086a709e7f8a;p=tahoe-lafs%2Ftahoe-lafs.git rename bin/fec and bin/unfec to zfec and zunfec --- diff --git a/zfec/bin/fec b/zfec/bin/fec deleted file mode 100644 index c4eb9fe2..00000000 --- a/zfec/bin/fec +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python - -# import bindann -# import bindann.monkeypatch.all - -import sys - -import zfec -from zfec.util import argparse -from zfec import filefec -from zfec.util.version import Version -__version__ = Version("1.0.0a1-0-STABLE") - -if '-V' in sys.argv or '--version' in sys.argv: - print "zfec library version: ", zfec.__version__ - print "fec command-line tool version: ", __version__ - sys.exit(0) - -parser = argparse.ArgumentParser(description="Encode a file into a set of share files, a subset of which can later be used to recover the original file.") - -parser.add_argument('inputfile', help='file to encode or "-" for stdin', type=argparse.FileType('rb'), metavar='INF') -parser.add_argument('-d', '--output-dir', help='directory in which share file names will be created (default ".")', default='.', metavar='D') -parser.add_argument('-p', '--prefix', help='prefix for share file names; If omitted, the name of the input file will be used.', metavar='P') -parser.add_argument('-s', '--suffix', help='suffix for share file names (default ".fec")', default='.fec', metavar='S') -parser.add_argument('-m', '--totalshares', help='the total number of share files created (default 16)', default=16, type=int, metavar='M') -parser.add_argument('-k', '--requiredshares', help='the number of share files required to reconstruct (default 4)', default=4, type=int, metavar='K') -parser.add_argument('-f', '--force', help='overwrite any file which already in place an output file (share file)', action='store_true') -parser.add_argument('-v', '--verbose', help='print out messages about progress', action='store_true') -parser.add_argument('-V', '--version', help='print out version number and exit', action='store_true') -args = parser.parse_args() - -if args.prefix is None: - args.prefix = args.inputfile.name - if args.prefix == "": - args.prefix = "" - -if args.totalshares < 3: - print "Invalid parameters, totalshares is required to be >= 3\nPlease see the accompanying documentation." - sys.exit(1) -if args.totalshares > 256: - print "Invalid parameters, totalshares is required to be <= 256\nPlease see the accompanying documentation." - sys.exit(1) -if args.requiredshares < 2: - print "Invalid parameters, requiredshares is required to be >= 2\nPlease see the accompanying documentation." - sys.exit(1) -if args.requiredshares >= args.totalshares: - print "Invalid parameters, requiredshares is required to be < totalshares\nPlease see the accompanying documentation." - sys.exit(1) - -args.inputfile.seek(0, 2) -fsize = args.inputfile.tell() -args.inputfile.seek(0, 0) -ret = filefec.encode_to_files(args.inputfile, fsize, args.output_dir, args.prefix, args.requiredshares, args.totalshares, args.suffix, args.force, args.verbose) - -sys.exit(ret) diff --git a/zfec/bin/unfec b/zfec/bin/unfec deleted file mode 100644 index ab354ee1..00000000 --- a/zfec/bin/unfec +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python - -# import bindann -# import bindann.monkeypatch.all - -import os, sys - -from zfec.util import argparse - -import zfec -from zfec import filefec -from zfec.util.version import Version -__version__ = Version("1.0.0a1-0-STABLE") - -if '-V' in sys.argv or '--version' in sys.argv: - print "zfec library version: ", zfec.__version__ - print "fec command-line tool version: ", __version__ - sys.exit(0) - -parser = argparse.ArgumentParser(description="Decode data from share files.") - -parser.add_argument('-o', '--outputfile', required=True, help='file to write the resulting data to, or "-" for stdout', type=str, metavar='OUTF') -parser.add_argument('sharefiles', nargs='*', help='shares file to read the encoded data from', type=argparse.FileType('rb'), metavar='SHAREFILE') -parser.add_argument('-v', '--verbose', help='print out messages about progress', action='store_true') -parser.add_argument('-f', '--force', help='overwrite any file which already in place of the output file', action='store_true') -parser.add_argument('-V', '--version', help='print out version number and exit', action='store_true') -args = parser.parse_args() - -if len(args.sharefiles) < 2: - print "At least two sharefiles are required." - sys.exit(1) - -if args.force: - outf = open(args.outputfile, 'wb') -else: - try: - outfd = os.open(args.outputfile, os.O_WRONLY|os.O_CREAT|os.O_EXCL) - except OSError: - print "There is already a file named %r -- aborting. Use --force to overwrite." % (args.outputfile,) - sys.exit(2) - outf = os.fdopen(outfd, "wb") - -try: - ret = filefec.decode_from_files(outf, args.sharefiles, args.verbose) -except filefec.InsufficientShareFilesError, e: - print str(e) - sys.exit(3) - -sys.exit(ret) diff --git a/zfec/bin/zfec b/zfec/bin/zfec new file mode 100644 index 00000000..f86cb550 --- /dev/null +++ b/zfec/bin/zfec @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# import bindann +# import bindann.monkeypatch.all + +import sys + +import zfec +from zfec.util import argparse +from zfec import filefec +from zfec.util.version import Version +__version__ = Version("1.0.0a1-0-STABLE") + +if '-V' in sys.argv or '--version' in sys.argv: + print "zfec library version: ", zfec.__version__ + print "zfec command-line tool version: ", __version__ + sys.exit(0) + +parser = argparse.ArgumentParser(description="Encode a file into a set of share files, a subset of which can later be used to recover the original file.") + +parser.add_argument('inputfile', help='file to encode or "-" for stdin', type=argparse.FileType('rb'), metavar='INF') +parser.add_argument('-d', '--output-dir', help='directory in which share file names will be created (default ".")', default='.', metavar='D') +parser.add_argument('-p', '--prefix', help='prefix for share file names; If omitted, the name of the input file will be used.', metavar='P') +parser.add_argument('-s', '--suffix', help='suffix for share file names (default ".fec")', default='.fec', metavar='S') +parser.add_argument('-m', '--totalshares', help='the total number of share files created (default 16)', default=16, type=int, metavar='M') +parser.add_argument('-k', '--requiredshares', help='the number of share files required to reconstruct (default 4)', default=4, type=int, metavar='K') +parser.add_argument('-f', '--force', help='overwrite any file which already in place an output file (share file)', action='store_true') +parser.add_argument('-v', '--verbose', help='print out messages about progress', action='store_true') +parser.add_argument('-V', '--version', help='print out version number and exit', action='store_true') +args = parser.parse_args() + +if args.prefix is None: + args.prefix = args.inputfile.name + if args.prefix == "": + args.prefix = "" + +if args.totalshares < 3: + print "Invalid parameters, totalshares is required to be >= 3\nPlease see the accompanying documentation." + sys.exit(1) +if args.totalshares > 256: + print "Invalid parameters, totalshares is required to be <= 256\nPlease see the accompanying documentation." + sys.exit(1) +if args.requiredshares < 2: + print "Invalid parameters, requiredshares is required to be >= 2\nPlease see the accompanying documentation." + sys.exit(1) +if args.requiredshares >= args.totalshares: + print "Invalid parameters, requiredshares is required to be < totalshares\nPlease see the accompanying documentation." + sys.exit(1) + +args.inputfile.seek(0, 2) +fsize = args.inputfile.tell() +args.inputfile.seek(0, 0) +ret = filefec.encode_to_files(args.inputfile, fsize, args.output_dir, args.prefix, args.requiredshares, args.totalshares, args.suffix, args.force, args.verbose) + +sys.exit(ret) diff --git a/zfec/bin/zunfec b/zfec/bin/zunfec new file mode 100644 index 00000000..e7a93f52 --- /dev/null +++ b/zfec/bin/zunfec @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +# import bindann +# import bindann.monkeypatch.all + +import os, sys + +from zfec.util import argparse + +import zfec +from zfec import filefec +from zfec.util.version import Version +__version__ = Version("1.0.0a1-0-STABLE") + +if '-V' in sys.argv or '--version' in sys.argv: + print "zfec library version: ", zfec.__version__ + print "zunfec command-line tool version: ", __version__ + sys.exit(0) + +parser = argparse.ArgumentParser(description="Decode data from share files.") + +parser.add_argument('-o', '--outputfile', required=True, help='file to write the resulting data to, or "-" for stdout', type=str, metavar='OUTF') +parser.add_argument('sharefiles', nargs='*', help='shares file to read the encoded data from', type=argparse.FileType('rb'), metavar='SHAREFILE') +parser.add_argument('-v', '--verbose', help='print out messages about progress', action='store_true') +parser.add_argument('-f', '--force', help='overwrite any file which already in place of the output file', action='store_true') +parser.add_argument('-V', '--version', help='print out version number and exit', action='store_true') +args = parser.parse_args() + +if len(args.sharefiles) < 2: + print "At least two sharefiles are required." + sys.exit(1) + +if args.force: + outf = open(args.outputfile, 'wb') +else: + try: + outfd = os.open(args.outputfile, os.O_WRONLY|os.O_CREAT|os.O_EXCL) + except OSError: + print "There is already a file named %r -- aborting. Use --force to overwrite." % (args.outputfile,) + sys.exit(2) + outf = os.fdopen(outfd, "wb") + +try: + ret = filefec.decode_from_files(outf, args.sharefiles, args.verbose) +except filefec.InsufficientShareFilesError, e: + print str(e) + sys.exit(3) + +sys.exit(ret)