提交模拟计算

This commit is contained in:
wangsong 2022-06-14 15:14:26 +08:00
parent d8a436df70
commit dd94f1153a
2 changed files with 21 additions and 22 deletions

View File

@ -71,6 +71,7 @@ class UpdateManager():
#失败后重启进行安装的限制次数 目前在自适应升级上面使用
self.retry_limit = self.RETRY_LIMIT_NUM
self.simulate_mode = SimulateTerminal()
#光盘源
self.source_info = UpdateSourceInfo()
@ -889,12 +890,13 @@ class InhibitShutdownLock():
except Exception as e:
logging.error("unlock failed." + str(e))
class SimulateUpdateInstall():
class SimulateTerminal():
ZH_UNMET_DEPENDENCIES = '下列软件包有未满足的依赖关系:'
EN_UNMET_DEPENDENCIES = 'The following packages have unmet dependencies:'
def __init__(self):
pass
def emulate_install(self,pkgs):
def _emulate_install(self,pkgs):
args = ["apt-get", "install","--simulate"]
args = args + pkgs
@ -910,18 +912,26 @@ class SimulateUpdateInstall():
return p.stdout
def thread_install(self):
threading_emulate = threading.Thread(target=self.emulate_update)
threading_emulate = threading.Thread(target=self._emulate_install)
threading_emulate.start()
def thread_update(self):
threading_emulate = threading.Thread(target=self.emulate_update)
threading_emulate.start()
def emulate_install_broken(self,pkgs):
self.emulate_install(pkgs)
def dependencies_broken(self,pkgs):
terminal_msg = self._emulate_install(pkgs)
if len(terminal_msg) > 500:
terminal_msg = ''
if self.ZH_UNMET_DEPENDENCIES in terminal_msg:
terminal_msg = '\n' + self.ZH_UNMET_DEPENDENCIES + terminal_msg.split(self.ZH_UNMET_DEPENDENCIES)[1]
elif self.EN_UNMET_DEPENDENCIES in terminal_msg:
terminal_msg = '\n' + self.EN_UNMET_DEPENDENCIES + terminal_msg.split(self.EN_UNMET_DEPENDENCIES)[1]
else:
terminal_msg = ''
pass
return terminal_msg
class UpdateInstallMode():
def __init__(self,parent):

View File

@ -456,12 +456,11 @@ class InstallBackend():
return delete_pkgs,delete_desc
except Exception as e:
logging.info(str(e))
# msg = get_broken_details(cache,False)
pkg_string = ''
for pkg in pkgs_install + pkgs_upgrade:
pkg_string = pkg_string + ' ' + str(pkg)
logging.info('Resolver calculation Packages List: '+pkg_string+'\n')
terminal_msg = self.emulate_calcul_broken(pkgs_install + pkgs_upgrade)
terminal_msg = self.window_main.simulate_mode.dependencies_broken(pkgs_install + pkgs_upgrade)
logging.error(terminal_msg)
raise UpdateBaseError(ERROR_RESOLVER_FAILED,
desc= terminal_msg)
@ -539,7 +538,7 @@ class InstallBackend():
if len(error_string + error_desc) > 20:
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
else:
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+''+error_desc,error_desc)
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
return
else:
if self.now_upgrade.version_upgrade == True and self.now_upgrade.need_retry == True and success == False:
@ -602,17 +601,7 @@ class InstallBackend():
self.window_main.dbusController.Quit(None)
elif action == self.ACTION_CHECK_RESOLVER:
zh_desc = '下列软件包有未满足的依赖关系:'
en_desc = 'The following packages have unmet dependencies:'
if success == False:
if len(error_desc) > 500:
error_desc = ''
if zh_desc in error_desc:
error_desc = '\n' + zh_desc + error_desc.split(zh_desc)[1]
elif en_desc in error_desc:
error_desc = '\n' + en_desc + error_desc.split(en_desc)[1]
self.window_main.sqlite3_server.insert_info(self.action_mode,self.now_upgrade.single_pkgs,\
self.now_upgrade.upgrade_groups,[],success,error_string,error_desc)
@ -662,12 +651,12 @@ class InstallBackend():
#开始生成列表
self.window_main.start_available()
else:
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+''+error_desc,error_desc)
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
self.window_main.sqlite3_server.insert_into_display("check_time",get_east_8_time())
elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_CACHE:
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+''+error_desc,error_desc)
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string,error_desc)
elif action == self.ACTION_FIX_BROKEN:
self.window_main.dbusController.FixBrokenStatusChanged(True,success,100,'',error_string,error_desc)
logging.warning("fix broken packages is complete...")