Пример #1
0
def main(argv, session):
    args = docopt(__doc__, argv=argv)
    src_path = args['<src-identifier>/<src-file>']
    dest_path = args['<dest-identifier>/<dest-file>']

    # First we use ia_copy, prep argv for ia_copy.
    argv.pop(0)
    argv = ['copy'] + argv

    # Call ia_copy.
    r, src_file = ia_copy.main(argv, session, cmd='move')
    dr = src_file.delete(cascade_delete=True)
    if dr.status_code == 204:
        print('success: moved {} to {}'.format(src_path, dest_path))
        sys.exit(0)
    print('error: {}'.format(dr.content))
Пример #2
0
def main(argv, session):
    args = docopt(__doc__, argv=argv)
    src_path = args['<src-identifier>/<src-file>']
    dest_path = args['<dest-identifier>/<dest-file>']

    # Validate args.
    s = Schema({
        str:
        Use(bool),
        '--metadata':
        list,
        '--header':
        Or(None,
           And(Use(get_args_dict), dict),
           error='--header must be formatted as --header="key:value"'),
        '<src-identifier>/<src-file>':
        And(str,
            lambda x: '/' in x,
            error='Source not formatted correctly. See usage example.'),
        '<dest-identifier>/<dest-file>':
        And(str,
            lambda x: '/' in x,
            error='Destiantion not formatted correctly. See usage example.'),
    })
    try:
        args = s.validate(args)
    except SchemaError as exc:
        print('{0}\n{1}'.format(str(exc), printable_usage(__doc__)),
              file=sys.stderr)
        sys.exit(1)

    # Add keep-old-version by default.
    if 'x-archive-keep-old-version' not in args['--header']:
        args['--header']['x-archive-keep-old-version'] = '1'

    # First we use ia_copy, prep argv for ia_copy.
    argv.pop(0)
    argv = ['copy'] + argv

    # Call ia_copy.
    r, src_file = ia_copy.main(argv, session, cmd='move')
    dr = src_file.delete(headers=args['--header'], cascade_delete=True)
    if dr.status_code == 204:
        print('success: moved {} to {}'.format(src_path, dest_path))
        sys.exit(0)
    print('error: {}'.format(dr.content))
Пример #3
0
def main(argv, session):
    args = docopt(__doc__, argv=argv)
    src_path = args['<src-identifier>/<src-file>']
    dest_path = args['<dest-identifier>/<dest-file>']

    headers = get_args_dict(args['--header'])
    # Add keep-old-version by default.
    if 'x-archive-keep-old-version' not in args['--header']:
        headers['x-archive-keep-old-version'] = '1'

    # First we use ia_copy, prep argv for ia_copy.
    argv.pop(0)
    argv = ['copy'] + argv

    # Call ia_copy.
    r, src_file = ia_copy.main(argv, session, cmd='move')
    dr = src_file.delete(headers=headers, cascade_delete=True)
    if dr.status_code == 204:
        print('success: moved {} to {}'.format(src_path, dest_path))
        sys.exit(0)
    print('error: {}'.format(dr.content))
Пример #4
0
def main(argv, session):
    args = docopt(__doc__, argv=argv)
    src_path = args['<src-identifier>/<src-file>']
    dest_path = args['<dest-identifier>/<dest-file>']

    # Validate args.
    s = Schema({
        str: Use(bool),
        '--metadata': list,
        '--header': Or(None, And(Use(get_args_dict), dict),
            error='--header must be formatted as --header="key:value"'),
        '<src-identifier>/<src-file>': And(str, lambda x: '/' in x,
            error='Source not formatted correctly. See usage example.'),
        '<dest-identifier>/<dest-file>': And(str, lambda x: '/' in x,
            error='Destination not formatted correctly. See usage example.'),
    })
    try:
        args = s.validate(args)
    except SchemaError as exc:
        print('{0}\n{1}'.format(str(exc), printable_usage(__doc__)), file=sys.stderr)
        sys.exit(1)

    # Add keep-old-version by default.
    if 'x-archive-keep-old-version' not in args['--header']:
        args['--header']['x-archive-keep-old-version'] = '1'

    # First we use ia_copy, prep argv for ia_copy.
    argv.pop(0)
    argv = ['copy'] + argv

    # Call ia_copy.
    r, src_file = ia_copy.main(argv, session, cmd='move')
    dr = src_file.delete(headers=args['--header'], cascade_delete=True)
    if dr.status_code == 204:
        print('success: moved {} to {}'.format(src_path, dest_path))
        sys.exit(0)
    print('error: {}'.format(dr.content))