コード例 #1
0
ファイル: Diff.py プロジェクト: daleathan/Tardis
def parseArgs():
    isatty = os.isatty(sys.stdout.fileno())
    global args

    parser = argparse.ArgumentParser(description='Diff files between current and a Tardis backup, or multiple Tardis versions', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)
    (args, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument("--backup", '-b',   nargs='+', dest='backup', default=[current], help="Backup set(s) to use (Default: %(default)s)")

    parser.add_argument('--color',                  dest='color',   default=isatty, action=Util.StoreBoolean,   help='Use colors')

    diffgroup = parser.add_mutually_exclusive_group()
    diffgroup.add_argument('--unified', '-u',  dest='unified', type=int, default=0, nargs='?', const=3,         help='Generate unified diff')
    diffgroup.add_argument('--context', '-c',  dest='context', type=int, default=5, nargs='?', const=5,         help='Generate context diff')
    diffgroup.add_argument('--ndiff', '-n',    dest='ndiff',   default=False, action='store_true',              help='Generate NDiff style diff')

    parser.add_argument('--reduce-path', '-R',  dest='reduce',  default=0, const=sys.maxint, type=int, nargs='?',   metavar='N',
                        help='Reduce path by N directories.  No value for "smart" reduction')

    parser.add_argument('--recurse', '-r',      dest='recurse', default=False, action=Util.StoreBoolean, help='Recurse into directories.  Default: %(default)s')
    parser.add_argument('--list', '-l',         dest='list', default=False, action=Util.StoreBoolean, help='Only list files that differ.  Do not show diffs.  Default: %(default)s')

    parser.add_argument('--verbose', '-v',  action='count', dest='verbose', default=0, help='Increase the verbosity')
    parser.add_argument('--version',        action='version', version='%(prog)s ' + Tardis.__versionstring__, help='Show the version')
    parser.add_argument('--help', '-h',     action='help')
    parser.add_argument('files',            nargs='+', default=None,                 help="File to diff")

    args = parser.parse_args(remaining)

    #print args
    return args
コード例 #2
0
def processArgs():
    parser = argparse.ArgumentParser(
        description='encrypt or decrypt filenames',
        fromfile_prefix_chars='@',
        add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--encrypt',
                        '-e',
                        dest='encrypt',
                        default=False,
                        action='store_true',
                        help='Encrypt names instead of decrypting')
    parser.add_argument(
        '--quiet',
        '-q',
        dest='quiet',
        default=False,
        action='store_true',
        help="Only print the translation, not the input strings")

    parser.add_argument('--help', '-h', action='help')
    parser.add_argument('names',
                        nargs='*',
                        help="List of pathnames to decrypt")

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #3
0
ファイル: shtardis.py プロジェクト: daleathan/Tardis
def processArgs():
    parser = argparse.ArgumentParser(description='Encrypt the database',
                                     add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--shell',
                        dest='shell',
                        default=getShell(),
                        help='Shell to use.  Default: %(default)s')

    parser.add_argument('--verbose',
                        '-v',
                        action='count',
                        default=0,
                        dest='verbose',
                        help='Increase the verbosity')

    parser.add_argument('--help', '-h', action='help')

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #4
0
def processArgs():
    parser = argparse.ArgumentParser(description='Generate a key backup',
                                     fromfile_prefix_chars='@',
                                     formatter_class=Util.HelpFormatter,
                                     add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser, addcrypt=False)

    parser.add_argument('--output',
                        '-o',
                        default=None,
                        dest='output',
                        required=True,
                        help='Output file')

    parser.add_argument('--verbose',
                        '-v',
                        action='count',
                        default=0,
                        dest='verbose',
                        help='Increase the verbosity')
    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s ' + Tardis.__versionstring__,
                        help='Show the version')
    parser.add_argument('--help', '-h', action='help')

    Util.addGenCompletions(parser)

    return parser.parse_args(remaining)
コード例 #5
0
def processArgs():
    isatty = os.isatty(sys.stdout.fileno())

    parser = argparse.ArgumentParser(description='List Tardis File Versions', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--long', '-l',     dest='long',        default=False, action='store_true',         help='Use long listing format.')
    parser.add_argument('--hidden', '-a',   dest='hidden',      default=False, action='store_true',         help='Show hidden files.')
    parser.add_argument('--reverse', '-r',  dest='reverse',     default=False, action='store_true',         help='Reverse the sort order')
    parser.add_argument('--annotate', '-f', dest='annotate',    default=False, action='store_true',         help='Annotate files based on type.')
    parser.add_argument('--size', '-s',     dest='size',        default=False, action='store_true',         help='Show file sizes')
    parser.add_argument('--human', '-H',    dest='human',       default=False, action='store_true',         help='Format sizes for easy reading')
    parser.add_argument('--dirinfo', '-d',  dest='dirinfo',     default=False, action='store_true',         help='List directories, but not their contents')
    parser.add_argument('--checksums', '-c',dest='cksums',      default=False, action='store_true',         help='Print checksums.')
    parser.add_argument('--chainlen', '-L', dest='chnlen',      default=False, action='store_true',         help='Print chainlengths.')
    parser.add_argument('--inode', '-i',    dest='inode',       default=False, action='store_true',         help='Print inode numbers')
    parser.add_argument('--versions', '-V', dest='versions',    default='change', choices=['none', 'change', 'all', 'last'],   help='Display all, changed, last, or no versions of files.  Default: %(default)s')
    parser.add_argument('--deletions',      dest='deletions',   default=True,  action=Util.StoreBoolean,    help='Show deletions. Default: %(default)s')
    parser.add_argument('--broken',         dest='broken',      default=True,  action=Util.StoreBoolean,    help='Show broken files (missing data). Default: %(default)s')
    parser.add_argument('--oneline', '-O',  dest='oneline',     default=False, action=Util.StoreBoolean,    help='Display versions on one line with the name.  Default: %(default)s')
    parser.add_argument('--times', '-T',    dest='checktimes',  default=False, action=Util.StoreBoolean,    help='Use file time changes when determining diffs. Default: %(default)s')
    parser.add_argument('--metadata', '-M', dest='checkmeta',   default=False, action=Util.StoreBoolean,    help='Use any metadata changes when determining diffs.  Default: %(default)s')
    parser.add_argument('--headers',        dest='headers',     default=True,  action=Util.StoreBoolean,    help='Show headers. Default: %(default)s')
    parser.add_argument('--colors',         dest='colors',      default=isatty, action=Util.StoreBoolean,   help='Use colors. Default: %(default)s')
    parser.add_argument('--columns',        dest='columns',     type=int, default=None ,                    help='Number of columns to display')

    parser.add_argument('--recurse', '-R',  dest='recurse',     default=False, action='store_true',         help='List Directories Recurively')
    parser.add_argument('--maxdepth',       dest='maxdepth',    default=sys.maxint, type=int,               help='Maximum depth to recurse directories')

    parser.add_argument('--glob',           dest='glob',        default=False, action=Util.StoreBoolean,    help='Glob filenames')

    parser.add_argument('--reduce',         dest='reduce',      default=0, type=int, const=sys.maxint, nargs='?',
                        help='Reduce paths by N directories.  No value for smart reduction')
    parser.add_argument('--realpath',       dest='realpath',    default=True, action=Util.StoreBoolean,     help='Use the full path, expanding symlinks to their actual path components')

    rangegrp = parser.add_mutually_exclusive_group()
    rangegrp.add_argument('--range',        dest='range',   default=None,                                   help="Use a range of backupsets.  Format: 'Start:End' Start and End can be names or backupset numbers.  Either value can be left off to indicate the first or last set respectively")
    rangegrp.add_argument('--dates',        dest='daterange', default=None,                                 help="Use a range of dates for the backupsets.  Format: 'Start:End'.  Start and End are names which can be intepreted liberally.  Either can be left off to indicate the first or last set respectively")

    parser.add_argument('--exceptions',     default=False, action=Util.StoreBoolean, dest='exceptions', help="Log full exception data");

    parser.add_argument('--verbose', '-v',  action='count', default=0, dest='verbose',                  help='Increase the verbosity')
    parser.add_argument('--version',        action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',     action='help')

    parser.add_argument('directories', nargs='*', default='.',                                              help='List of directories/files to list')

    Util.addGenCompletions(parser)

    return parser.parse_args(remaining)
コード例 #6
0
ファイル: List.py プロジェクト: koldinger/Tardis
def processArgs():
    isatty = os.isatty(sys.stdout.fileno())

    parser = argparse.ArgumentParser(description='List Tardis File Versions', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--long', '-l',     dest='long',        default=False, action='store_true',         help='Use long listing format.')
    parser.add_argument('--hidden', '-a',   dest='hidden',      default=False, action='store_true',         help='Show hidden files.')
    parser.add_argument('--reverse', '-r',  dest='reverse',     default=False, action='store_true',         help='Reverse the sort order')
    parser.add_argument('--annotate', '-f', dest='annotate',    default=False, action='store_true',         help='Annotate files based on type.')
    parser.add_argument('--size', '-s',     dest='size',        default=False, action='store_true',         help='Show file sizes')
    parser.add_argument('--human', '-H',    dest='human',       default=False, action='store_true',         help='Format sizes for easy reading')
    parser.add_argument('--dirinfo', '-d',  dest='dirinfo',     default=False, action='store_true',         help='List directories, but not their contents')
    parser.add_argument('--checksums', '-c',dest='cksums',      default=False, action='store_true',         help='Print checksums.')
    parser.add_argument('--chainlen', '-L', dest='chnlen',      default=False, action='store_true',         help='Print chainlengths.')
    parser.add_argument('--inode', '-i',    dest='inode',       default=False, action='store_true',         help='Print inode numbers')
    parser.add_argument('--versions', '-V', dest='versions',    default='change', choices=['none', 'change', 'all', 'last'],   help='Display all, changed, last, or no versions of files.  Default: %(default)s')
    parser.add_argument('--deletions',      dest='deletions',   default=True,  action=Util.StoreBoolean,    help='Show deletions. Default: %(default)s')
    parser.add_argument('--broken',         dest='broken',      default=True,  action=Util.StoreBoolean,    help='Show broken files (missing data). Default: %(default)s')
    parser.add_argument('--oneline', '-O',  dest='oneline',     default=False, action=Util.StoreBoolean,    help='Display versions on one line with the name.  Default: %(default)s')
    parser.add_argument('--times', '-T',    dest='checktimes',  default=False, action=Util.StoreBoolean,    help='Use file time changes when determining diffs. Default: %(default)s')
    parser.add_argument('--metadata', '-M', dest='checkmeta',   default=False, action=Util.StoreBoolean,    help='Use any metadata changes when determining diffs.  Default: %(default)s')
    parser.add_argument('--headers',        dest='headers',     default=True,  action=Util.StoreBoolean,    help='Show headers. Default: %(default)s')
    parser.add_argument('--colors',         dest='colors',      default=isatty, action=Util.StoreBoolean,   help='Use colors. Default: %(default)s')
    parser.add_argument('--columns',        dest='columns',     type=int, default=None ,                    help='Number of columns to display')

    parser.add_argument('--recurse', '-R',  dest='recurse',     default=False, action='store_true',         help='List Directories Recurively')
    parser.add_argument('--maxdepth',       dest='maxdepth',    default=sys.maxsize, type=int,               help='Maximum depth to recurse directories')

    parser.add_argument('--glob',           dest='glob',        default=False, action=Util.StoreBoolean,    help='Glob filenames')

    parser.add_argument('--reduce',         dest='reduce',      default=0, type=int, const=sys.maxsize, nargs='?',
                        help='Reduce paths by N directories.  No value for smart reduction')
    parser.add_argument('--realpath',       dest='realpath',    default=True, action=Util.StoreBoolean,     help='Use the full path, expanding symlinks to their actual path components')

    rangegrp = parser.add_mutually_exclusive_group()
    rangegrp.add_argument('--range',        dest='range',   default=None,                                   help="Use a range of backupsets.  Format: 'Start:End' Start and End can be names or backupset numbers.  Either value can be left off to indicate the first or last set respectively")
    rangegrp.add_argument('--dates',        dest='daterange', default=None,                                 help="Use a range of dates for the backupsets.  Format: 'Start:End'.  Start and End are names which can be intepreted liberally.  Either can be left off to indicate the first or last set respectively")

    parser.add_argument('--exceptions',     default=False, action=Util.StoreBoolean, dest='exceptions', help="Log full exception data");

    parser.add_argument('--verbose', '-v',  action='count', default=0, dest='verbose',                  help='Increase the verbosity')
    parser.add_argument('--version',        action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',     action='help')

    parser.add_argument('directories', nargs='*', default='.',                                              help='List of directories/files to list')

    Util.addGenCompletions(parser)

    return parser.parse_args(remaining)
コード例 #7
0
def processArgs():
    parser = argparse.ArgumentParser(description='Encrypt the database',
                                     add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--names',
                        dest='names',
                        action='store_true',
                        default=False,
                        help='Encrypt filenames. Default=%(default)s')
    parser.add_argument('--dirs',
                        dest='dirs',
                        action='store_true',
                        default=False,
                        help='Generate directory hashes.  Default=%(default)s')
    parser.add_argument('--sigs',
                        dest='sigs',
                        action='store_true',
                        default=False,
                        help='Generate signature files.  Default=%(default)s')
    parser.add_argument('--files',
                        dest='files',
                        action='store_true',
                        default=False,
                        help='Encrypt files. Default=%(default)s')
    parser.add_argument('--meta',
                        dest='meta',
                        action='store_true',
                        default=False,
                        help='Generate metadata files.  Default=%(default)s')
    parser.add_argument(
        '--all',
        dest='all',
        action='store_true',
        default=False,
        help='Perform all encyrption steps. Default=%(default)s')

    parser.add_argument('--help', '-h', action='help')

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    if (not (args.names or args.files or args.dirs or args.meta or args.all
             or args.sigs)):
        parser.error(
            "Must specify at least one --names, --files, --dirs, --meta, or --all"
        )
    return args
コード例 #8
0
ファイル: mkKeyBackup.py プロジェクト: koldinger/Tardis
def processArgs():
    parser = argparse.ArgumentParser(description='Generate a key backup', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser, addcrypt=False)

    parser.add_argument('--output', '-o',   default=None, dest='output', required=True,           help='Output file')

    parser.add_argument('--verbose', '-v',  action='count', default=0, dest='verbose',                  help='Increase the verbosity')
    parser.add_argument('--version',        action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',     action='help')

    Util.addGenCompletions(parser)

    return parser.parse_args(remaining)
コード例 #9
0
ファイル: decryptFile.py プロジェクト: daleathan/Tardis
def processArgs():
    parser = argparse.ArgumentParser(description='Decrypt a File', fromfile_prefix_chars='@', add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--output', '-o',       type=argparse.FileType('wb'), default=sys.stdout.buffer, help='output file (default: stdout)')
    parser.add_argument('--from_cache', '-c',   default=False, action='store_true', help='Read a cached file')
    parser.add_argument('--noauth', '-n',       default=False, action='store_true', help='Do not authenticate file info')
    parser.add_argument('--help', '-h',   action='help');
    parser.add_argument('name',           nargs=1, help="Pathnames to decrypt")

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #10
0
ファイル: decryptName.py プロジェクト: koldinger/Tardis
def processArgs():
    parser = argparse.ArgumentParser(description='encrypt or decrypt filenames', fromfile_prefix_chars='@', add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser, addcrypt=False)

    parser.add_argument('--encrypt', '-e', dest='encrypt', default=False, action='store_true', help='Encrypt names instead of decrypting')
    parser.add_argument('--quiet', '-q', dest='quiet', default=False, action='store_true', help="Only print the translation, not the input strings")

    parser.add_argument('--help', '-h',     action='help');
    parser.add_argument('names',          nargs='*', help="List of pathnames to decrypt")

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #11
0
ファイル: checkDB2.py プロジェクト: daleathan/Tardis
def processArgs():
    parser = argparse.ArgumentParser(
        description='Check contents of the DB against the file system',
        fromfile_prefix_chars='@',
        formatter_class=Util.HelpFormatter,
        add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    #parser.add_argument('--output', '-o',   default=None, dest='output', required=True,           help='Output file')

    parser.add_argument('--authenticate',
                        '-a',
                        default='none',
                        nargs='?',
                        const='size',
                        dest='authenticate',
                        choices=['none', 'size', 'all'],
                        help='Authenticate files with incorrect sizes')
    parser.add_argument('--output',
                        '-o',
                        default=None,
                        dest='output',
                        type=argparse.FileType('w'),
                        help='Output data')

    parser.add_argument('--verbose',
                        '-v',
                        action='count',
                        default=0,
                        dest='verbose',
                        help='Increase the verbosity')
    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s ' + Tardis.__versionstring__,
                        help='Show the version')
    parser.add_argument('--help', '-h', action='help')

    Util.addGenCompletions(parser)

    return parser.parse_args(remaining)
コード例 #12
0
ファイル: findPath.py プロジェクト: daleathan/Tardis
def processArgs():
    parser = argparse.ArgumentParser(description='Extract paths for a changeset', fromfile_prefix_chars='@', add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--encrypt', '-e', dest='encrypt', default=False, action='store_true', help='Encrypt names instead of decrypting')
    parser.add_argument('--quiet', '-q', dest='quiet', default=False, action='store_true', help="Only print the translation, not the input strings")
    parser.add_argument('--backup', '-b', dest='backup', default=None, help='Look in specific backupset')

    parser.add_argument('--help', '-h',     action='help');
    parser.add_argument('checksums',          nargs='*', help="List of checksums to extract")

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #13
0
ファイル: Regenerate.py プロジェクト: koldinger/Tardis
def parseArgs():
    parser = argparse.ArgumentParser(description='Recover Backed Up Files', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument("--output", "-o",   dest="output", help="Output file", default=None)
    parser.add_argument("--checksum", "-c", help="Use checksum instead of filename", dest='cksum', action='store_true', default=False)

    bsetgroup = parser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--backup", "-b", help="Backup set to use.  Default: %(default)s", dest='backup', default=Defaults.getDefault('TARDIS_RECENT_SET'))
    bsetgroup.add_argument("--date", "-d",   help="Regenerate as of date", dest='date', default=None)
    bsetgroup.add_argument("--last", "-l",   dest='last', default=False, action='store_true', help="Regenerate the most recent version of the file")

    parser.add_argument('--recurse',        dest='recurse', default=True, action=Util.StoreBoolean, help='Recurse directory trees.  Default: %(default)s')
    parser.add_argument('--recovername',    dest='recovername', default=False, action=Util.StoreBoolean,    help='Recover the name when recovering a checksum.  Default: %(default)s')

    parser.add_argument('--authenticate',    dest='auth', default=True, action=Util.StoreBoolean,    help='Authenticate files while regenerating them.  Default: %(default)s')
    parser.add_argument('--authfail-action', dest='authfailaction', default='rename', choices=['keep', 'rename', 'delete'], help='Action to take for files that do not authenticate.  Default: %(default)s')

    parser.add_argument('--reduce-path', '-R',  dest='reduce',  default=0, const=sys.maxsize, type=int, nargs='?',   metavar='N',
                        help='Reduce path by N directories.  No value for "smart" reduction')
    parser.add_argument('--set-times', dest='settime', default=True, action=Util.StoreBoolean,      help='Set file times to match original file. Default: %(default)s')
    parser.add_argument('--set-perms', dest='setperm', default=True, action=Util.StoreBoolean,      help='Set file owner and permisions to match original file. Default: %(default)s')
    parser.add_argument('--set-attrs', dest='setattrs', default=True, action=Util.StoreBoolean,     help='Set file extended attributes to match original file.  May only set attributes in user space. Default: %(default)s')
    parser.add_argument('--set-acl',   dest='setacl', default=True, action=Util.StoreBoolean,       help='Set file access control lists to match the original file. Default: %(default)s')
    parser.add_argument('--overwrite', '-O', dest='overwrite', default=owModeDefault, const='always', nargs='?',
                        choices=['always', 'newer', 'older', 'never', 'ask'],
                        help='Mode for handling existing files. Default: %(default)s')

    parser.add_argument('--hardlinks',  dest='hardlinks',   default=True,   action=Util.StoreBoolean,   help='Create hardlinks of multiple copies of same inode created. Default: %(default)s')

    parser.add_argument('--exceptions',         default=False, action=Util.StoreBoolean, dest='exceptions', help="Log full exception data");
    parser.add_argument('--verbose', '-v',      action='count', default=0, dest='verbose', help='Increase the verbosity')
    parser.add_argument('--version',            action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',         action='help')

    parser.add_argument('files', nargs='+', default=None, help="List of files to regenerate")

    Util.addGenCompletions(parser)

    return parser.parse_args(remaining)
コード例 #14
0
def processArgs():
    parser = argparse.ArgumentParser(
        description='Encrypt files for a backup database', add_help=False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('--output',
                        '-o',
                        dest='output',
                        required=True,
                        help="Output directory")
    parser.add_argument('--json',
                        '-j',
                        default=None,
                        dest='input',
                        help='JSON input file')
    parser.add_argument('--signature',
                        '-s',
                        default=False,
                        action='store_true',
                        dest='signature',
                        help='Generate signature file')
    parser.add_argument('--compress-data',
                        '-Z',
                        dest='compress',
                        const='zlib',
                        default=None,
                        nargs='?',
                        choices=CompressedBuffer.getCompressors(),
                        help='Compress files')
    parser.add_argument('names',
                        nargs='*',
                        help="List of pathnames to decrypt")
    parser.add_argument('--help', '-h', action='help')

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #15
0
def processArgs():
    parser = argparse.ArgumentParser(description='Mount a FUSE filesystem containing tardis backup data', add_help = False, fromfile_prefix_chars='@')

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument('-o',               dest='mountopts', action='append',help='Standard mount -o options')
    parser.add_argument('-d',               dest='debug', action='store_true', default=False, help='Run in FUSE debug mode')
    parser.add_argument('-f',               dest='foreground', action='store_true', default=False, help='Remain in foreground')

    parser.add_argument('--verbose', '-v',  dest='verbose', action='count', default=0, help="Increase verbosity")
    parser.add_argument('--version',            action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',     action='help')

    parser.add_argument('mountpoint',       nargs=1, help="List of directories to sync")

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #16
0
ファイル: TardisFS.py プロジェクト: koldinger/Tardis
def processArgs():
    parser = argparse.ArgumentParser(description='Mount a FUSE filesystem containing tardis backup data', add_help = False, fromfile_prefix_chars='@')

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser, addcrypt=False)

    parser.add_argument('-o',               dest='mountopts', action='append',help='Standard mount -o options')
    parser.add_argument('-d',               dest='debug', action='store_true', default=False, help='Run in FUSE debug mode')
    parser.add_argument('-f',               dest='foreground', action='store_true', default=False, help='Remain in foreground')

    parser.add_argument('--verbose', '-v',  dest='verbose', action='count', default=0, help="Increase verbosity")
    parser.add_argument('--version',            action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',     action='help')

    parser.add_argument('mountpoint',       nargs=1, help="List of directories to sync")

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    return args
コード例 #17
0
def parseArgs():
    isatty = os.isatty(sys.stdout.fileno())
    global args

    parser = argparse.ArgumentParser(description='Diff files between current and a Tardis backup, or multiple Tardis versions', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)
    (args, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument("--backup", '-b',   nargs='+', dest='backup', default=[current], help="Backup set(s) to use (Default: %(default)s)")

    parser.add_argument('--color',                  dest='color',   default=isatty, action=Util.StoreBoolean,   help='Use colors')

    diffgroup = parser.add_mutually_exclusive_group()
    diffgroup.add_argument('--unified', '-u',  dest='unified', type=int, default=0, nargs='?', const=3,         help='Generate unified diff')
    diffgroup.add_argument('--context', '-c',  dest='context', type=int, default=5, nargs='?', const=5,         help='Generate context diff')
    diffgroup.add_argument('--ndiff', '-n',    dest='ndiff',   default=False, action='store_true',              help='Generate NDiff style diff')

    parser.add_argument('--reduce-path', '-R',  dest='reduce',  default=0, const=sys.maxint, type=int, nargs='?',   metavar='N',
                        help='Reduce path by N directories.  No value for "smart" reduction')

    parser.add_argument('--binary', '-B',   dest='binary', default=False, action=Util.StoreBoolean, help='Print differences in binary files.  Default: %(default)s')
    parser.add_argument('--recurse', '-r',  dest='recurse', default=False, action=Util.StoreBoolean, help='Recurse into directories.  Default: %(default)s')
    parser.add_argument('--list', '-l',     dest='list', default=False, action=Util.StoreBoolean, help='Only list files that differ.  Do not show diffs.  Default: %(default)s')

    parser.add_argument('--exceptions',     default=False, action=Util.StoreBoolean, dest='exceptions', help="Log full exception data");
    parser.add_argument('--verbose', '-v',  action='count', dest='verbose', default=0, help='Increase the verbosity')
    parser.add_argument('--version',        action='version', version='%(prog)s ' + Tardis.__versionstring__, help='Show the version')
    parser.add_argument('--help', '-h',     action='help')

    parser.add_argument('files',            nargs='+', default=None,                 help="File to diff")

    Util.addGenCompletions(parser)
    args = parser.parse_args(remaining)

    #print args
    return args
コード例 #18
0
ファイル: encryptDB.py プロジェクト: koldinger/Tardis
def processArgs():
    parser = argparse.ArgumentParser(description='Encrypt the database', add_help = False)

    (_, remaining) = Config.parseConfigOptions(parser)
    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser, addcrypt=False)

    parser.add_argument('--names',          dest='names',    action='store_true', default=False,       help='Encrypt filenames. Default=%(default)s')
    parser.add_argument('--dirs',           dest='dirs',     action='store_true', default=False,       help='Generate directory hashes.  Default=%(default)s')
    parser.add_argument('--sigs',           dest='sigs',     action='store_true', default=False,       help='Generate signature files.  Default=%(default)s')
    parser.add_argument('--files',          dest='files',    action='store_true', default=False,       help='Encrypt files. Default=%(default)s')
    parser.add_argument('--meta',           dest='meta',     action='store_true', default=False,       help='Generate metadata files.  Default=%(default)s')
    parser.add_argument('--all',            dest='all',      action='store_true', default=False,       help='Perform all encyrption steps. Default=%(default)s')

    parser.add_argument('--help', '-h',     action='help');

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    if (not (args.names or args.files or args.dirs or args.meta or args.all or args.sigs)):
        parser.error("Must specify at least one --names, --files, --dirs, --meta, or --all")
    return args
コード例 #19
0
ファイル: Sonic.py プロジェクト: koldinger/Tardis
def parseArgs():
    global args, minPwStrength

    parser = argparse.ArgumentParser(description='Tardis Sonic Screwdriver Utility Program', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (args, remaining) = Config.parseConfigOptions(parser)
    c = Config.config
    t = args.job

    # Shared parser
    bsetParser = argparse.ArgumentParser(add_help=False)
    bsetgroup = bsetParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--backup", "-b", help="Backup set to use", dest='backup', default=None)
    bsetgroup.add_argument("--date", "-d",   help="Use last backupset before date", dest='date', default=None)

    purgeParser = argparse.ArgumentParser(add_help=False)
    purgeParser.add_argument('--priority',       dest='priority',   default=0, type=int,                   help='Maximum priority backupset to purge')
    purgeParser.add_argument('--incomplete',     dest='incomplete', default=False, action='store_true',    help='Purge only incomplete backup sets')
    bsetgroup = purgeParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--date", "-d",     dest='date',       default=None,                            help="Purge sets before this date")
    bsetgroup.add_argument("--backup", "-b",   dest='backup',     default=None,                            help="Purge sets before this set")

    deleteParser = argparse.ArgumentParser(add_help=False)
    #deleteParser.add_argument("--backup", "-b",  dest='backup',     default=None,                          help="Purge sets before this set")
    deleteParser.add_argument("backups", nargs="*", default=None, help="Backup sets to delete")

    cnfParser = argparse.ArgumentParser(add_help=False)
    cnfParser.add_argument('--confirm',          dest='confirm', action=Util.StoreBoolean, default=True,   help='Confirm deletes and purges')

    keyParser = argparse.ArgumentParser(add_help=False)
    keyGroup = keyParser.add_mutually_exclusive_group(required=True)
    keyGroup.add_argument('--extract',          dest='extract', default=False, action='store_true',         help='Extract keys from database')
    keyGroup.add_argument('--insert',           dest='insert', default=False, action='store_true',          help='Insert keys from database')
    keyParser.add_argument('--delete',          dest='deleteKeys', default=False, action=Util.StoreBoolean, help='Delete keys from server or database')

    filesParser = argparse.ArgumentParser(add_help=False)
    filesParser.add_argument('--long', '-l',    dest='long', default=False, action=Util.StoreBoolean,           help='Long format')
    filesParser.add_argument('--fullpath', '-f',    dest='fullname', default=False, action=Util.StoreBoolean,   help='Print full path name in names')
    filesParser.add_argument('--previous',      dest='previous', default=False, action=Util.StoreBoolean,       help="Include files that first appear in the set, but weren't added here")
    filesParser.add_argument('--dirs',          dest='dirs', default=False, action=Util.StoreBoolean,           help='Include directories in list')
    filesParser.add_argument('--status',        dest='status', default=False, action=Util.StoreBoolean,         help='Include status (new/delta) in list')
    filesParser.add_argument('--human', '-H',   dest='human', default=False, action=Util.StoreBoolean,          help='Print sizes in human readable form')
    filesParser.add_argument('--checksums', '-c', dest='cksums', default=False, action=Util.StoreBoolean,       help='Print checksums')
    filesParser.add_argument('--chainlen', '-L', dest='chnlen', default=False, action=Util.StoreBoolean,        help='Print chainlengths')
    filesParser.add_argument('--inode', '-i',   dest='inode', default=False, action=Util.StoreBoolean,          help='Print inodes')

    common = argparse.ArgumentParser(add_help=False)
    Config.addPasswordOptions(common)
    Config.addCommonOptions(common)

    create = argparse.ArgumentParser(add_help=False)
    create.add_argument('--schema',                 dest='schema',          default=c.get(t, 'Schema'), help='Path to the schema to use (Default: %(default)s)')

    newPassParser = argparse.ArgumentParser(add_help=False)
    newpassgrp = newPassParser.add_argument_group("New Password specification options")
    npwgroup = newpassgrp.add_mutually_exclusive_group()
    npwgroup.add_argument('--newpassword',      dest='newpw', default=None, nargs='?', const=True,  help='Change to this password')
    npwgroup.add_argument('--newpassword-file', dest='newpwf', default=None,                        help='Read new password from file')
    npwgroup.add_argument('--newpassword-prog', dest='newpwp', default=None,                        help='Use the specified command to generate the new password on stdout')

    configKeyParser = argparse.ArgumentParser(add_help=False)
    configKeyParser.add_argument('--key',       dest='configKeys', choices=configKeys, action='append',    help='Configuration key to retrieve.  None for all keys')
    configKeyParser.add_argument('--sys',       dest='sysKeys', default=False, action=Util.StoreBoolean,   help='List System Keys as well as configurable ones')

    configValueParser = argparse.ArgumentParser(add_help=False)
    configValueParser.add_argument('--key',     dest='key', choices=configKeys, required=True,      help='Configuration key to set')
    configValueParser.add_argument('--value',   dest='value', required=True,                        help='Configuration value to access')

    priorityParser = argparse.ArgumentParser(add_help=False)
    priorityParser.add_argument('--priority',   dest='priority', type=int, required=True,           help='New priority backup set')

    renameParser = argparse.ArgumentParser(add_help=False)
    renameParser.add_argument('--name',         dest='newname', required=True,                      help='New name')

    listParser = argparse.ArgumentParser(add_help=False)
    listParser.add_argument('--long', '-l',     dest='longinfo', default=False, action=Util.StoreBoolean,   help='Print long info')
    listParser.add_argument('--minpriority',    dest='minpriority', default=0, type=int,            help='Minimum priority to list')
    listParser.add_argument('--number', '-n',   dest='number', default=sys.maxsize, type=int,       help='Maximum number to show')

    subs = parser.add_subparsers(help="Commands", dest='command')
    subs.add_parser('create',       parents=[common, create],                               help='Create a client database')
    subs.add_parser('setpass',      parents=[common],                                       help='Set a password')
    subs.add_parser('chpass',       parents=[common, newPassParser],                        help='Change a password')
    subs.add_parser('keys',         parents=[common, keyParser],                            help='Move keys to/from server and key file')
    subs.add_parser('list',         parents=[common, listParser],                           help='List backup sets')
    subs.add_parser('files',        parents=[common, filesParser, bsetParser],              help='List new files in a backup set')
    subs.add_parser('info',         parents=[common, bsetParser],                           help='Print info on backup sets')
    subs.add_parser('purge',        parents=[common, purgeParser, cnfParser],               help='Purge old backup sets')
    subs.add_parser('delete',       parents=[common, deleteParser, cnfParser],              help='Delete a backup set')
    subs.add_parser('orphans',      parents=[common],                                       help='Delete orphan files')
    subs.add_parser('getconfig',    parents=[common, configKeyParser],                      help='Get Config Value')
    subs.add_parser('setconfig',    parents=[common, configValueParser],                    help='Set Config Value')
    subs.add_parser('priority',     parents=[common, priorityParser, bsetParser],           help='Set backupset priority')
    subs.add_parser('rename',       parents=[common, renameParser, bsetParser],             help='Rename a backup set')
    subs.add_parser('upgrade',      parents=[common],                                       help='Update the database schema')

    parser.add_argument('--exceptions',         dest='exceptions', default=False, action=Util.StoreBoolean,   help='Log exception messages')
    parser.add_argument('--verbose', '-v',      dest='verbose', default=0, action='count', help='Be verbose.  Add before usb command')
    parser.add_argument('--version',            action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',         action='help')

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)
    if args.command == None:
        parser.print_help()
        sys.exit(0)

    # And load the required strength for new passwords.  NOT specifiable on the command line.
    #minPwStrength = c.getfloat(t, 'PwStrMin')
    return args
コード例 #20
0
def parseArgs():
    global args, minPwStrength

    parser = argparse.ArgumentParser(description='Tardis Sonic Screwdriver Utility Program', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (args, remaining) = Config.parseConfigOptions(parser)
    c = Config.config
    t = args.job

    # Shared parser
    bsetParser = argparse.ArgumentParser(add_help=False)
    bsetgroup = bsetParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--backup", "-b", help="Backup set to use", dest='backup', default=None)
    bsetgroup.add_argument("--date", "-d",   help="Use last backupset before date", dest='date', default=None)

    purgeParser = argparse.ArgumentParser(add_help=False)
    purgeParser.add_argument('--priority',       dest='priority',   default=0, type=int,                   help='Maximum priority backupset to purge')
    purgeParser.add_argument('--incomplete',     dest='incomplete', default=False, action='store_true',    help='Purge only incomplete backup sets')
    bsetgroup = purgeParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--date", "-d",     dest='date',       default=None,                            help="Purge sets before this date")
    bsetgroup.add_argument("--backup", "-b",   dest='backup',     default=None,                            help="Purge sets before this set")

    deleteParser = argparse.ArgumentParser(add_help=False)
    #deleteParser.add_argument("--backup", "-b",  dest='backup',     default=None,                          help="Purge sets before this set")
    deleteParser.add_argument("backups", nargs="*", default=None, help="Backup sets to delete")

    cnfParser = argparse.ArgumentParser(add_help=False)
    cnfParser.add_argument('--confirm',          dest='confirm', action=Util.StoreBoolean, default=True,   help='Confirm deletes and purges')

    keyParser = argparse.ArgumentParser(add_help=False)
    keyGroup = keyParser.add_mutually_exclusive_group(required=True)
    keyGroup.add_argument('--extract',          dest='extract', default=False, action='store_true',         help='Extract keys from database')
    keyGroup.add_argument('--insert',           dest='insert', default=False, action='store_true',          help='Insert keys from database')
    keyParser.add_argument('--delete',          dest='deleteKeys', default=False, action=Util.StoreBoolean, help='Delete keys from server or database')

    common = argparse.ArgumentParser(add_help=False)
    Config.addPasswordOptions(common)
    Config.addCommonOptions(common)

    create = argparse.ArgumentParser(add_help=False)
    create.add_argument('--schema',                 dest='schema',          default=c.get(t, 'Schema'), help='Path to the schema to use (Default: %(default)s)')

    newPassParser = argparse.ArgumentParser(add_help=False)
    newpassgrp = newPassParser.add_argument_group("New Password specification options")
    npwgroup = newpassgrp.add_mutually_exclusive_group()
    npwgroup.add_argument('--newpassword',      dest='newpw', default=None, nargs='?', const=True,  help='Change to this password')
    npwgroup.add_argument('--newpassword-file', dest='newpwf', default=None,                        help='Read new password from file')
    npwgroup.add_argument('--newpassword-prog', dest='newpwp', default=None,                        help='Use the specified command to generate the new password on stdout')

    configKeyParser = argparse.ArgumentParser(add_help=False)
    configKeyParser.add_argument('--key',       dest='configKeys', choices=configKeys, action='append',    help='Configuration key to retrieve.  None for all keys')
    configKeyParser.add_argument('--sys',       dest='sysKeys', default=False, action=Util.StoreBoolean,   help='List System Keys as well as configurable ones')

    configValueParser = argparse.ArgumentParser(add_help=False)
    configValueParser.add_argument('--key',     dest='key', choices=configKeys, required=True,      help='Configuration key to set')
    configValueParser.add_argument('--value',   dest='value', required=True,                        help='Configuration value to access')

    subs = parser.add_subparsers(help="Commands", dest='command')
    subs.add_parser('create',       parents=[common, create], help='Create a client database')
    subs.add_parser('setpass',      parents=[common], help='Set a password')
    subs.add_parser('chpass',       parents=[common, newPassParser],                       help='Change a password')
    subs.add_parser('keys',         parents=[common, keyParser],                           help='Move keys to/from server and key file')
    subs.add_parser('list',         parents=[common],                                      help='List backup sets')
    subs.add_parser('info',         parents=[common, bsetParser],                          help='Print info on backup sets')
    subs.add_parser('purge',        parents=[common, purgeParser, cnfParser],              help='Purge old backup sets')
    subs.add_parser('delete',       parents=[common, deleteParser, cnfParser],             help='Delete a backup set')
    subs.add_parser('orphans',      parents=[common],                                      help='Delete orphan files')
    subs.add_parser('getconfig',    parents=[common, configKeyParser],                     help='Get Config Value')
    subs.add_parser('setconfig',    parents=[common, configValueParser],                   help='Set Config Value')

    parser.add_argument('--verbose', '-v',      dest='verbose', default=0, action='count', help='Be verbose.  Add before usb command')
    parser.add_argument('--version',            action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',         action='help')

    args = parser.parse_args(remaining)

    # And load the required strength for new passwords.  NOT specifiable on the command line.
    #minPwStrength = c.getfloat(t, 'PwStrMin')
    return args
コード例 #21
0
ファイル: Diff.py プロジェクト: koldinger/Tardis
def parseArgs():
    isatty = os.isatty(sys.stdout.fileno())
    global args

    parser = argparse.ArgumentParser(
        description="Diff files between current and a Tardis backup, or multiple Tardis versions",
        fromfile_prefix_chars="@",
        formatter_class=Util.HelpFormatter,
        add_help=False,
    )
    (args, remaining) = Config.parseConfigOptions(parser)

    Config.addCommonOptions(parser)
    Config.addPasswordOptions(parser)

    parser.add_argument(
        "--backup",
        "-b",
        nargs="+",
        dest="backup",
        default=[current],
        help="Backup set(s) to use (Default: %(default)s)",
    )

    parser.add_argument("--color", dest="color", default=isatty, action=Util.StoreBoolean, help="Use colors")

    diffgroup = parser.add_mutually_exclusive_group()
    diffgroup.add_argument(
        "--unified", "-u", dest="unified", type=int, default=0, nargs="?", const=3, help="Generate unified diff"
    )
    diffgroup.add_argument(
        "--context", "-c", dest="context", type=int, default=5, nargs="?", const=5, help="Generate context diff"
    )
    diffgroup.add_argument(
        "--ndiff", "-n", dest="ndiff", default=False, action="store_true", help="Generate NDiff style diff"
    )

    parser.add_argument(
        "--reduce-path",
        "-R",
        dest="reduce",
        default=0,
        const=sys.maxint,
        type=int,
        nargs="?",
        metavar="N",
        help='Reduce path by N directories.  No value for "smart" reduction',
    )

    parser.add_argument(
        "--binary",
        "-B",
        dest="binary",
        default=False,
        action=Util.StoreBoolean,
        help="Print differences in binary files.  Default: %(default)s",
    )
    parser.add_argument(
        "--recurse",
        "-r",
        dest="recurse",
        default=False,
        action=Util.StoreBoolean,
        help="Recurse into directories.  Default: %(default)s",
    )
    parser.add_argument(
        "--list",
        "-l",
        dest="list",
        default=False,
        action=Util.StoreBoolean,
        help="Only list files that differ.  Do not show diffs.  Default: %(default)s",
    )

    parser.add_argument("--verbose", "-v", action="count", dest="verbose", default=0, help="Increase the verbosity")
    parser.add_argument(
        "--version", action="version", version="%(prog)s " + Tardis.__versionstring__, help="Show the version"
    )
    parser.add_argument("--help", "-h", action="help")
    parser.add_argument("files", nargs="+", default=None, help="File to diff")

    args = parser.parse_args(remaining)

    # print args
    return args
コード例 #22
0
ファイル: Sonic.py プロジェクト: daleathan/Tardis
def parseArgs():
    global args, minPwStrength

    parser = argparse.ArgumentParser(
        description="Tardis Sonic Screwdriver Utility Program",
        fromfile_prefix_chars="@",
        formatter_class=Util.HelpFormatter,
        add_help=False,
    )

    (args, remaining) = Config.parseConfigOptions(parser)
    c = Config.config
    t = args.job

    # Shared parser
    bsetParser = argparse.ArgumentParser(add_help=False)
    bsetgroup = bsetParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--backup", "-b", help="Backup set to use", dest="backup", default=None)
    bsetgroup.add_argument("--date", "-d", help="Use last backupset before date", dest="date", default=None)

    purgeParser = argparse.ArgumentParser(add_help=False)
    purgeParser.add_argument(
        "--priority", dest="priority", default=0, type=int, help="Maximum priority backupset to purge"
    )
    purgeParser.add_argument(
        "--incomplete", dest="incomplete", default=False, action="store_true", help="Purge only incomplete backup sets"
    )
    bsetgroup = purgeParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--date", "-d", dest="date", default=None, help="Purge sets before this date")
    bsetgroup.add_argument("--backup", "-b", dest="backup", default=None, help="Purge sets before this set")

    deleteParser = argparse.ArgumentParser(add_help=False)
    # deleteParser.add_argument("--backup", "-b",  dest='backup',     default=None,                          help="Purge sets before this set")
    deleteParser.add_argument("backups", nargs="*", default=None, help="Backup sets to delete")

    cnfParser = argparse.ArgumentParser(add_help=False)
    cnfParser.add_argument(
        "--confirm", dest="confirm", action=Util.StoreBoolean, default=True, help="Confirm deletes and purges"
    )

    keyParser = argparse.ArgumentParser(add_help=False)
    keyGroup = keyParser.add_mutually_exclusive_group(required=True)
    keyGroup.add_argument(
        "--extract", dest="extract", default=False, action="store_true", help="Extract keys from database"
    )
    keyGroup.add_argument(
        "--insert", dest="insert", default=False, action="store_true", help="Insert keys from database"
    )
    keyParser.add_argument(
        "--delete",
        dest="deleteKeys",
        default=False,
        action=Util.StoreBoolean,
        help="Delete keys from server or database",
    )

    common = argparse.ArgumentParser(add_help=False)
    Config.addPasswordOptions(common)
    Config.addCommonOptions(common)

    create = argparse.ArgumentParser(add_help=False)
    create.add_argument(
        "--schema", dest="schema", default=c.get(t, "Schema"), help="Path to the schema to use (Default: %(default)s)"
    )

    newPassParser = argparse.ArgumentParser(add_help=False)
    newpassgrp = newPassParser.add_argument_group("New Password specification options")
    npwgroup = newpassgrp.add_mutually_exclusive_group()
    npwgroup.add_argument(
        "--newpassword", dest="newpw", default=None, nargs="?", const=True, help="Change to this password"
    )
    npwgroup.add_argument("--newpassword-file", dest="newpwf", default=None, help="Read new password from file")
    npwgroup.add_argument(
        "--newpassword-prog",
        dest="newpwp",
        default=None,
        help="Use the specified command to generate the new password on stdout",
    )

    configKeyParser = argparse.ArgumentParser(add_help=False)
    configKeyParser.add_argument(
        "--key",
        dest="configKeys",
        choices=configKeys,
        action="append",
        help="Configuration key to retrieve.  None for all keys",
    )
    configKeyParser.add_argument(
        "--sys",
        dest="sysKeys",
        default=False,
        action=Util.StoreBoolean,
        help="List System Keys as well as configurable ones",
    )

    configValueParser = argparse.ArgumentParser(add_help=False)
    configValueParser.add_argument(
        "--key", dest="key", choices=configKeys, required=True, help="Configuration key to set"
    )
    configValueParser.add_argument("--value", dest="value", required=True, help="Configuration value to access")

    subs = parser.add_subparsers(help="Commands", dest="command")
    subs.add_parser("create", parents=[common, create], help="Create a client database")
    subs.add_parser("setpass", parents=[common], help="Set a password")
    subs.add_parser("chpass", parents=[common, newPassParser], help="Change a password")
    subs.add_parser("keys", parents=[common, keyParser], help="Move keys to/from server and key file")
    subs.add_parser("list", parents=[common], help="List backup sets")
    subs.add_parser("info", parents=[common, bsetParser], help="Print info on backup sets")
    subs.add_parser("purge", parents=[common, purgeParser, cnfParser], help="Purge old backup sets")
    subs.add_parser("delete", parents=[common, deleteParser, cnfParser], help="Delete a backup set")
    subs.add_parser("orphans", parents=[common], help="Delete orphan files")
    subs.add_parser("getconfig", parents=[common, configKeyParser], help="Get Config Value")
    subs.add_parser("setconfig", parents=[common, configValueParser], help="Set Config Value")

    # parser.add_argument('--verbose', '-v',      dest='verbose', action='count',                     help='Be verbose')
    parser.add_argument(
        "--version", action="version", version="%(prog)s " + Tardis.__versionstring__, help="Show the version"
    )
    parser.add_argument("--help", "-h", action="help")

    args = parser.parse_args(remaining)

    # And load the required strength for new passwords.  NOT specifiable on the command line.
    # minPwStrength = c.getfloat(t, 'PwStrMin')
    return args
コード例 #23
0
def parseArgs():
    global args, minPwStrength

    parser = argparse.ArgumentParser(description='Tardis Sonic Screwdriver Utility Program', fromfile_prefix_chars='@', formatter_class=Util.HelpFormatter, add_help=False)

    (args, remaining) = Config.parseConfigOptions(parser)
    c = Config.config
    t = args.job

    # Shared parser
    bsetParser = argparse.ArgumentParser(add_help=False)
    bsetgroup = bsetParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--backup", "-b", help="Backup set to use", dest='backup', default=None)
    bsetgroup.add_argument("--date", "-d",   help="Use last backupset before date", dest='date', default=None)

    purgeParser = argparse.ArgumentParser(add_help=False)
    purgeParser.add_argument('--priority',       dest='priority',   default=0, type=int,                   help='Maximum priority backupset to purge')
    purgeParser.add_argument('--incomplete',     dest='incomplete', default=False, action='store_true',    help='Purge only incomplete backup sets')
    bsetgroup = purgeParser.add_mutually_exclusive_group()
    bsetgroup.add_argument("--date", "-d",     dest='date',       default=None,                            help="Purge sets before this date")
    bsetgroup.add_argument("--backup", "-b",   dest='backup',     default=None,                            help="Purge sets before this set")

    deleteParser = argparse.ArgumentParser(add_help=False)
    #deleteParser.add_argument("--backup", "-b",  dest='backup',     default=None,                          help="Purge sets before this set")
    deleteParser.add_argument("backups", nargs="*", default=None, help="Backup sets to delete")

    cnfParser = argparse.ArgumentParser(add_help=False)
    cnfParser.add_argument('--confirm',          dest='confirm', action=Util.StoreBoolean, default=True,   help='Confirm deletes and purges')

    keyParser = argparse.ArgumentParser(add_help=False)
    keyGroup = keyParser.add_mutually_exclusive_group(required=True)
    keyGroup.add_argument('--extract',          dest='extract', default=False, action='store_true',         help='Extract keys from database')
    keyGroup.add_argument('--insert',           dest='insert', default=False, action='store_true',          help='Insert keys from database')
    keyParser.add_argument('--delete',          dest='deleteKeys', default=False, action=Util.StoreBoolean, help='Delete keys from server or database')

    filesParser = argparse.ArgumentParser(add_help=False)
    filesParser.add_argument('--long', '-l',    dest='long', default=False, action=Util.StoreBoolean,           help='Long format')
    filesParser.add_argument('--fullpath', '-f',    dest='fullname', default=False, action=Util.StoreBoolean,   help='Print full path name in names')
    filesParser.add_argument('--previous',      dest='previous', default=False, action=Util.StoreBoolean,       help="Include files that first appear in the set, but weren't added here")
    filesParser.add_argument('--dirs',          dest='dirs', default=False, action=Util.StoreBoolean,           help='Include directories in list')
    filesParser.add_argument('--status',        dest='status', default=False, action=Util.StoreBoolean,         help='Include status (new/delta) in list')
    filesParser.add_argument('--human', '-H',   dest='human', default=False, action=Util.StoreBoolean,          help='Print sizes in human readable form')
    filesParser.add_argument('--checksums', '-c', dest='cksums', default=False, action=Util.StoreBoolean,       help='Print checksums')
    filesParser.add_argument('--chainlen', '-L', dest='chnlen', default=False, action=Util.StoreBoolean,        help='Print chainlengths')
    filesParser.add_argument('--inode', '-i',   dest='inode', default=False, action=Util.StoreBoolean,          help='Print inodes')

    common = argparse.ArgumentParser(add_help=False)
    Config.addPasswordOptions(common)
    Config.addCommonOptions(common)

    create = argparse.ArgumentParser(add_help=False)
    create.add_argument('--schema',                 dest='schema',          default=c.get(t, 'Schema'), help='Path to the schema to use (Default: %(default)s)')

    newPassParser = argparse.ArgumentParser(add_help=False)
    newpassgrp = newPassParser.add_argument_group("New Password specification options")
    npwgroup = newpassgrp.add_mutually_exclusive_group()
    npwgroup.add_argument('--newpassword',      dest='newpw', default=None, nargs='?', const=True,  help='Change to this password')
    npwgroup.add_argument('--newpassword-file', dest='newpwf', default=None,                        help='Read new password from file')
    npwgroup.add_argument('--newpassword-prog', dest='newpwp', default=None,                        help='Use the specified command to generate the new password on stdout')

    configKeyParser = argparse.ArgumentParser(add_help=False)
    configKeyParser.add_argument('--key',       dest='configKeys', choices=configKeys, action='append',    help='Configuration key to retrieve.  None for all keys')
    configKeyParser.add_argument('--sys',       dest='sysKeys', default=False, action=Util.StoreBoolean,   help='List System Keys as well as configurable ones')

    configValueParser = argparse.ArgumentParser(add_help=False)
    configValueParser.add_argument('--key',     dest='key', choices=configKeys, required=True,      help='Configuration key to set')
    configValueParser.add_argument('--value',   dest='value', required=True,                        help='Configuration value to access')

    priorityParser = argparse.ArgumentParser(add_help=False)
    priorityParser.add_argument('--priority',   dest='priority', type=int, required=True,           help='New priority backup set')

    renameParser = argparse.ArgumentParser(add_help=False)
    renameParser.add_argument('--name',         dest='newname', required=True,                      help='New name')

    listParser = argparse.ArgumentParser(add_help=False)
    listParser.add_argument('--long', '-l',     dest='longinfo', default=False, action=Util.StoreBoolean,   help='Print long info')

    subs = parser.add_subparsers(help="Commands", dest='command')
    subs.add_parser('create',       parents=[common, create],                               help='Create a client database')
    subs.add_parser('setpass',      parents=[common],                                       help='Set a password')
    subs.add_parser('chpass',       parents=[common, newPassParser],                        help='Change a password')
    subs.add_parser('keys',         parents=[common, keyParser],                            help='Move keys to/from server and key file')
    subs.add_parser('list',         parents=[common, listParser],                           help='List backup sets')
    subs.add_parser('files',        parents=[common, filesParser, bsetParser],              help='List new files in a backup set')
    subs.add_parser('info',         parents=[common, bsetParser],                           help='Print info on backup sets')
    subs.add_parser('purge',        parents=[common, purgeParser, cnfParser],               help='Purge old backup sets')
    subs.add_parser('delete',       parents=[common, deleteParser, cnfParser],              help='Delete a backup set')
    subs.add_parser('orphans',      parents=[common],                                       help='Delete orphan files')
    subs.add_parser('getconfig',    parents=[common, configKeyParser],                      help='Get Config Value')
    subs.add_parser('setconfig',    parents=[common, configValueParser],                    help='Set Config Value')
    subs.add_parser('priority',     parents=[common, priorityParser, bsetParser],           help='Set backupset priority')
    subs.add_parser('rename',       parents=[common, renameParser, bsetParser],             help='Rename a backup set')
    subs.add_parser('upgrade',      parents=[common],                                       help='Update the database schema')

    parser.add_argument('--exceptions',         dest='exceptions', default=False, action=Util.StoreBoolean,   help='Log exception messages')
    parser.add_argument('--verbose', '-v',      dest='verbose', default=0, action='count', help='Be verbose.  Add before usb command')
    parser.add_argument('--version',            action='version', version='%(prog)s ' + Tardis.__versionstring__,    help='Show the version')
    parser.add_argument('--help', '-h',         action='help')

    Util.addGenCompletions(parser)

    args = parser.parse_args(remaining)

    # And load the required strength for new passwords.  NOT specifiable on the command line.
    #minPwStrength = c.getfloat(t, 'PwStrMin')
    return args