Пример #1
0
def copy(source, destination=None, **kwds):
  '''copy source to (possibly) remote destination

Execute a copy, and return the copier. Use 'kill' to kill the copier, and 
'pid' to get the process id for the copier.

Inputs:
    source      -- path string of source 'file'
    destination -- path string for destination target
  '''
  #XXX: options, background, stdin can be set w/ kwds (also name, launcher)
  if destination is None: destination = os.getcwd()
  from LauncherSCP import LauncherSCP
  opt = kwds.pop('options', None)
  kwds['background'] = kwds.pop('bg', False) # ignores 'background'
  copier = LauncherSCP(**kwds)
  if ':' in source or ':' in destination:
    if opt is None: opt = '-q -r'
    copier(options=opt, source=source, destination=destination)
  else:
    if opt is None: opt = '-r'
    copier(launcher='cp', options=opt, source=source, destination=destination)
  logging.info('executing {%s}', copier.message)
  copier.launch()
  copier.kill()
  return copier
Пример #2
0
def copy(source, destination=None, **kwds):
    '''copy source to (possibly) remote destination

Execute a copy, and return the copier. Use 'kill' to kill the copier, and 
'pid' to get the process id for the copier.

Inputs:
    source      -- path string of source 'file'
    destination -- path string for destination target
  '''
    #XXX: options, background, stdin can be set w/ kwds (also name, launcher)
    if destination is None: destination = os.getcwd()
    from LauncherSCP import LauncherSCP
    opt = kwds.pop('options', None)
    kwds['background'] = kwds.pop('bg', False)  # ignores 'background'
    copier = LauncherSCP(**kwds)
    if ':' in source or ':' in destination:
        if opt is None: opt = '-q -r'
        copier(options=opt, source=source, destination=destination)
    else:
        if opt is None: opt = '-r'
        copier(launcher='cp',
               options=opt,
               source=source,
               destination=destination)
    logging.info('executing {%s}', copier.message)
    copier.launch()
    copier.kill()
    return copier