示例#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 pathos.secure import Copier
  opt = kwds.pop('options', None)
  kwds['background'] = kwds.pop('bg', False) # ignores 'background'
  copier = Copier(**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)
  pathos.logger().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 pathos.secure import Copier
  opt = kwds.pop('options', None)
  kwds['background'] = kwds.pop('bg', False) # ignores 'background'
  copier = Copier(**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)
  pathos.logger().info('executing {%s}', copier.message)
  copier.launch()
  copier.kill()
  return copier
示例#3
0
if __name__=='__main__':
    source0 = 'test.txt'
    source1 = '~/test.txt'
    source2 = '~/result.txt'
    dest0 = source1
    dest1 = source2
    dest2 = '.'
    cpu1 = 'localhost'
    cpu2 = 'localhost'
   #cpu1 = 'computer.cacr.caltech.edu'
   #cpu2 = 'foobar.danse.us'
    del1 = 'rm '+source1
    del2 = 'rm '+source2

    copier = Copier('LauncherSCP')
    print('creating %s' % source0)
    f = open(source0,'w')
    f.write('Test Successful!\n')
    f.close()

    from time import sleep
    sleep(1) #FIXME: needs time to work...
    print('executing {scp %s %s:%s}' % (source0,cpu1,dest0))
    copier(source=source0, destination=cpu1+':'+dest0)
    copier.launch()

    sleep(1) #FIXME: needs time to work...
    print('executing {scp %s:%s %s:%s}' % (cpu1,source1,cpu2,dest1))
    copier(source=cpu1+':'+source1, destination=cpu2+':'+dest1)
    copier.launch()
示例#4
0
if __name__ == '__main__':
    source0 = 'test.txt'
    source1 = '~/test.txt'
    source2 = '~/result.txt'
    dest0 = source1
    dest1 = source2
    dest2 = '.'
    cpu1 = 'localhost'
    cpu2 = 'localhost'
    #cpu1 = 'computer.cacr.caltech.edu'
    #cpu2 = 'foobar.danse.us'
    del1 = 'rm ' + source1
    del2 = 'rm ' + source2

    copier = Copier('LauncherSCP')
    print('creating %s' % source0)
    f = open(source0, 'w')
    f.write('Test Successful!\n')
    f.close()

    from time import sleep
    sleep(1)  #FIXME: needs time to work...
    print('executing {scp %s %s:%s}' % (source0, cpu1, dest0))
    copier(source=source0, destination=cpu1 + ':' + dest0)
    copier.launch()

    sleep(1)  #FIXME: needs time to work...
    print('executing {scp %s:%s %s:%s}' % (cpu1, source1, cpu2, dest1))
    copier(source=cpu1 + ':' + source1, destination=cpu2 + ':' + dest1)
    copier.launch()