Ejemplo n.º 1
0
    def _start_updater(self):
        local_config = read_config(update_file=True)
        interval = local_config['db_updater']['interval'] or 20 * 60

        updater = DatabaseUpdater(http_client=self.context.http_client,
                                  logger=self.context.logger,
                                  db_locks=self.db_locks,
                                  interval=interval)
        if local_config['db_updater']['enabled']:
            updater.start()
        else:
            updater.download_databases()  # only once
Ejemplo n.º 2
0
    def save_settings(self,
                      component: PanelComponent) -> Tuple[bool, List[str]]:
        config = read_config()

        panel = component.components[0]
        config['db_updater']['enabled'] = panel.get_component(
            'up_enabled').get_selected()
        config['db_updater']['interval'] = panel.get_component(
            'up_int').get_int_value()

        try:
            save_config(config, CONFIG_FILE)
            return True, None
        except:
            return False, [traceback.format_exc()]
Ejemplo n.º 3
0
    def prepare(self, task_manager: TaskManager, root_password: str,
                internet_available: bool):
        local_config = read_config(update_file=True)
        interval = local_config['db_updater']['interval'] or 20 * 60

        updater = DatabaseUpdater(task_man=task_manager,
                                  i18n=self.context.i18n,
                                  http_client=self.context.http_client,
                                  logger=self.context.logger,
                                  db_locks=self.db_locks,
                                  interval=interval)
        if local_config['db_updater']['enabled']:
            updater.start()
        elif internet_available:
            updater.download_databases()  # only once
Ejemplo n.º 4
0
    def get_settings(self, screen_width: int,
                     screen_height: int) -> ViewComponent:
        config = read_config()
        max_width = floor(screen_width * 0.15)

        enabled_opts = [
            InputOption(label=self.i18n['yes'].capitalize(), value=True),
            InputOption(label=self.i18n['no'].capitalize(), value=False)
        ]

        updater_opts = [
            SingleSelectComponent(
                label=self.i18n['appimage.config.db_updates.activated'],
                options=enabled_opts,
                default_option=[
                    o for o in enabled_opts
                    if o.value == config['db_updater']['enabled']
                ][0],
                max_per_line=len(enabled_opts),
                type_=SelectViewType.RADIO,
                tooltip=self.i18n['appimage.config.db_updates.activated.tip'],
                max_width=max_width,
                id_='up_enabled'),
            TextInputComponent(
                label=self.i18n['interval'],
                value=str(config['db_updater']['interval']),
                tooltip=self.i18n['appimage.config.db_updates.interval.tip'],
                only_int=True,
                max_width=max_width,
                id_='up_int')
        ]

        return PanelComponent([
            FormComponent(updater_opts,
                          self.i18n['appimage.config.db_updates'])
        ])