src/lsi/lsi.py
def _copy_from(entries, remote_path, local_path, profile):
    """
    Performs an SCP command where the remote_path is the source and the
    local_path is a format string, formatted individually for each host
    being copied from so as to create one or more distinct paths on the
    local system.

    :param entries: A list of entries.
    :type entries: ``list`` of :py:class:`HostEntry`
    :param remote_path: The source path on the remote machine(s).
    :type remote_path: ``str``
    :param local_path: A format string for the path on the local machine.
    :type local_path: ``str``
    :param profile: The profile, holding username/idfile info, etc.
    :type profile: :py:class:`Profile`
    """
    commands = []
    paths = set()
    for entry in entries:
        hname = entry.hostname or entry.public_ip
        _local_path = entry.format_string(local_path)
        if _local_path in paths:
            raise ValueError('Duplicate local paths: one or more paths '
                             'had value {} after formatting.'
                             .format(local_path))
        paths.add(_local_path)
        # If the path references a folder, create the folder if it doesn't
        # exist.
        _folder = os.path.split(_local_path)[0]
        if len(_folder) > 0:
            if not os.path.exists(_folder):
                print('Creating directory ' + _folder)
                os.makedirs(_folder)
        cmd = _build_scp_command(hname, profile.username,
                                 profile.identity_file,
                                 is_get=True,
                                 local_path=_local_path,
                                 remote_path=remote_path)
        print('Command:', cmd)
        commands.append({
            'command': cmd,
            'description': entry.display()
        })
    stream_commands(commands)
    print(green('Finished copying'))
def _copy_from(entries, remote_path, local_path, profile):
    """
    Performs an SCP command where the remote_path is the source and the
    local_path is a format string, formatted individually for each host
    being copied from so as to create one or more distinct paths on the
    local system.

    :param entries: A list of entries.
    :type entries: ``list`` of :py:class:`HostEntry`
    :param remote_path: The source path on the remote machine(s).
    :type remote_path: ``str``
    :param local_path: A format string for the path on the local machine.
    :type local_path: ``str``
    :param profile: The profile, holding username/idfile info, etc.
    :type profile: :py:class:`Profile`
    """
    commands = []
    paths = set()
    for entry in entries:
        hname = entry.hostname or entry.public_ip
        _local_path = entry.format_string(local_path)
        if _local_path in paths:
            raise ValueError('Duplicate local paths: one or more paths '
                             'had value {} after formatting.'
                             .format(local_path))
        paths.add(_local_path)
        # If the path references a folder, create the folder if it doesn't
        # exist.
        _folder = os.path.split(_local_path)[0]
        if len(_folder) > 0:
            if not os.path.exists(_folder):
                print('Creating directory ' + _folder)
                os.makedirs(_folder)
        cmd = _build_scp_command(hname, profile.username,
                                 profile.identity_file,
                                 is_get=True,
                                 local_path=_local_path,
                                 remote_path=remote_path)
        print('Command:', cmd)
        commands.append({
            'command': cmd,
            'description': entry.display()
        })
    stream_commands(commands)
    print(green('Finished copying'))
def _copy_from ( entries , remote_path , local_path , profile ) : commands = [ ] paths = set ( ) for entry in entries : hname = entry . hostname or entry . public_ip _local_path = entry . format_string ( local_path ) if _local_path in paths : raise ValueError ( 'Duplicate local paths: one or more paths ' 'had value {} after formatting.' . format ( local_path ) ) paths . add ( _local_path ) # If the path references a folder, create the folder if it doesn't # exist. _folder = os . path . split ( _local_path ) [ 0 ] if len ( _folder ) > 0 : if not os . path . exists ( _folder ) : print ( 'Creating directory ' + _folder ) os . makedirs ( _folder ) cmd = _build_scp_command ( hname , profile . username , profile . identity_file , is_get = True , local_path = _local_path , remote_path = remote_path ) print ( 'Command:' , cmd ) commands . append ( { 'command' : cmd , 'description' : entry . display ( ) } ) stream_commands ( commands ) print ( green ( 'Finished copying' ) )
Performs an SCP command where the remote_path is the source and the
    local_path is a format string, formatted individually for each host
    being copied from so as to create one or more distinct paths on the
    local system.

    :param entries: A list of entries.
    :type entries: ``list`` of :py:class:`HostEntry`
    :param remote_path: The source path on the remote machine(s).
    :type remote_path: ``str``
    :param local_path: A format string for the path on the local machine.
    :type local_path: ``str``
    :param profile: The profile, holding username/idfile info, etc.
    :type profile: :py:class:`Profile`
Performs an SCP command where the remote_path is the source and the local_path is a format string formatted individually for each host being copied from so as to create one or more distinct paths on the local system .