From 377f0212c7309be4332014956b846ac782b0dad3 Mon Sep 17 00:00:00 2001 From: luoxueyi Date: Thu, 28 Jul 2022 16:31:48 +0800 Subject: [PATCH 1/3] mavis quit uu --- backend/SystemUpdater/Core/utils.py | 17 +++++++++++++---- backend/SystemUpdater/UpdateManager.py | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/SystemUpdater/Core/utils.py b/backend/SystemUpdater/Core/utils.py index 6fff806..bbec68e 100644 --- a/backend/SystemUpdater/Core/utils.py +++ b/backend/SystemUpdater/Core/utils.py @@ -692,10 +692,19 @@ def whether_to_quit_uu(): if 'SUB_PROJECT_CODENAME' not in osreleasedict.keys(): osreleasedict.update({'SUB_PROJECT_CODENAME':''}) if 'PROJECT_CODENAME' in osreleasedict: - if osreleasedict['PROJECT_CODENAME']=='V10SP1-edu': - if 'SUB_PROJECT_CODENAME' in osreleasedict: - if osreleasedict['SUB_PROJECT_CODENAME']=='mavis': - return False + if osreleasedict['PROJECT_CODENAME']=='V10SP1-edu': + if 'SUB_PROJECT_CODENAME' in osreleasedict: + if osreleasedict['SUB_PROJECT_CODENAME']=='mavis': + return False + else: + logging.info("SUB_PROJECT_CODENAME != mavis") + else: + logging.info("no SUB_PROJECT_CODENAME") + else: + logging.info("PROJECT_CODENAME != V10SP1-edu") + else: + logging.info("no PROJECT_CODENAME") + return True def get_proc_from_dbus_name(dbus_name, bus=None): diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 06a9b4f..397130c 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -194,7 +194,7 @@ class UpdateManager(): resolver_backend.start(upgrade_content) else: if not_resolver == True: - if upgrade_mode == InstallBackend.MODE_INSTALL_SINGLE and whether_to_quit_uu: + if whether_to_quit_uu(): kill_process(self.RUN_UNATTENDED_UPGRADE) install_backend = get_backend(self, InstallBackend.ACTION_INSTALL,upgrade_mode) install_backend.start(upgrade_content) From b76acea3da2825fa98cdefffc6c4d4f39ea1de8b Mon Sep 17 00:00:00 2001 From: luoxueyi Date: Fri, 29 Jul 2022 09:57:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/Core/Database.py | 11 +++++++---- backend/SystemUpdater/UpdateManagerDbus.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/backend/SystemUpdater/Core/Database.py b/backend/SystemUpdater/Core/Database.py index 333d17b..0be3280 100644 --- a/backend/SystemUpdater/Core/Database.py +++ b/backend/SystemUpdater/Core/Database.py @@ -259,8 +259,7 @@ class Sqlite3Server(object): InstallInfos.update({"status":status}) InstallInfos.update({"errorCode":str(error_string+" "+error_desc)}) self.window_main.collector.Upgrade_Process_Msg("finish-install", InstallInfos.copy()) - # 软件商店获取中文名 - appname_cn = self.get_cn_appname(str(pkgname)) + # 软件商店获取中文名insert_into_displayr(pkgname)) #FIXME: 临时方案 PHP PHPSeverSend(_send_log = self.window_main.configs_uncover.getWithDefault("SystemStatus", "upload_upgrade_log", False), _appname=pkgname, _appversion=pkgversion, _statue=status, _errorcode="10000100") try: @@ -523,9 +522,13 @@ class Sqlite3Server(object): logging.error(_("Failed to initialize the database: %s"), str(e)) return '' - + def insert_upgrade_history(self, caller): + caller_list = ['kylin-unattended-upgrade'] + if caller not in caller_list: + logging.warninng() + def listtojsonstr(lists): import json jsonfile = json.dumps(lists) - return jsonfile \ No newline at end of file + return jsonfile diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index cfcc725..9a0c8e2 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -1070,6 +1070,17 @@ class UpdateManagerDbusControllerUtils(dbus.service.Object): logging.info("All silent upgrade: %s.",pkglist) return pkglist + # 提供插入更新历史的接口 + @dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='', out_signature='', sender_keyword='sender') + def InsertUpgradeHistory(self, sender=None): + logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InsertUpgradeHistory Parsed silent upgrade ...') + try: + sender_name = get_proc_from_dbus_name(sender) + logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' Call InsertUpgradeHistory from %s.', sender_name) + self.parent.sqlite3_server.insert_upgrade_history(sender_name) + pass + except Exception as e: + logging.error("InsertUpgradeHistory Failed: %s" % str(e), exc_info=True) WRITABLE_PROPERTIES = () From fe55a422e4d476b65bb1e61331a801e5fea75d5b Mon Sep 17 00:00:00 2001 From: lxy Date: Fri, 29 Jul 2022 15:43:22 +0800 Subject: [PATCH 3/3] add method: InsertUpgradeHistory --- backend/SystemUpdater/Core/Database.py | 36 ++++++++++++++++++++-- backend/SystemUpdater/UpdateManagerDbus.py | 15 ++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/backend/SystemUpdater/Core/Database.py b/backend/SystemUpdater/Core/Database.py index 0be3280..5481d93 100644 --- a/backend/SystemUpdater/Core/Database.py +++ b/backend/SystemUpdater/Core/Database.py @@ -9,6 +9,7 @@ import sqlite3 import logging import datetime from gettext import gettext as _ +from sys import exec_prefix from SystemUpdater.Core.DataAcquisition import PHPSeverSend from SystemUpdater.Core.UpdaterConfigParser import UpgradeConfig @@ -522,11 +523,40 @@ class Sqlite3Server(object): logging.error(_("Failed to initialize the database: %s"), str(e)) return '' - def insert_upgrade_history(self, caller): - caller_list = ['kylin-unattended-upgrade'] + def insert_upgrade_history(self, args, caller): + caller_list = ['kylin-unattended-upgrade', "d-feet"] if caller not in caller_list: - logging.warninng() + logging.warning("Caller \" %s \": Operation without permission...", caller) + return False + # {"appname":GLib.Variant("s", "kylin-system-updater"), "version":GLib.Variant("s", "0.0")} + # "description":GLib.Variant("s", "Update Manager for Kylin"), "date":GLib.Variant("s", "2022-07-27 15:23:51") + # "status":GLib.Variant("s", "failed"), "keyword":GLib.Variant("s", "1") + # "errorcode":GLib.Variant("s", "System upgrade is complete. "), "appname_cn":GLib.Variant("s", "音乐") + upgrade_info = {} + try: + for it in args: + upgrade_info[str(it)] = str(args[str(it)]) + logging.info("upgrade_info: %s", upgrade_info) + #self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr, appname_cn) + if "appname" in upgrade_info.keys() and "version" in upgrade_info.keys() \ + and "description" in upgrade_info.keys() \ + and "date" in upgrade_info.keys() \ + and "status" in upgrade_info.keys() \ + and "keyword" in upgrade_info.keys() \ + and "errorcode" in upgrade_info.keys() \ + and "appname_cn" in upgrade_info.keys() : + self.insert_into_updateinfo( upgrade_info["appname"], upgrade_info["version"], \ + upgrade_info["description"], \ + upgrade_info["date"], \ + upgrade_info["status"], \ + upgrade_info["keyword"], \ + upgrade_info["errorcode"], \ + upgrade_info["appname_cn"] ) + except Exception as e: + logging.error(e) + return False + return True def listtojsonstr(lists): import json diff --git a/backend/SystemUpdater/UpdateManagerDbus.py b/backend/SystemUpdater/UpdateManagerDbus.py index 9a0c8e2..d10ce42 100755 --- a/backend/SystemUpdater/UpdateManagerDbus.py +++ b/backend/SystemUpdater/UpdateManagerDbus.py @@ -1071,16 +1071,21 @@ class UpdateManagerDbusControllerUtils(dbus.service.Object): return pkglist # 提供插入更新历史的接口 - @dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='', out_signature='', sender_keyword='sender') - def InsertUpgradeHistory(self, sender=None): - logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InsertUpgradeHistory Parsed silent upgrade ...') + @dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='a{sv}', out_signature='b', sender_keyword='sender') + def InsertUpgradeHistory(self, arg = {}, sender=None): try: + # {"appname":GLib.Variant("s", "kylin-system-updater"), "version":GLib.Variant("s", "string value")} + # "description":GLib.Variant("s", "Update Manager for Kylin"), "date":GLib.Variant("s", "2022-07-27 15:23:51") + # "status":GLib.Variant("s", "failed"), "keyword":GLib.Variant("s", "1") + # "errorcode":GLib.Variant("s", "System upgrade is complete. "), "appname_cn":GLib.Variant("s", "音乐") sender_name = get_proc_from_dbus_name(sender) logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' Call InsertUpgradeHistory from %s.', sender_name) - self.parent.sqlite3_server.insert_upgrade_history(sender_name) - pass + if not self.parent.sqlite3_server.insert_upgrade_history(arg, sender_name) : + return False except Exception as e: logging.error("InsertUpgradeHistory Failed: %s" % str(e), exc_info=True) + return False + return True WRITABLE_PROPERTIES = ()