def update_modules(self, repository):
        base_dir = path.dirname(path.dirname(path.abspath(__file__)))
        modules_dir = path.join(base_dir, 'modules')

        self._remove_compiled_files(modules_dir)

        installed_modules = self.list_installed_modules_for(repository)
        updated_named_configs = []

        for name, obj in self.walk_modules(modules_dir, repository=repository):
            updated_named_configs += self.update(obj, name, repository)

            if obj.name:
                installed_modules.discard(obj.name)

        # Delete all modules that are no longer in the repository
        for missing_module in installed_modules:
            print "Deleting '{}'".format(missing_module)
            ModuleInfo.get_collection().remove({'name': missing_module})

        # Disable all modules that have incomplete named configs
        for updated_named_config in unique_for_key(updated_named_configs,
                                                   'name'):
            if incomplete_config(updated_named_config['config']):
                for name, obj in self.walk_modules(modules_dir):
                    if obj.name and updated_named_config[
                            'name'] in obj.named_configs:
                        info = ModuleInfo.get(name=obj.name)

                        if info['enabled']:
                            print "Disabling {} for incomplete named config {}".format(
                                obj.name, updated_named_config['name'])
                            info.update_value('enabled', False)
Пример #2
0
def configuration():
    print("########## Configuration ##########\n")
    for config in Config.find():
        print(("{}: {}".format(config['name'], not incomplete_config(config['config']))))

    print("\nModules:\n")

    for module in ModuleInfo.find():
        state = "Disabled"
        configured = "Configured"

        if module['enabled']:
            state = "Enabled"

        if incomplete_config(module['config']):
            configured = "Not Configured"

        print(("{: <25} {: <20} {: <10} {: <15}".format(module['name'], module['type'], state, configured)))
Пример #3
0
    def update_config(self, new_info):
        if self['type'] == 'Processing':
            self['generates'] = new_info['generates']
            self._update_diffed_value('queue', new_info['queue'])
            self._update_diffed_value('acts_on', new_info['acts_on'])
            self._update_diffed_value('triggered_by', new_info['triggered_by'])

        elif self['type'] == 'Preloading':
            self._update_diffed_value('queue', new_info['queue'])
            self._update_diffed_value('priority', new_info['priority'])

        elif self['type'] == 'Filetype':
            self._update_diffed_value('acts_on', new_info['acts_on'])

        self['description'] = new_info['description']
        self['config'] = apply_config_update(self['config'], new_info['config'])

        if self['enabled'] and incomplete_config(self['config']):
            self['enabled'] = False

        self.save()
Пример #4
0
    def update_config(self, new_info):
        if self['type'] == 'Processing':
            self['generates'] = new_info['generates']

            self['queue'] = new_info['queue']
            if 'queue' in self['diffs']:
                if self['diffs']['queue'] == new_info['queue']:
                    del self['diffs']['queue']
                else:
                    self['queue'] = self['diffs']['queue']

            self._update_diffed_value('acts_on', new_info['acts_on'])
            self._update_diffed_value('triggered_by', new_info['triggered_by'])

        self['description'] = new_info['description']
        self['config'] = apply_config_update(self['config'],
                                             new_info['config'])

        if self['enabled'] and incomplete_config(self['config']):
            self['enabled'] = False

        self.save()