def rsync(args): compress = not args.nocompress utils.rsync(args.ssh_host, args.ssh_user, args.targets, compress, prefix=HOSTNAME)
def test_rsync(): from metrique.utils import rsync, sys_call, rand_chars, remove_file from metrique.utils import read_file #remove_file(f_1) #remove_file(dest, force=True) if not sys_call('which rsync'): return # skip this test if rsync isn't available fname = rand_chars(prefix='rsync') path = os.path.join(cache_dir, fname) with open(path, 'w') as f: f.write('test') dest = os.path.join(tmp_dir, 'rsync') rsync(targets=path, dest=dest) assert read_file(os.path.join(dest, fname)) == 'test' with open(path, 'w') as f: f.write('test 2') rsync(targets=path, dest=dest) assert read_file(os.path.join(dest, fname)) == 'test 2' remove_file(path, force=True) remove_file(dest, force=True)