def run(self): self.taskman.register_task(self.task_id, self.i18n['arch.task.mirrors'], get_icon_path()) self.logger.info("Refreshing mirrors") handler = ProcessHandler() try: self.taskman.update_progress(self.task_id, 10, '') success, output = handler.handle_simple(pacman.refresh_mirrors(self.root_password), output_handler=self._notify_output) if success: if self.sort_limit is not None and self.sort_limit >= 0: self.taskman.update_progress(self.task_id, 50, self.i18n['arch.custom_action.refresh_mirrors.status.updating']) try: handler.handle_simple(pacman.sort_fastest_mirrors(self.root_password, self.sort_limit), output_handler=self._notify_output) except: self.logger.error("Could not sort mirrors by speed") traceback.print_exc() mirrors.register_sync(self.logger) else: self.logger.error("It was not possible to refresh mirrors") except: self.logger.error("It was not possible to refresh mirrors") traceback.print_exc() self.taskman.update_progress(self.task_id, 100, None) self.taskman.finish_task(self.task_id) self.logger.info("Finished")
def run(self): ti = time.time() self.taskman.update_progress( self.task_id, 0, self.i18n['task.waiting_task'].format( bold(self.create_config.task_name))) self.create_config.join() arch_config = self.create_config.config aur_supported = aur.is_supported(arch_config) self.taskman.update_progress(self.task_id, 1, self.i18n['arch.task.checking_settings']) if not self.is_enabled(arch_config, aur_supported): self.taskman.update_progress(self.task_id, 100, self.i18n['arch.task.disabled']) self.taskman.finish_task(self.task_id) return if not mirrors.should_sync(self.logger): self.taskman.update_progress(self.task_id, 100, self.i18n['arch.task.mirrors.cached']) self.taskman.finish_task(self.task_id) return sort_limit = arch_config['mirrors_sort_limit'] self.logger.info("Refreshing mirrors") handler = ProcessHandler() try: self.taskman.update_progress(self.task_id, 10, '') success, output = handler.handle_simple( pacman.refresh_mirrors(self.root_password), output_handler=self._notify_output) if success: if sort_limit is not None and sort_limit >= 0: self.taskman.update_progress( self.task_id, 50, self.i18n[ 'arch.custom_action.refresh_mirrors.status.updating'] ) try: handler.handle_simple( pacman.sort_fastest_mirrors( self.root_password, sort_limit), output_handler=self._notify_output) except: self.logger.error("Could not sort mirrors by speed") traceback.print_exc() mirrors.register_sync(self.logger) self.refreshed = True else: self.logger.error("It was not possible to refresh mirrors") except: self.logger.error("It was not possible to refresh mirrors") traceback.print_exc() self.taskman.update_progress(self.task_id, 100, None) self.taskman.finish_task(self.task_id) tf = time.time() self.logger.info("Finished. Took {0:.2f} seconds".format(tf - ti))