词条修改以及增加新信号发送错误代码

This commit is contained in:
wangsong 2022-06-13 13:42:48 +08:00
parent c4973e716d
commit c65620d466
7 changed files with 107 additions and 56 deletions

View File

@ -7,7 +7,7 @@ __all__ = (
"ERROR_NOT_INIT_PACKAGESINFIO","ERROR_READ_IMPORTANTLIST_FAILED","ERROR_RESOLVER_FAILED","ERROR_NOT_UPGRADE_PACKAGES",
"ERROR_REMOVE_ESSENTIAL_PACKAGES","ERROR_NOT_DISK_SPACE",
"ERROR_UPDATE_KEY_SIGNATURES",
"ERROR_UPDATE_KEY_SIGNATURES","ERROR_UPDATE_NET_AUTHENTICATION","ERROR_UPDATE_NOTREAD_SOURCES",
"get_error_description_from_enum", "get_error_string_from_enum", "get_source_name_from_enum")
@ -18,14 +18,8 @@ _ = gettext.gettext
#更新阶段
ERROR_UPDATE_KEY_SIGNATURES = "The following signatures"
#UPGRADE MONITOR STATUS
MONIT_DETECT = "step-updatedetect"
MONIT_DEPRESOLUT = "step-depresolution"
MONIT_DOWNLOAD = "step-downloading"
MONIT_INSTALL = "step-installing"
MONIT_FINISH = "step-finish"
ERROR_UPDATE_NET_AUTHENTICATION ="does the network require authentication?"
ERROR_UPDATE_NOTREAD_SOURCES = "The list of sources could not be read"
#自己的
ERROR_UPDATE_SOURCE_FAILED = "error-update-source-failed"
@ -39,6 +33,17 @@ ERROR_NOT_UPGRADE_PACKAGES = "error-not-upgrade-packages"
ERROR_REMOVE_ESSENTIAL_PACKAGES = "error-remove-essential-packages"
ERROR_NOT_DISK_SPACE = "error-not-disk-space"
_STRINGS_ERROR = {
ERROR_UPDATE_SOURCE_FAILED: _("Unable to access the source management server"),
ERROR_NETWORK_FAILED: _("Please check your network connection and retry."),
ERROR_NOT_GROUPS_CONFIG: _("Unable to get group configuration package, please contact administrator to solve"),
ERROR_SOFTWARE_INDEX_RROKEN: _("Software index is broken"),
ERROR_NOT_INIT_PACKAGESINFIO: _("Could not initialize the package information"),
ERROR_READ_IMPORTANTLIST_FAILED: _("read important list failed"),
ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"),
ERROR_NOT_UPGRADE_PACKAGES: _("There is an exception in the update package."),
ERROR_REMOVE_ESSENTIAL_PACKAGES: _("There is an exception in the update package."),
ERROR_NOT_DISK_SPACE: _("Disk space is insufficient, please clean the disk and then upgrade")}
_DESCS_ERROR = {
ERROR_UPDATE_SOURCE_FAILED: _("Check your source management server config"),
@ -57,20 +62,20 @@ _DESCS_ERROR = {
ERROR_RESOLVER_FAILED: _("nothing"),
ERROR_NOT_UPGRADE_PACKAGES: _("This update cannot detect the upgradeable package."),
ERROR_REMOVE_ESSENTIAL_PACKAGES: _("You request the removal of a system-essential package."),
ERROR_NOT_DISK_SPACE: _("test")}
ERROR_NOT_DISK_SPACE: _("test"),
ERROR_UPDATE_KEY_SIGNATURES: _("Check your source public key signature"),
ERROR_UPDATE_NET_AUTHENTICATION: _("Check if your network requires authentication?"),
_STRINGS_ERROR = {
ERROR_UPDATE_SOURCE_FAILED: _("Unable to access the source management server"),
ERROR_NETWORK_FAILED: _("Please check your network connection and retry."),
ERROR_NOT_GROUPS_CONFIG: _("Unable to get group configuration package, please contact administrator to solve"),
ERROR_SOFTWARE_INDEX_RROKEN: _("Software index is broken"),
ERROR_NOT_INIT_PACKAGESINFIO: _("Could not initialize the package information"),
ERROR_READ_IMPORTANTLIST_FAILED: _("read important list failed"),
ERROR_RESOLVER_FAILED: _("Could not calculate the upgrade"),
ERROR_NOT_UPGRADE_PACKAGES: _("There is an exception in the update package."),
ERROR_REMOVE_ESSENTIAL_PACKAGES: _("There is an exception in the update package."),
ERROR_NOT_DISK_SPACE: _("Disk space is insufficient, please clean the disk and then upgrade")}
ERROR_UPDATE_NOTREAD_SOURCES: _("Please check your source list and retry.")
}
#UPGRADE MONITOR STATUS
MONIT_DETECT = "step-updatedetect"
MONIT_DEPRESOLUT = "step-depresolution"
MONIT_DOWNLOAD = "step-downloading"
MONIT_INSTALL = "step-installing"
MONIT_FINISH = "step-finish"
SOURCE_NAME = {
'kylin-installer':_("Kylin Installer"),

View File

@ -77,9 +77,11 @@ class UpdateManager():
self.install_mode = UpdateInstallMode(self)
self.apt_p2p_config = AptP2pConfigManager()
#加载Cache
self.refresh_cache()
self._reload_options_config()
#加载Cache
self._refresh_cache_only()
def _reload_options_config(self):
#添加默认保留旧配置
@ -277,6 +279,17 @@ class UpdateManager():
logging.error(str(e))
raise UpdateBaseError(ERROR_NOT_INIT_PACKAGESINFIO)
def _refresh_cache_only(self):
try:
#第一次进入 之后update不进入
if self.cache is None:
self.cache = MyCache(None)
else:
self.cache.open(None)
self.cache._initDepCache()
except Exception as e:
logging.error(e)
def _check_self_upgrade(self,cache):
need_upgrade = False

View File

@ -894,7 +894,13 @@ class UpdateManagerDbusController(dbus.service.Object):
@dbus.service.signal(UPDATER_DBUS_INTERFACE)
def ChangeUpgradePolicy(self):
logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" ChangeUpgradePolicy")
#下载安装前的状态检查信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='bs')
def InstallDetectStatus(self, success,error_code=''):
logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " InstallDetectStatus success = %r , error_code = %s",\
success,error_code)
WRITABLE_PROPERTIES = ()
# pylint: disable-msg=C0103,C0322

View File

@ -286,7 +286,7 @@ class InstallBackend():
self.window_main.check_conifg_aptdeamon()
self.update()
except UpdateBaseError as excep:
self._action_done(self.action,True,False,excep.header,excep.desc)
self._action_done(self.action,True,False,excep.header,excep.desc,excep.code)
except UpdateProgressExit as excep:
pass
except Exception as e:
@ -521,18 +521,23 @@ class InstallBackend():
logging.error("Package("+pkg+") "+ str(e))
return [],[]
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
def _action_done(self, action, is_cancelled,success, error_string,error_desc):
#后端的状态 到空闲状态
self.window_main.now_working = self.ACTION_DEFUALT_STATUS
def _send_error_code(self,error_code):
if error_code == ERROR_NOT_DISK_SPACE:
self.window_main.dbusController.InstallDetectStatus(False,error_code)
#调用aptdeamon结束之后处理的地方 不管是出错还是正常都在此处理
def _action_done(self, action, is_cancelled,success, error_string,error_desc,error_code=''):
#后端的状态 到空闲状态
self.window_main.now_working = self.ACTION_DEFUALT_STATUS
#升级完成后走的分支
if action == self.ACTION_INSTALL:
#记录这个过程中是否关机
self.window_main.configs.setValue("SystemStatus","abnormal_reboot",str(False),True)
#解锁 禁止关机
unLockedEnableShutdown()
self._send_error_code(error_code)
#单包安装模式 单独处理 目前 更新配置包和升级本身使用
if self.action_mode == self.MODE_INSTALL_SINGLE:
if success:
@ -673,27 +678,28 @@ class InstallBackend():
self.window_main.dbusController.UpdateDownloadFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc)
elif action == self.ACTION_UPDATE:
if success == False and ERROR_UPDATE_KEY_SIGNATURES in self.aptd_base.error_details:
error_desc = _("Check your source public key signature")
#网络认证错误
elif success == False and 'does the network require authentication?' in self.aptd_base.error_details:
error_desc = _("Check if your network requires authentication?")
elif action == self.ACTION_UPDATE and self.action_mode == self.MODE_UPDATE_ALL:
if success == False:
threading_emulate = threading.Thread(target=self.emulate_update)
threading_emulate.start()
if ERROR_UPDATE_KEY_SIGNATURES in self.aptd_base.error_details:
error_desc = get_error_description_from_enum(ERROR_UPDATE_KEY_SIGNATURES)
elif ERROR_UPDATE_NET_AUTHENTICATION in self.aptd_base.error_details:
error_desc = get_error_description_from_enum(ERROR_UPDATE_NET_AUTHENTICATION)
elif ERROR_UPDATE_NOTREAD_SOURCES in self.aptd_base.error_details:
error_desc = get_error_description_from_enum(ERROR_UPDATE_NOTREAD_SOURCES)
if success and self.action_mode == self.MODE_UPDATE_ALL:
if success:
#开始生成列表
self.window_main.start_available()
else:
self.window_main.dbusController.DistUpdateDetectFinished(success,[],error_string+''+error_desc,error_desc)
if self.action_mode == self.MODE_UPDATE_ALL:
#记录本次更新时间插入数据库
self.window_main.sqlite3_server.insert_into_display("check_time",get_east_8_time())
if success == False and self.action_mode == self.MODE_UPDATE_ALL:
threading_emulate = threading.Thread(target=self.emulate_update)
threading_emulate.start()
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)
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...")

View File

@ -520,6 +520,27 @@
#### InstallDetectStatus
- `介绍:`下载安装前的状态检查
- `出参`: `b:`检查出错时为`False`,没有错误`success``s:`产生错误的码
- 错误码示例:
```python
ERROR_NOT_DISK_SPACE = "error-not-disk-space"
```
- `示例:`
```sh
#表示出现磁盘已满的错误z
InstallDetectStatus success = False , error_code = "error-not-disk-space"
```

View File

@ -85,18 +85,15 @@ if __name__ == "__main__":
logging.info('kylin-system-updater(lang:%s) starting ...',os.environ["LANGUAGE"])
try:
app = UpdateManager(options)
app = UpdateManager(options)
#当出现安装过程中异常的重启时 开机直接进行修复操作
if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True:
app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True)
app.check_frontend_pkg()
#当出现安装过程中异常的重启时 开机直接进行修复操作
if app.configs.getWithDefault("ConfigPkgStatus", "check_frontend_pkg", False) == True:
app.configs.setValue("ConfigPkgStatus","check_frontend_pkg",str(False),True)
app.check_frontend_pkg()
#当出现安装过程中异常的重启时 开机直接进行修复操作
if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True:
app.start_update()
#当出现安装过程中异常的重启时 开机直接进行修复操作
if app.configs.getWithDefault("SystemStatus", "abnormal_reboot", False) == True:
app.start_update()
app.run()
except Exception as e:
logging.error(e)
app.run()

View File

@ -2625,6 +2625,9 @@ msgstr "磁盘空间不足,请清理磁盘后进行升级更新"
msgid "Please check your network connection and retry."
msgstr "请检查您的网络连接后再试。"
msgid "Please check your source list and retry."
msgstr "请检查您的源列表后再试。"
msgid "Checking network connection"
msgstr "检查网络连接中"