swiftly/cli/put.py
def cli_put_directory_structure(context, path):
    """
    Performs PUTs rooted at the path using a directory structure
    pointed to by context.input\_.

    See :py:mod:`swiftly.cli.put` for context usage information.

    See :py:class:`CLIPut` for more information.
    """
    if not context.input_:
        raise ReturnCode(
            'called cli_put_directory_structure without context.input_ set')
    if not os.path.isdir(context.input_):
        raise ReturnCode(
            '%r is not a directory' % context.input_)
    if not path:
        raise ReturnCode(
            'uploading a directory structure requires at least a container '
            'name')
    new_context = context.copy()
    new_context.input_ = None
    container = path.split('/', 1)[0]
    cli_put_container(new_context, container)
    ilen = len(context.input_)
    if not context.input_.endswith(os.sep):
        ilen += 1
    conc = Concurrency(context.concurrency)
    for (dirpath, dirnames, filenames) in os.walk(context.input_):
        if not dirnames and not filenames:
            new_context = context.copy()
            new_context.headers = dict(context.headers)
            new_context.headers['content-type'] = 'text/directory'
            new_context.headers['x-object-meta-mtime'] = \
                '%f' % os.path.getmtime(context.input_)
            new_context.input_ = None
            new_context.empty = True
            new_path = path
            if path[-1] != '/':
                new_path += '/'
            new_path += dirpath[ilen:]
            for (exc_type, exc_value, exc_tb, result) in \
                    six.itervalues(conc.get_results()):
                if exc_value:
                    conc.join()
                    raise exc_value
            conc.spawn(new_path, cli_put_object, new_context, new_path)
        else:
            for fname in filenames:
                new_context = context.copy()
                new_context.input_ = os.path.join(dirpath, fname)
                new_path = path
                if path[-1] != '/':
                    new_path += '/'
                if dirpath[ilen:]:
                    new_path += dirpath[ilen:] + '/'
                new_path += fname
                for (exc_type, exc_value, exc_tb, result) in \
                        six.itervalues(conc.get_results()):
                    if exc_value:
                        conc.join()
                        raise exc_value
                conc.spawn(new_path, cli_put_object, new_context, new_path)
    conc.join()
    for (exc_type, exc_value, exc_tb, result) in \
            six.itervalues(conc.get_results()):
        if exc_value:
            raise exc_value
def cli_put_directory_structure(context, path):
    """
    Performs PUTs rooted at the path using a directory structure
    pointed to by context.input\_.

    See :py:mod:`swiftly.cli.put` for context usage information.

    See :py:class:`CLIPut` for more information.
    """
    if not context.input_:
        raise ReturnCode(
            'called cli_put_directory_structure without context.input_ set')
    if not os.path.isdir(context.input_):
        raise ReturnCode(
            '%r is not a directory' % context.input_)
    if not path:
        raise ReturnCode(
            'uploading a directory structure requires at least a container '
            'name')
    new_context = context.copy()
    new_context.input_ = None
    container = path.split('/', 1)[0]
    cli_put_container(new_context, container)
    ilen = len(context.input_)
    if not context.input_.endswith(os.sep):
        ilen += 1
    conc = Concurrency(context.concurrency)
    for (dirpath, dirnames, filenames) in os.walk(context.input_):
        if not dirnames and not filenames:
            new_context = context.copy()
            new_context.headers = dict(context.headers)
            new_context.headers['content-type'] = 'text/directory'
            new_context.headers['x-object-meta-mtime'] = \
                '%f' % os.path.getmtime(context.input_)
            new_context.input_ = None
            new_context.empty = True
            new_path = path
            if path[-1] != '/':
                new_path += '/'
            new_path += dirpath[ilen:]
            for (exc_type, exc_value, exc_tb, result) in \
                    six.itervalues(conc.get_results()):
                if exc_value:
                    conc.join()
                    raise exc_value
            conc.spawn(new_path, cli_put_object, new_context, new_path)
        else:
            for fname in filenames:
                new_context = context.copy()
                new_context.input_ = os.path.join(dirpath, fname)
                new_path = path
                if path[-1] != '/':
                    new_path += '/'
                if dirpath[ilen:]:
                    new_path += dirpath[ilen:] + '/'
                new_path += fname
                for (exc_type, exc_value, exc_tb, result) in \
                        six.itervalues(conc.get_results()):
                    if exc_value:
                        conc.join()
                        raise exc_value
                conc.spawn(new_path, cli_put_object, new_context, new_path)
    conc.join()
    for (exc_type, exc_value, exc_tb, result) in \
            six.itervalues(conc.get_results()):
        if exc_value:
            raise exc_value
def cli_put_directory_structure ( context , path ) : if not context . input_ : raise ReturnCode ( 'called cli_put_directory_structure without context.input_ set' ) if not os . path . isdir ( context . input_ ) : raise ReturnCode ( '%r is not a directory' % context . input_ ) if not path : raise ReturnCode ( 'uploading a directory structure requires at least a container ' 'name' ) new_context = context . copy ( ) new_context . input_ = None container = path . split ( '/' , 1 ) [ 0 ] cli_put_container ( new_context , container ) ilen = len ( context . input_ ) if not context . input_ . endswith ( os . sep ) : ilen += 1 conc = Concurrency ( context . concurrency ) for ( dirpath , dirnames , filenames ) in os . walk ( context . input_ ) : if not dirnames and not filenames : new_context = context . copy ( ) new_context . headers = dict ( context . headers ) new_context . headers [ 'content-type' ] = 'text/directory' new_context . headers [ 'x-object-meta-mtime' ] = '%f' % os . path . getmtime ( context . input_ ) new_context . input_ = None new_context . empty = True new_path = path if path [ - 1 ] != '/' : new_path += '/' new_path += dirpath [ ilen : ] for ( exc_type , exc_value , exc_tb , result ) in six . itervalues ( conc . get_results ( ) ) : if exc_value : conc . join ( ) raise exc_value conc . spawn ( new_path , cli_put_object , new_context , new_path ) else : for fname in filenames : new_context = context . copy ( ) new_context . input_ = os . path . join ( dirpath , fname ) new_path = path if path [ - 1 ] != '/' : new_path += '/' if dirpath [ ilen : ] : new_path += dirpath [ ilen : ] + '/' new_path += fname for ( exc_type , exc_value , exc_tb , result ) in six . itervalues ( conc . get_results ( ) ) : if exc_value : conc . join ( ) raise exc_value conc . spawn ( new_path , cli_put_object , new_context , new_path ) conc . join ( ) for ( exc_type , exc_value , exc_tb , result ) in six . itervalues ( conc . get_results ( ) ) : if exc_value : raise exc_value
Performs PUTs rooted at the path using a directory structure
    pointed to by context.input\_.

    See :py:mod:`swiftly.cli.put` for context usage information.

    See :py:class:`CLIPut` for more information.
Performs PUTs rooted at the path using a directory structure pointed to by context . input \ _ .