Exemplo n.º 1
0
    def prepare(self, task_manager: TaskManager, root_password: str,
                internet_available: bool):
        ti = time.time()
        self.logger.info("Initializing")
        taskman = task_manager if task_manager else TaskManager(
        )  # empty task manager to prevent null pointers

        create_config = CreateConfigFile(
            taskman=taskman,
            configman=self.configman,
            i18n=self.i18n,
            task_icon_path=get_path('img/logo.svg'),
            logger=self.logger)
        create_config.start()

        if self.managers:
            internet_on = self.context.is_internet_available()
            prepare_tasks = []
            for man in self.managers:
                if man not in self._already_prepared and self._can_work(man):
                    t = Thread(target=man.prepare,
                               args=(taskman, root_password, internet_on),
                               daemon=True)
                    t.start()
                    prepare_tasks.append(t)
                    self._already_prepared.append(man)

            for t in prepare_tasks:
                t.join()

        tf = time.time()
        self.logger.info("Finished. Took {0:.2f} seconds".format(tf - ti))
Exemplo n.º 2
0
    def prepare(self, task_manager: TaskManager, root_password: str,
                internet_available: bool):
        create_config = CreateConfigFile(taskman=task_manager,
                                         configman=self.configman,
                                         i18n=self.i18n,
                                         task_icon_path=get_icon_path(),
                                         logger=self.logger)
        create_config.start()

        symlink_check = SymlinksVerifier(taskman=task_manager,
                                         i18n=self.i18n,
                                         logger=self.logger)
        symlink_check.start()

        if internet_available:
            DatabaseUpdater(taskman=task_manager,
                            i18n=self.context.i18n,
                            create_config=create_config,
                            http_client=self.context.http_client,
                            logger=self.context.logger).start()

            AppImageSuggestionsDownloader(taskman=task_manager,
                                          i18n=self.context.i18n,
                                          http_client=self.context.http_client,
                                          logger=self.context.logger,
                                          create_config=create_config).start()
Exemplo n.º 3
0
    def prepare(self, task_manager: TaskManager, root_password: Optional[str],
                internet_available: bool):
        create_config = CreateConfigFile(taskman=task_manager,
                                         configman=self.configman,
                                         i18n=self.i18n,
                                         task_icon_path=get_icon_path(),
                                         logger=self.logger)
        create_config.start()

        task_manager.register_task('snap_cats',
                                   self.i18n['task.download_categories'],
                                   get_icon_path())
        category_downloader = CategoriesDownloader(
            id_='snap',
            manager=self,
            http_client=self.http_client,
            logger=self.logger,
            url_categories_file=URL_CATEGORIES_FILE,
            categories_path=CATEGORIES_FILE_PATH,
            internet_connection=internet_available,
            internet_checker=self.context.internet_checker,
            after=lambda: self._finish_category_task(task_manager))
        category_downloader.before = lambda: self._start_category_task(
            task_manager, create_config, category_downloader)
        category_downloader.start()
Exemplo n.º 4
0
    def _start_category_task(self, taskman: TaskManager,
                             create_config: CreateConfigFile,
                             downloader: CategoriesDownloader):
        if taskman:
            taskman.update_progress(
                'snap_cats', 0, self.i18n['task.waiting_task'].format(
                    bold(create_config.task_name)))
            create_config.join()

            categories_exp = create_config.config['categories_exp']
            downloader.expiration = categories_exp if isinstance(
                categories_exp, int) else None
            taskman.update_progress('snap_cats', 1, None)
Exemplo n.º 5
0
 def prepare(self, task_manager: TaskManager, root_password: str,
             internet_available: bool):
     CreateConfigFile(taskman=task_manager,
                      configman=self.configman,
                      i18n=self.i18n,
                      task_icon_path=get_icon_path(),
                      logger=self.logger).start()
Exemplo n.º 6
0
    def prepare(self, task_manager: TaskManager, root_password: Optional[str], internet_available: bool):
        create_config = CreateConfigFile(taskman=task_manager, configman=self.configman, i18n=self.i18n,
                                         task_icon_path=get_icon_path(), logger=self.logger)
        create_config.start()

        symlink_check = SymlinksVerifier(taskman=task_manager, i18n=self.i18n, logger=self.logger)
        symlink_check.start()

        if internet_available:
            DatabaseUpdater(taskman=task_manager, i18n=self.context.i18n,
                            create_config=create_config, http_client=self.context.http_client,
                            logger=self.context.logger).start()

            if not self.suggestions_downloader.is_custom_local_file_mapped():
                self.suggestions_downloader.taskman = task_manager
                self.suggestions_downloader.create_config = create_config
                self.suggestions_downloader.register_task()
                self.suggestions_downloader.start()