From 7c35a9f868984fcaf165987258a1c48a20761670 Mon Sep 17 00:00:00 2001 From: wangsong Date: Wed, 14 Sep 2022 10:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9dbus=E7=9A=84=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E8=BF=94=E5=9B=9E=E5=80=BC=E5=81=9A=E5=87=BA=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E5=8C=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManagerDbus.py | 67 ++++++++++++++++------ backend/data/system-updater-coverable.conf | 1 + 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 7ab4e3f..09265bd 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -53,6 +53,7 @@ UU_UPGRADE_MODE_BEFORE_SHUTDOWN = 1 #dbus 建立 class UpdateManagerDbusController(dbus.service.Object): """ this is a helper to provide the UpdateManagerIFace """ + MOTHOD_RETURN_SUCCESS = "success" def __init__(self, parent, bus_name, object_path=UPDATER_DBUS_PATH): @@ -242,10 +243,10 @@ class UpdateManagerDbusController(dbus.service.Object): return self.parent.now_working except Exception as e: logging.error(str(e)) - return False + return self.parent.now_working #apt install -f - @dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='b') + @dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='bs') def FixBrokenDepends(self): try: #处于更新和升级中的话 不进行更新 @@ -255,9 +256,10 @@ class UpdateManagerDbusController(dbus.service.Object): else: logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' FixBrokenDepends ...') self.parent.start_fix_broken() - return True - except Exception: - return False + return True,self.MOTHOD_RETURN_SUCCESS + except Exception as e: + logging.error(str(e)) + return False,str(e) #dpkg configure -a @dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='b') @@ -270,9 +272,10 @@ class UpdateManagerDbusController(dbus.service.Object): else: logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' FixIncompleteInstall ...') self.parent.start_fix_incomplete() - return True - except Exception: - return False + return True,self.MOTHOD_RETURN_SUCCESS + except Exception as e: + logging.error(str(e)) + return False,str(e) #更新的dbus @dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='bs',sender_keyword='sender') @@ -287,7 +290,7 @@ class UpdateManagerDbusController(dbus.service.Object): logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' UpdateDetect sender:%s...',sender_name) self._check_prohibit_user(sender_name) self.parent.start_update() - return True,'success' + return True,self.MOTHOD_RETURN_SUCCESS except Exception as e: logging.error(str(e)) return False,str(e) @@ -341,7 +344,7 @@ class UpdateManagerDbusController(dbus.service.Object): self._check_prohibit_user(sender_name) logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistUpgradeAll and not_resolver:%r...',not_resolver) self.parent.start_install(InstallBackend.MODE_INSTALL_ALL,not_resolver) - return True,'success' + return True,self.MOTHOD_RETURN_SUCCESS except Exception as e: logging.info(str(e)) return False,str(e) @@ -361,11 +364,37 @@ class UpdateManagerDbusController(dbus.service.Object): self._check_prohibit_user(sender_name) logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistUpgradeSystem and not_resolver:%r...',not_resolver) self.parent.start_install(InstallBackend.MODE_INSTALL_SYSTEM,not_resolver) - return True,'success' + return True,self.MOTHOD_RETURN_SUCCESS except Exception as e: logging.error(False, str(e)) return (False, str(e)) + # #卸载包 + # @dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='as',out_signature='bs',sender_keyword='sender') + # def PurgePackagesOnly(self,_purge_list, sender=None): + # try: + # sender_name = get_proc_from_dbus_name(sender) + # logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistPurgePackages Sender:%s and purge list is:%s...',sender_name,_purge_list) + # (status, details) = PolicyKit_Authority(get_source_name_from_enum(sender_name)+_(" requires authentication to uninstall software packages."), sender) + # if not status: + # return False,details + + # purge_list = [str(pkg) for pkg in _purge_list] + + # # 处于更新和升级中的话 不进行升级 + # if self.parent.now_working != InstallBackend.ACTION_DEFUALT_STATUS: + # self.PurgePackagesFinished(False,_("Other tasks are being updated and upgraded, please uninstall them later."),'') + # logging.warning('PurgePackages In the process of updating or Upgrading...') + # return False,'PurgePackages In the process of updating or Upgrading...' + # else: + # self._check_prohibit_user(sender_name) + + # self.parent.start_purge_pkgs(purge_list) + # return True,self.MOTHOD_RETURN_SUCCESS + # except Exception as e: + # logging.error(str(e)) + # return False,str(e) + #卸载包 @dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='asss',out_signature='bs',sender_keyword='sender') def PurgePackages(self,_purge_list,cur_user,user_lang = '', sender=None): @@ -381,7 +410,7 @@ class UpdateManagerDbusController(dbus.service.Object): #合法性的校验 if input_lang == None or input_lang == '': logging.info("The incoming language is Illegal...") - return self.parent.now_working + return False,"The incoming language is Illegal..." #处于更新和升级中的话 不进行更新 if input_lang != local_language or input_lang != local_lang: @@ -415,7 +444,7 @@ class UpdateManagerDbusController(dbus.service.Object): self._check_prohibit_user(sender_name) self.parent.start_purge_pkgs(purge_list) - return True,'success' + return True,self.MOTHOD_RETURN_SUCCESS except Exception as e: logging.error(str(e)) return False,str(e) @@ -447,7 +476,7 @@ class UpdateManagerDbusController(dbus.service.Object): # 安装本地deb包 - @dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ssbbs',out_signature='b',sender_keyword='sender') + @dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ssbbs',out_signature='bs',sender_keyword='sender') def InstallDebFile(self,source = "unKnown", path = "", _check_local_dep = False, _auto_satisfy = False, user_lang = '', sender=None): try: #当传入为空时 直接返回 @@ -461,7 +490,7 @@ class UpdateManagerDbusController(dbus.service.Object): #合法性的校验 if input_lang == None or input_lang == '': logging.info("The incoming language is Illegal...") - return self.parent.now_working + return False,"The incoming language is Illegal..." #处于更新和升级中的话 不进行更新 if input_lang != local_language or input_lang != local_lang: @@ -481,23 +510,23 @@ class UpdateManagerDbusController(dbus.service.Object): check_local_dep,auto_satisfy,user_lang,sender_name) logging.info("Will install: %s.",path) self.parent.start_deb_install(deb_path, _check_local_dep, _auto_satisfy, source, sender) - return True + return True,self.MOTHOD_RETURN_SUCCESS except Exception as e: logging.error(str(e)) - return (False) + return False,str(e) # commitpackages - @dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='as',out_signature='b',sender_keyword='sender') + @dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='as',out_signature='bs',sender_keyword='sender') def InstallPackages(self, pkg_list = [], sender=None): try: sender_name = get_proc_from_dbus_name(sender) self._check_prohibit_user(sender_name) logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InstallPackages : [%s], InstallPackages sender: %s .', ", ".join(list(pkg_list)), sender_name) self.parent.start_back_upgrade(pkg_list) + return True,self.MOTHOD_RETURN_SUCCESS except Exception as e: logging.error(str(e)) return (False) - return True #更新的dbus @dbus.service.method(UPDATER_DBUS_INTERFACE,out_signature='bs',sender_keyword='sender') diff --git a/backend/data/system-updater-coverable.conf b/backend/data/system-updater-coverable.conf index aa976a2..f03d938 100644 --- a/backend/data/system-updater-coverable.conf +++ b/backend/data/system-updater-coverable.conf @@ -1,3 +1,4 @@ +#此配置文件内的所有配置项,在新装时都会被替换掉 [SystemStatusCover] close_source_filter = False priority_upgrade_restart = True