예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
파일: source.py 프로젝트: stdweird/vsc-zk
    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
예제 #4
0
 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))
예제 #5
0
 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))