Beispiel #1
0
    def __subprocess_popen(self, args):
        """
        For internal use.
        Execute the given command line, interpreted as a shell command.
        Returns int Exitcode, string StdOut, string StdErr
        """
        from subprocess import Popen, PIPE

        args[0] = util.which(args[0])
        p = Popen(args, stdout=PIPE, stderr=PIPE)
        stdout, stderr = p.communicate()

        return p.returncode, stdout, stderr
    def __init__(self, parsed_url):
        duplicity.backend.Backend.__init__(self, parsed_url)

        acdcli_exe = None
        try:
          # duplicity 0.7.06 and older
          acdcli_exe = self.which(self.acd_cmd)
        except AttributeError:
          # duplicity 0.7.07 and newer
          acdcli_exe = util.which(self.acd_cmd)

        if acdcli_exe == None:
            log.FatalError(self.acd_cmd + ' not found: Please install acd_cli',
                           log.ErrorCode.backend_not_found)

        self.parsed_url = parsed_url
        self.url_string = duplicity.backend.strip_auth_from_url(self.parsed_url)

        # Use an explicit directory name.
        if self.url_string[-1] != '/':
            self.url_string += '/'

        self.subprocess_popen(self.acd_cmd + " sync")
#          self.backend = duplicity.backend.get_backend_object(url)
#          self.assertEqual(self.backend.__class__.__name__, u'HSIBackend')


class FTPBackendTest(BackendInstanceBase):
    def setUp(self):
        super(FTPBackendTest, self).setUp()
        os.makedirs(u'testfiles/output')
        url = u'ftp://*****:*****@hostname/testfiles/output'
        self.backend = duplicity.backend.get_backend_object(url)
        self.assertEqual(self.backend.__class__.__name__, u'LFTPBackend')


class FTPSBackendTest(BackendInstanceBase):
    def setUp(self):
        super(FTPSBackendTest, self).setUp()
        os.makedirs(u'testfiles/output')
        url = u'ftps://*****:*****@hostname/testfiles/output'
        self.backend = duplicity.backend.get_backend_object(url)
        self.assertEqual(self.backend.__class__.__name__, u'LFTPBackend')


@unittest.skipIf(not util.which(u'rclone'), u"rclone not installed")
class RCloneBackendTest(BackendInstanceBase):
    def setUp(self):
        super(RCloneBackendTest, self).setUp()
        os.makedirs(u'testfiles/output')
        url = u'rclone://duptest:/%s/testfiles/output' % os.getcwd()
        self.backend = duplicity.backend.get_backend_object(url)
        self.assertEqual(self.backend.__class__.__name__, u'RcloneBackend')
Beispiel #4
0
        info = self.backend._query_list([b'file-a', b'file-b'])
        self.assertEqual(info[b'file-a'][u'size'], self.local.getsize())
        self.assertEqual(info[b'file-b'][u'size'], -1)
        self.assertFalse(b'file-c' in info)


class LocalBackendTest(BackendInstanceBase):
    def setUp(self):
        super(LocalBackendTest, self).setUp()
        url = u'file://{0}/testfiles/output'.format(_runtest_dir)
        self.backend = duplicity.backend.get_backend_object(url)
        self.assertEqual(self.backend.__class__.__name__, u'LocalBackend')


# TODO: Add par2-specific tests here, to confirm that we can recover
@unittest.skipIf(not util.which(u'par2'), u"par2 not installed")
class Par2BackendTest(BackendInstanceBase):
    def setUp(self):
        super(Par2BackendTest, self).setUp()
        url = u'par2+file://{0}/testfiles/output'.format(_runtest_dir)
        self.backend = duplicity.backend.get_backend_object(url)
        self.assertEqual(self.backend.__class__.__name__, u'Par2Backend')


# TODO: Fix so localhost is not required.  Fails on LP and GitLab
# class RsyncBackendTest(BackendInstanceBase):
#     def setUp(self):
#         super(RsyncBackendTest, self).setUp()
#         os.makedirs(u'{0}/testfiles/output')  # rsync needs it to exist first
#         url = u'rsync://localhost:2222//%s/{0}/testfiles/output' % os.getcwd()
#         self.backend = duplicity.backend.get_backend_object(url)