Beispiel #1
0
def main():
    args = shared.init()

    parser = argparse.ArgumentParser()
    parser.add_argument('-n',
                        '--no-filenames',
                        action='store_true',
                        help='do not print filenames next to MD5 digests')
    parser.add_argument('-r',
                        '--recursive',
                        action='store_true',
                        help='recurse into directories and subdirectories')
    parser.add_argument('nodes', nargs='+', metavar='NODE')
    args = parser.parse_args(namespace=args)

    for node_id in args.nodes:
        args.node = node_id
        shared.resolve_remote_path_args(args, ['node'])
        node = shared.cache.get_node(args.node)
        try:
            print_md5s(node,
                       recursive=args.recursive,
                       no_filenames=args.no_filenames)
        except IsADirectoryError:
            shared.logger.error('%s is a directory.' % node_id)
        except LookupError:
            shared.logger.error('%s has no associated MD5 digest.' % node_id)
Beispiel #2
0
def main():
    shared.acd_cli.db.NodeCache = NodeCache
    args = shared.init()

    parser = argparse.ArgumentParser()
    parser.add_argument('--include-trash', '-t', action='store_true')
    parser.add_argument('--dir-only', '-d', action='store_true')
    parser.add_argument('--max-depth', '-L', type=int)
    parser.add_argument('--no-human-readable',
                        action='store_true',
                        help="""show sizes in plain byte counts""")
    parser.add_argument(
        '--numfmt',
        action='store_true',
        help="""use numfmt(1) styled sizes (at most one decimal place)""")
    parser.add_argument(
        '--si',
        '--base10',
        action='store_true',
        help="""show sizes in SI (base 10) units; defaul is IEC (base 2)""")
    parser.add_argument(
        '-P',
        '--progress',
        action='store_true',
        help="""show progress information when gathering information""")
    parser.add_argument('node',
                        nargs='?',
                        default='/',
                        help='root directory for the tree')
    args = parser.parse_args(namespace=args)

    shared.resolve_remote_path_args(args, ['node'])

    node = shared.cache.get_node(args.node)
    kwargs = {
        'trash': args.include_trash,
        'dir_only': args.dir_only,
        'max_depth': args.max_depth,
        'human_readable': not args.no_human_readable,
        'numfmt': args.numfmt,
        'base10': args.si,
        'progress': args.progress,
    }
    tree_size, lines = shared.cache.trees_format(node, **kwargs)

    if args.progress:
        sys.stderr.write('\n')
    print('\n'.join(lines))
Beispiel #3
0
def main():
    args = shared.init()

    parser = argparse.ArgumentParser()
    parser.add_argument("-n", "--no-filenames", action="store_true", help="do not print filenames next to MD5 digests")
    parser.add_argument("-r", "--recursive", action="store_true", help="recurse into directories and subdirectories")
    parser.add_argument("nodes", nargs="+", metavar="NODE")
    args = parser.parse_args(namespace=args)

    for node_id in args.nodes:
        args.node = node_id
        shared.resolve_remote_path_args(args, ["node"])
        node = shared.cache.get_node(args.node)
        try:
            print_md5s(node, recursive=args.recursive, no_filenames=args.no_filenames)
        except IsADirectoryError:
            shared.logger.error("%s is a directory." % node_id)
        except LookupError:
            shared.logger.error("%s has no associated MD5 digest." % node_id)
Beispiel #4
0
def main():
    shared.acd_cli.db.NodeCache = NodeCache
    args = shared.init()

    parser = argparse.ArgumentParser()
    parser.add_argument('--include-trash', '-t', action='store_true')
    parser.add_argument('--dir-only', '-d', action='store_true')
    parser.add_argument('--max-depth', '-L', type=int)
    parser.add_argument('--no-human-readable', action='store_true',
                        help="""show sizes in plain byte counts""")
    parser.add_argument('--numfmt', action='store_true',
                        help="""use numfmt(1) styled sizes (at most one decimal place)""")
    parser.add_argument('--si', '--base10', action='store_true',
                        help="""show sizes in SI (base 10) units; defaul is IEC (base 2)""")
    parser.add_argument('-P', '--progress', action='store_true',
                        help="""show progress information when gathering information""")
    parser.add_argument('node', nargs='?', default='/', help='root directory for the tree')
    args = parser.parse_args(namespace=args)

    shared.resolve_remote_path_args(args, ['node'])

    node = shared.cache.get_node(args.node)
    kwargs = {
        'trash': args.include_trash,
        'dir_only': args.dir_only,
        'max_depth': args.max_depth,
        'human_readable': not args.no_human_readable,
        'numfmt': args.numfmt,
        'base10': args.si,
        'progress': args.progress,
    }
    tree_size, lines = shared.cache.trees_format(node, **kwargs)

    if args.progress:
        sys.stderr.write('\n')
    print('\n'.join(lines))