Exemple #1
0
 def patch(cls, dest_rpath, source_diffiter, start_index=()):
     """Patch dest_rpath with an rorpiter of diffs"""
     ITR = rorpiter.IterTreeReducer(PatchITRB, [dest_rpath, cls.CCPP])
     for diff in rorpiter.FillInIter(source_diffiter, dest_rpath):
         log.Log("Processing file {cf}".format(cf=diff), log.INFO)
         ITR(diff.index, diff)
     ITR.finish_processing()
     cls.CCPP.close()
     dest_rpath.setdata()
Exemple #2
0
 def patch_and_increment(cls, dest_rpath, source_diffiter, inc_rpath):
     """Patch dest_rpath with rorpiter of diffs and write increments"""
     ITR = rorpiter.IterTreeReducer(IncrementITRB,
                                    [dest_rpath, inc_rpath, cls.CCPP])
     for diff in rorpiter.FillInIter(source_diffiter, dest_rpath):
         log.Log("Processing changed file {cf}".format(cf=diff), log.INFO)
         ITR(diff.index, diff)
     ITR.finish_processing()
     cls.CCPP.close()
     dest_rpath.setdata()
Exemple #3
0
    def test_fill_in(self):
        """Test fill_in_iter"""
        rootrp = RPath(Globals.local_connection, "testfiles/output")

        def get_rpiter():
            for int_index in [(1, 2), (1, 3), (1, 4), (2, ), (2, 1), (3, 4, 5),
                              (3, 6)]:
                index = tuple(map(lambda i: str(i), int_index))
                yield rootrp.new_index(index)

        filled_in = rorpiter.FillInIter(get_rpiter(), rootrp)
        rp_list = list(filled_in)
        index_list = map(lambda rp: tuple(map(int, rp.index)), rp_list)
        assert index_list == [(), (1, ), (1, 2), (1, 3), (1, 4), (2, ), (2, 1),
                              (3, ), (3, 4), (3, 4, 5), (3, 6)], index_list
Exemple #4
0
    def patch(cls, target, diff_iter):
        """
        Patch target with the diffs from the mirror side

        This function and the associated ITRB is similar to the
        patching code in backup.py, but they have different error
        correction requirements, so it seemed easier to just repeat it
        all in this module.
        """
        ITR = rorpiter.IterTreeReducer(_DirPatchITRB, [target])
        for diff in rorpiter.FillInIter(diff_iter, target):
            log.Log("Processing changed file {cf}".format(cf=diff), log.INFO)
            ITR(diff.index, diff)
        ITR.finish_processing()
        target.setdata()
Exemple #5
0
    def test_fill_in(self):
        """Test fill_in_iter"""
        rootrp = rpath.RPath(Globals.local_connection, abs_output_dir)

        def get_rpiter():
            for int_index in [(1, 2), (1, 3), (1, 4), (2, ), (2, 1), (3, 4, 5),
                              (3, 6)]:
                index = tuple([str(i) for i in int_index])
                yield rootrp.new_index(index)

        filled_in = rorpiter.FillInIter(get_rpiter(), rootrp)
        rp_list = list(filled_in)
        index_list = [tuple(map(int, rp.index)) for rp in rp_list]
        assert index_list == [(), (1, ), (1, 2), (1, 3), (1, 4), (2, ), (2, 1),
                              (3, ), (3, 4), (3, 4, 5), (3, 6)], index_list
Exemple #6
0
    def test_fill_in(self):
        """Test fill_in_iter"""
        rootrp = rpath.RPath(Globals.local_connection, abs_output_dir)

        def get_rpiter():
            for index in [('a', 'b'), ('a', 'c'), ('a', 'd'), ('b', ),
                          ('b', 'a'), ('c', 'd', 'e'), ('c', 'f')]:
                yield rootrp.new_index(index)

        filled_in = rorpiter.FillInIter(get_rpiter(), rootrp)
        # rpath index is a bytes tuple, needs to be converted to strings.
        # FillInIter complains about non existing directory 'c' and 'c/d',
        # this is normal because indeed the directories don't exist.
        index_list = [tuple(map(os.fsdecode, rp.index)) for rp in filled_in]
        self.assertEqual(index_list, [(), ('a', ), ('a', 'b'), ('a', 'c'),
                                      ('a', 'd'), ('b', ), ('b', 'a'), ('c', ),
                                      ('c', 'd'), ('c', 'd', 'e'), ('c', 'f')])