From 8386722af49492a6509f9907e18bda9a28ab653a Mon Sep 17 00:00:00 2001 From: wangsong Date: Tue, 21 Jun 2022 19:16:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=9B=B4=E6=94=B9=E5=AF=BC=E8=87=B4=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/DataAcquisition.py | 2 +- backend/SystemUpdater/Core/Database.py | 8 +- backend/SystemUpdater/Core/UpdateList.py | 77 +++++++++++++++++++ backend/SystemUpdater/Core/enums.py | 20 ++--- backend/po/zh_CN.po | 10 ++- 5 files changed, 101 insertions(+), 16 deletions(-) diff --git a/backend/SystemUpdater/Core/DataAcquisition.py b/backend/SystemUpdater/Core/DataAcquisition.py index 5c12877..2b60fed 100644 --- a/backend/SystemUpdater/Core/DataAcquisition.py +++ b/backend/SystemUpdater/Core/DataAcquisition.py @@ -188,7 +188,7 @@ class UpdateMsgCollector(): logging.error(e) def Upgrade_Process_Msg(self, action, dict_msg = {}): - if self.updateManager.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False) == True: + if self.updateManager.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False) == True: tmp_dict = {} tmp_dict.update(dict_msg) try: diff --git a/backend/SystemUpdater/Core/Database.py b/backend/SystemUpdater/Core/Database.py index 382ab72..333d17b 100644 --- a/backend/SystemUpdater/Core/Database.py +++ b/backend/SystemUpdater/Core/Database.py @@ -212,7 +212,7 @@ class Sqlite3Server(object): self._refresh_system_version(version) #FIXME: 临时方案 PHP - PHPSeverSend(_send_log = self.window_main.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") elif pkg_list: # 单包更新 # 获取单包数据插入数据库 pkgname = pkg_list.pop(0) @@ -262,7 +262,7 @@ class Sqlite3Server(object): # 软件商店获取中文名 appname_cn = self.get_cn_appname(str(pkgname)) #FIXME: 临时方案 PHP - PHPSeverSend(_send_log = self.window_main.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") try: self.insert_into_updateinfo(pkgname, pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn) # FIXME: 发送插入数据库成功的信号local_upgrade_list @@ -315,7 +315,7 @@ class Sqlite3Server(object): self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn) self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr) #FIXME: 临时方案 PHP - PHPSeverSend(_send_log = self.window_main.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkg.name, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkg.name, _appversion=pkgversion, _statue=status, _errorcode="10000100") # insert group deb next for i in pkg_group: # FIXME: 获取组信息 @@ -337,7 +337,7 @@ class Sqlite3Server(object): InstallInfos.update({"errorCode":str(error_string+" "+error_desc)}) self.window_main.collector.Upgrade_Process_Msg("finish-install", InstallInfos.copy()) #FIXME: 临时方案 PHP - PHPSeverSend(_send_log = self.window_main.configs.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=i, _appversion=pkgversion, _statue=status, _errorcode="10000100") + PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=i, _appversion=pkgversion, _statue=status, _errorcode="10000100") try: self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn) self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr) diff --git a/backend/SystemUpdater/Core/UpdateList.py b/backend/SystemUpdater/Core/UpdateList.py index cbc5b7c..f8ca9f2 100644 --- a/backend/SystemUpdater/Core/UpdateList.py +++ b/backend/SystemUpdater/Core/UpdateList.py @@ -276,6 +276,83 @@ class UpdateList(): except Exception as e: logging.error(e) + def _split_package_id(package): + """Return the name, the version number and the release of the + specified package.""" + if "=" in package: + name, version = package.split("=", 1) + release = None + elif "/" in package: + name, release = package.split("/", 1) + version = None + else: + name = package + version = release = None + return name, version, release + + def _mark_packages_for_downgrade(self, packages, resolver): + """Mark packages for downgrade.""" + for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg) + for pkg in packages]: + try: + pkg = self.cache[pkg_name] + except KeyError: + pass + # raise TransactionFailed(ERROR_NO_PACKAGE, + # _("Package %s isn't available"), + # pkg_name) + if not pkg.is_installed: + pass + # raise TransactionFailed(ERROR_PACKAGE_NOT_INSTALLED, + # _("Package %s isn't installed"), + # pkg_name) + auto = pkg.is_auto_installed + + if pkg_ver: + if pkg.installed and pkg.installed.version < pkg_ver: + pass + # FIXME: We need a new error enum + # raise TransactionFailed(ERROR_NO_PACKAGE, + # _("The former version %s of %s " + # "is already installed"), + # pkg.installed.version, pkg.name) + elif pkg.installed and pkg.installed.version == pkg_ver: + pass + # raise TransactionFailed(ERROR_PACKAGE_ALREADY_INSTALLED, + # _("The version %s of %s " + # "is already installed"), + # pkg.installed.version, pkg.name) + try: + pkg.candidate = pkg.versions[pkg_ver] + except KeyError: + pass + # raise TransactionFailed(ERROR_NO_PACKAGE, + # _("The version %s of %s isn't " + # "available"), pkg_ver, pkg_name) + else: + pass + # raise TransactionFailed(ERROR_NO_PACKAGE, + # _("You need to specify a version to " + # "downgrade %s to"), + # pkg_name) + + # pkg.mark_install(False, False, True) + # pkg.mark_auto(auto) + # resolver.clear(pkg) + # resolver.protect(pkg) + + def _make_downgrade(self,cache,data): + downgrade_pkgs = data["force_downgrade"] + for pkg_name, pkg_ver, pkg_rel in [self._split_package_id(pkg) + for pkg in downgrade_pkgs]: + try: + pkg = cache[pkg_name] + except KeyError: + logging.warning("Package %s isn't available",pkg_name) + if not pkg.is_installed: + logging.warning("Package %s isn't installed",pkg_name) + pass + def _make_groups_upgrade(self,cache,group_list, pkgs_upgrade = []): try: if os.path.isdir(self.parent.config_path) == False: diff --git a/backend/SystemUpdater/Core/enums.py b/backend/SystemUpdater/Core/enums.py index bc29afc..001354d 100644 --- a/backend/SystemUpdater/Core/enums.py +++ b/backend/SystemUpdater/Core/enums.py @@ -43,15 +43,17 @@ _STRINGS_ERROR = { PRIORITY_UPGRADE_SUCCCESSED: _("Update Manager upgrade is complete, please restart the control panel before performing the system update"), #update - ERROR_UPDATE_DEFAULT_FAILED: _("Check for update exceptions,please check your network connection and retry."), - ERROR_UPDATE_SOURCE_FAILED: _("Check for update exceptions,please check your network connection and retry."), - ERROR_NETWORK_FAILED: _("Check for update exceptions,please check your network connection and retry."), - ERROR_NOT_GROUPS_CONFIG: _("Check for update exceptions,please check your network connection and retry."), - ERROR_UPDATE_KEY_SIGNATURES: _("Check for update exceptions,please check your network connection and retry."), - ERROR_READ_IMPORTANTLIST_FAILED: _("Check for update exceptions,please check your network connection and retry."), - ERROR_SOFTWARE_INDEX_RROKEN: _("Check for update exceptions,please check your network connection and retry."), - ERROR_NOT_INIT_PACKAGESINFIO: _("Check for update exceptions,please check your network connection and retry."), - ERROR_NOT_CONFIGPKG_DEPENDENCIES: _("Check for update exceptions,please check your network connection and retry."), + ERROR_UPDATE_DEFAULT_FAILED: _("Check for update exceptions,please check your network connection."), + ERROR_UPDATE_SOURCE_FAILED: _("Check for update exceptions,please check your network connection."), + ERROR_NETWORK_FAILED: _("Check for update exceptions,please check your network connection."), + ERROR_UPDATE_KEY_SIGNATURES: _("Check for update exceptions,please check your network connection."), + ERROR_READ_IMPORTANTLIST_FAILED: _("Check for update exceptions,please check your network connection."), + ERROR_SOFTWARE_INDEX_RROKEN: _("Check for update exceptions,please check your network connection."), + ERROR_NOT_INIT_PACKAGESINFIO: _("Check for update exceptions,please check your network connection."), + + #优先升级 + ERROR_NOT_GROUPS_CONFIG: _("Upgrade configuration acquisition exception."), + ERROR_NOT_CONFIGPKG_DEPENDENCIES: _("Upgrade configuration acquisition exception."), #install diff --git a/backend/po/zh_CN.po b/backend/po/zh_CN.po index 1664861..3c9323d 100644 --- a/backend/po/zh_CN.po +++ b/backend/po/zh_CN.po @@ -2626,8 +2626,14 @@ msgstr "依赖关系不满足" msgid "Disk space is insufficient, please clean the disk and then upgrade" msgstr "磁盘空间不足,请清理磁盘后进行升级更新" -msgid "Check for update exceptions,please check your network connection and retry." -msgstr "检查更新异常,请检查您的网络连接后再试。" +msgid "Check for update exceptions,please check your network connection." +msgstr "检查更新异常,请检查您的网络连接。" + +msgid "Priority upgrade status exception." +msgstr "优先升级异常。" + +msgid "Upgrade configuration acquisition exception." +msgstr "升级配置获取异常。" msgid "Please check your network connection and retry." msgstr "请检查您的网络连接后再试。"