Пример #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(filename, rhost, dest):
  '''copy 'file' object to target destination

Inputs:
    filename    -- path string of source 'file'
    rhost       -- hostname of destination target
    destination -- path string for destination target
  '''
  from LauncherSCP import LauncherSCP
  copier = LauncherSCP('copy_%s' % filename)
  logging.info('executing {scp %s %s:%s}', filename, rhost, dest)
  copier.stage(options='-q', source=filename, destination=rhost+':'+dest)
  copier.launch()
  return
Пример #3
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
Пример #4
0
def copy(file, rhost, dest):
    '''copy 'file' object to target destination

Inputs:
    source      -- path string of source 'file'
    rhost       -- hostname of destination target
    destination -- path string for destination target
  '''
    from LauncherSCP import LauncherSCP
    copier = LauncherSCP('copy_%s' % file)
    #print 'executing {scp %s %s:%s}' % (file,rhost,dest)
    copier.stage(options='-q', source=file, destination=rhost + ':' + dest)
    copier.launch()
    return