コード例 #1
0
ファイル: test_events.py プロジェクト: pywizard/pywizard
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
ファイル: test_events.py プロジェクト: pywizard/pywizard
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
ファイル: resource_service.py プロジェクト: pywizard/pywizard
 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
ファイル: resource_package.py プロジェクト: pywizard/pywizard
            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
ファイル: resource_config.py プロジェクト: pywizard/pywizard
    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
ファイル: test_events.py プロジェクト: pywizard/pywizard
def test_event_single_callback():
    clb = Mock()
    event(clb)

    assert clb.mock_calls == [call()]
コード例 #7
0
ファイル: test_events.py プロジェクト: pywizard/pywizard
def test_event_single_callback_non_callable():
    event("hello")
コード例 #8
0
ファイル: resource_service.py プロジェクト: pywizard/pywizard
 def stop(self):
     if not self.is_service_running():
         self._exec_action('stop')
         event(self.on_stop)
コード例 #9
0
ファイル: resource_file.py プロジェクト: pywizard/pywizard
 def remove_file():
     os.remove(self.path)
     event(self.on_remove)
コード例 #10
0
ファイル: resource_file.py プロジェクト: pywizard/pywizard
 def remove_dir():
     try:
         os.rmdir(self.path)
     except OSError as e:
         info(e)
     event(self.on_remove)
コード例 #11
0
ファイル: resource_file.py プロジェクト: pywizard/pywizard
 def create_file():
     with open(self.path, 'w') as f:
         f.write(content_compiled)
     event(self.on_create)
コード例 #12
0
ファイル: resource_file.py プロジェクト: pywizard/pywizard
 def create_dir():
     os.makedirs(self.path)
     event(self.on_create)
コード例 #13
0
ファイル: resource_file.py プロジェクト: pywizard/pywizard
                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)