예제 #1
0
def test_event_several_callbacks_tuple():
    clb1 = Mock()
    clb2 = Mock()
    event((clb1, clb2))

    assert clb1.mock_calls == [call()]
    assert clb2.mock_calls == [call()]
예제 #2
0
def test_event_several_callbacks_list():
    clb1 = Mock()
    clb2 = Mock()
    event([clb1, clb2])

    assert clb1.mock_calls == [call()]
    assert clb2.mock_calls == [call()]
예제 #3
0
 def restart(self):
     if self.is_service_running():
         self._exec_action('restart')
         event(self.on_restart)
     else:
         info('Service %s is requested to be restarted, but it is not running. Restarting.' % self.name)
         self._exec_action('start')
         event(self.on_start)
예제 #4
0
            def install():
                info("Installing packages %s" % packs_to_install)

                event(self.before_install)

                provider.install_packages(packs_to_install)

                not_installed_packs = provider.get_not_installed(packs_to_install)
                if len(not_installed_packs) > 0:
                    error('The following packages was not installed on some reason: %s' % not_installed_packs)
                else:
                    event(self.after_install)
                    info('All packages installed: %s' % packs_to_install)
예제 #5
0
    def _apply():
        debug('Write ini settings to %s' % filename)
        debug(config)

        cfg = ConfigParser()
        cfg.read(filename)
        for section, values in config.items():
            if not cfg.has_section(section):
                if strict_sections:
                    raise Exception('No section %s in ini file %s' % (section, filename))
                else:
                    cfg.add_section(section)

            for key, val in values.items():
                cfg.set(section, key, val)

        with open(filename, 'w') as configfile:
            cfg.write(configfile)

        event(on_apply)
예제 #6
0
def test_event_single_callback():
    clb = Mock()
    event(clb)

    assert clb.mock_calls == [call()]
예제 #7
0
def test_event_single_callback_non_callable():
    event("hello")
예제 #8
0
 def stop(self):
     if not self.is_service_running():
         self._exec_action('stop')
         event(self.on_stop)
예제 #9
0
 def remove_file():
     os.remove(self.path)
     event(self.on_remove)
예제 #10
0
 def remove_dir():
     try:
         os.rmdir(self.path)
     except OSError as e:
         info(e)
     event(self.on_remove)
예제 #11
0
 def create_file():
     with open(self.path, 'w') as f:
         f.write(content_compiled)
     event(self.on_create)
예제 #12
0
 def create_dir():
     os.makedirs(self.path)
     event(self.on_create)
예제 #13
0
                def update_content():
                    # s.file_write(self.path, content_compiled, self.mode, self.owner, self.group)
                    with open(self.path, 'w') as f:
                        f.write(content_compiled)

                    event(self.on_update)