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
#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() sleep(1) #FIXME: needs time to work... print('executing {scp %s:%s %s}' % (cpu2,source2,dest2)) copier(source=cpu2+':'+source2, destination=dest2) copier.launch() sleep(1) #FIXME: needs time to work... print('cleanup temporary files...') import os os.remove(source0)
#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() sleep(1) #FIXME: needs time to work... print('executing {scp %s:%s %s}' % (cpu2, source2, dest2)) copier(source=cpu2 + ':' + source2, destination=dest2) copier.launch() sleep(1) #FIXME: needs time to work... print('cleanup temporary files...') import os os.remove(source0)