Example #1
0
def compare_filesystems(fs0, fs1, concurrent=False):
    """Compares the two given filesystems.

    fs0 and fs1 are two mounted GuestFS instances
    containing the two disks to be compared.

    If the concurrent flag is True,
    two processes will be used speeding up the comparison on multiple CPUs.

    Returns a dictionary containing files created, removed and modified.

        {'created_files': [<files in fs1 and not in fs0>],
         'deleted_files': [<files in fs0 and not in fs1>],
         'modified_files': [<files in both fs0 and fs1 but different>]}

    """
    if concurrent:
        task0 = thread.concurrent(target=visit_filesystem, args=(fs0, ))
        task1 = thread.concurrent(target=visit_filesystem, args=(fs1, ))

        files0 = task0.get()
        files1 = task1.get()
    else:
        files0 = visit_filesystem(fs0)
        files1 = visit_filesystem(fs1)

    return file_comparison(files0, files1)
 def test_undecorated_callback(self):
     """Thread Concurrent undecorated results are forwarded to callback."""
     task = thread.concurrent(target=undecorated, args=[1],
                              kwargs={'keyword_argument': 1},
                              callback=self.callback)
     event.wait()
     self.assertEqual(task.get(), 2)
 def test_undecorated_id(self):
     """Thread Concurrent ID is forwarded to it."""
     task = thread.concurrent(target=undecorated, args=[1],
                              kwargs={'keyword_argument': 1},
                              identifier='foo')
     self.assertEqual(task.id, 'foo')
 def test_undecorated_results(self):
     """Thread Concurrent undecorated results are produced."""
     task = thread.concurrent(target=undecorated, args=[1],
                              kwargs={'keyword_argument': 1})
     self.assertEqual(task.get(), 2)
 def test_undecorated_results(self):
     """Process Concurrent undecorated results are produced."""
     task = thread.concurrent(target=undecorated_simple)
     self.assertEqual(task.get(), 0)