Esempio n. 1
0
    def __init__(self, on_date=None):
        # Sync installed product info with server.
        # This will be done on register if we aren't registered.
        # ComplianceManager.__init__ needs the installed product info
        # in sync before it will be accurate, so update it, then
        # super().__init__. See rhbz #1004893
        self.installed_mgr = inj.require(inj.INSTALLED_PRODUCTS_MANAGER)
        self.update_product_manager()

        super(CertSorter, self).__init__(on_date)
        self.callbacks = set()

        cert_dir_monitors = {
            file_monitor.PRODUCT_WATCHER: file_monitor.DirectoryWatch(
                inj.require(inj.PROD_DIR).path,
                [self.on_prod_dir_changed, self.load]
            ),
            file_monitor.ENTITLEMENT_WATCHER: file_monitor.DirectoryWatch(
                inj.require(inj.ENT_DIR).path,
                [self.on_ent_dir_changed, self.load]
            ),
            file_monitor.CONSUMER_WATCHER: file_monitor.DirectoryWatch(
                inj.require(inj.IDENTITY).cert_dir_path,
                [self.on_identity_changed, self.load]
            )
        }

        # Note: no timer is setup to poll file_monitor by cert_sorter itself,
        # the gui can add one.
        self.cert_monitor = file_monitor.FilesystemWatcher(cert_dir_monitors)
Esempio n. 2
0
 def setUp(self):
     super(TestFilesystemWatcher, self).setUp()
     self.mock_cb1 = Mock(return_value=None)
     self.mock_cb2 = Mock(return_value=None)
     self.testpath1 = self.write_tempfile("").name
     self.testpath2 = self.write_tempfile("").name
     self.testpath3 = self.write_tempfile("").name
     self.dw1 = file_monitor.DirectoryWatch(self.testpath1, [], is_glob=True)
     self.dw2 = file_monitor.DirectoryWatch(self.testpath2, [], is_glob=False)
     self.dw3 = file_monitor.DirectoryWatch(self.testpath2, [self.mock_cb1, self.mock_cb2], is_glob=False)
     self.dir_list = [self.dw1, self.dw2, self.dw3]
     self.fsw1 = file_monitor.FilesystemWatcher(self.dir_list)
     self.fsw2 = file_monitor.InotifyFilesystemWatcher(self.dir_list)
Esempio n. 3
0
 def setUp(self):
     super(TestDirectoryWatch, self).setUp()
     self.mock_cb1 = Mock(return_value=None)
     self.mock_cb2 = Mock(return_value=None)
     self.tmp_file1 = tempfile.NamedTemporaryFile(prefix="directory_watcher_test_")
     self.tmp_file2 = tempfile.NamedTemporaryFile(prefix="directory_watcher_test_")
     self.testpath1 = self.tmp_file1.name
     self.testpath2 = self.tmp_file2.name
     subprocess.call("touch %s" % self.testpath1, shell=True)
     subprocess.call("touch %s" % self.testpath2, shell=True)
     self.dw1 = file_monitor.DirectoryWatch(self.testpath1, [], is_glob=True)
     self.dw2 = file_monitor.DirectoryWatch(self.testpath2, [], is_glob=False)
     self.dw3 = file_monitor.DirectoryWatch(self.testpath2, [self.mock_cb1, self.mock_cb2], is_glob=False)
 def setUp(self):
     super(TestDirectoryWatch, self).setUp()
     self.mock_cb1 = Mock(return_value=None)
     self.mock_cb2 = Mock(return_value=None)
     self.testpath1 = "file1"
     self.testpath2 = "file2"
     subprocess.call("touch %s" % self.testpath1, shell=True)
     subprocess.call("touch %s" % self.testpath2, shell=True)
     self.dw1 = file_monitor.DirectoryWatch(self.testpath1, [],
                                            is_glob=True)
     self.dw2 = file_monitor.DirectoryWatch(self.testpath2, [],
                                            is_glob=False)
     self.dw3 = file_monitor.DirectoryWatch(self.testpath2,
                                            [self.mock_cb1, self.mock_cb2],
                                            is_glob=False)