Exemple #1
0
 def signal_reload_cfg_file(self, *args):
     del args
     if self.chain_type == "client":
         from trollmoves.client import reload_config
     else:
         from trollmoves.server import reload_config
     reload_config(self.cmd_args.config_file, self.chains,
                   pub_instance=self.pub)
Exemple #2
0
 def reload_cfg_file(self, filename, *args, **kwargs):
     if self.chain_type == "client":
         from trollmoves.client import reload_config
         reload_config(filename, self.chains, *args, pub_instance=self.pub,
                       **kwargs)
     else:
         # Also Mirror uses the reload_config from the Server
         from trollmoves.server import reload_config
         reload_config(filename, self.chains, *args, publisher=self.pub,
                       **kwargs)
Exemple #3
0
 def reload_cfg_file(self, filename, *args, **kwargs):
     """Reload configuration file."""
     if self.chain_type == "client":
         from trollmoves.client import reload_config
         reload_config(filename, self.chains, *args, **kwargs)
     else:
         # Also Mirror uses the reload_config from the Server
         from trollmoves.server import reload_config
         reload_config(filename,
                       self.chains,
                       *args,
                       publisher=self.publisher,
                       use_watchdog=self.cmd_args.watchdog,
                       disable_backlog=self.cmd_args.disable_backlog)
Exemple #4
0
 def signal_reload_cfg_file(self, *args):
     """Handle reload signal."""
     del args
     if self.chain_type == "client":
         from trollmoves.client import reload_config
         reload_config(self.cmd_args.config_file,
                       self.chains,
                       sync_publisher=self.sync_publisher)
     else:
         from trollmoves.server import reload_config
         reload_config(self.cmd_args.config_file,
                       self.chains,
                       publisher=self.sync_publisher,
                       use_watchdog=self.cmd_args.watchdog,
                       disable_backlog=self.cmd_args.disable_backlog)
Exemple #5
0
def test_reload_config(Listener, NoisyPublisher):
    """Test trollmoves.client.reload_config(), which also builds the chains."""
    from trollmoves.client import reload_config

    with NamedTemporaryFile('w', delete=False) as fid:
        config_fname_1 = fid.name
        fid.write(CLIENT_CONFIG_1_ITEM)
    with NamedTemporaryFile('w', delete=False) as fid:
        config_fname_2 = fid.name
        fid.write(CLIENT_CONFIG_2_ITEMS)

    chains = {}
    callback = MagicMock()

    try:
        reload_config(config_fname_1, chains, callback=callback,
                      pub_instance='pub')
        section_name = "eumetcast_hrit_0deg_scp_hot_spare"
        assert section_name in chains
        listeners = chains[section_name]['listeners']
        assert len(listeners) == 4
        # The same listener was used for all, so it should have been
        # started four times
        for key in listeners:
            assert listeners[key].start.call_count == 4
        NoisyPublisher.assert_called_once()
        chains[section_name]['publisher'].start.assert_called_once()

        # Reload the same config again, nothing should happen
        reload_config(config_fname_1, chains, callback=callback,
                      pub_instance='pub')
        for key in listeners:
            assert listeners[key].start.call_count == 4
        NoisyPublisher.assert_called_once()
        chains[section_name]['publisher'].start.assert_called_once()

        # Load a new config with one new item
        reload_config(config_fname_2, chains, callback=callback,
                      pub_instance='pub')
        assert len(chains) == 2
        assert "foo" in chains
        # One additional call to publisher and listener
        assert NoisyPublisher.call_count == 2
        assert Listener.call_count == 5

        # Load the first config again, the other chain should have been removed
        reload_config(config_fname_1, chains, callback=callback,
                      pub_instance='pub')
        assert "foo" not in chains
        # No new calls to publisher nor listener
        assert NoisyPublisher.call_count == 2
        assert Listener.call_count == 5
    finally:
        os.remove(config_fname_1)
        os.remove(config_fname_2)
Exemple #6
0
 def signal_reload_cfg_file(*args):
     reload_config(cmd_args.config_file, chains, pub_instance=PUB)
Exemple #7
0
 def reload_cfg_file(filename, *args, **kwargs):
     reload_config(filename, chains, *args, pub_instance=PUB, **kwargs)