def run_rsync(self, encpath, host, port): """ Runs the rsync command with or without recursion, delete or dry-run option. It uses the destination module linked with this session. """ path, recursive = decode_path(encpath) gfile = self.generate_file(path) flags = self.get_flags(gfile, recursive) self.log.info('%s is sending path %s to %s %s' % (self.whoami, path, host, port)) self.log.debug('Used flags: "%s"' % ' '.join(flags)) command = 'rsync %s %s/ rsync://%s:%s/%s' % (' '.join(flags), self.rsyncpath, host, port, self.module) code, output = RunAsyncLoopLog.run(command) os.remove(gfile) parsed = self.parse_output(output) return code, parsed
def run_rsync(self, encpath, host, port): """ Runs the rsync command with or without recursion, delete or dry-run option. It uses the destination module linked with this session. """ path, recursive = decode_path(encpath) gfile = self.generate_file(path) flags = self.get_flags(gfile, recursive) self.log.info('%s is sending path %s to %s %s' % (self.whoami, path, host, port)) self.log.debug('Used flags: "%s"' % ' '.join(flags)) command = 'rsync %s %s/ rsync://%s:%s/%s' % ( ' '.join(flags), self.rsyncpath, host, port, self.module) code, output = RunAsyncLoopLog.run(command) os.remove(gfile) parsed = self.parse_output(output) return code, parsed
def run_rsync(self, encpath, host, port): """ Runs the rsync command with or without recursion, delete or dry-run option. It uses the destination module linked with this session. """ path, recursive = decode_path(encpath) file = self.generate_file(path) # Start rsync recursive or non recursive; archive mode (a) is equivalent to -rlptgoD (see man rsync) flags = ['--stats', '--numeric-ids', '-lptgoD', '--files-from=%s' % file] if recursive: flags.append('-r') if self.rsync_delete: flags.append('--delete') if self.rsync_dry: flags.append('-n') self.log.debug('echo %s is sending %s to %s %s' % (self.whoami, path, host, port)) command = 'rsync %s %s/ rsync://%s:%s/%s' % (' '.join(flags), self.rsyncpath, host, port, self.module) code, output = RunAsyncLoopLog.run(command) os.remove(file) return code, output
def test_decode_path(self): """ Test the decoding of a path """ self.assertTupleEqual(dw.decode_path('0_/tree/c1'), ('/tree/c1', 0)) self.assertTupleEqual(dw.decode_path('1_/tree/b1/bb2/.snapshots'), ('/tree/b1/bb2/.snapshots', 1))
def test_decode_path(self): """ Test the decoding of a path """ self.assertEqual(dw.decode_path('0_/tree/c1'), ('/tree/c1', 0)) self.assertEqual(dw.decode_path('1_/tree/b1/bb2/.snapshots'), ('/tree/b1/bb2/.snapshots', 1))