From ffb3028095fc19c5af719dd31197b715f877b175 Mon Sep 17 00:00:00 2001 From: wangsong Date: Fri, 6 May 2022 17:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E5=9C=A8=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=85=B3=E6=9C=BA=E5=AE=89=E8=A3=85=E6=97=B6=E6=89=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/SystemUpdater/UpdateManager.py | 28 ++++++++++++----------- backend/SystemUpdater/backend/__init__.py | 2 ++ backend/data/kylin-system-updater.service | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/backend/SystemUpdater/UpdateManager.py b/backend/SystemUpdater/UpdateManager.py index 4f44d84..32e8747 100644 --- a/backend/SystemUpdater/UpdateManager.py +++ b/backend/SystemUpdater/UpdateManager.py @@ -67,7 +67,7 @@ class UpdateManager(): #失败后重启进行安装的限制次数 目前在自适应升级上面使用 self.retry_limit = self.RETRY_LIMIT_NUM - + #光盘源 self.source_info = UpdateSourceInfo() @@ -906,13 +906,13 @@ class UpdateInstallMode(): from gi.repository import Gio, GLib connection = Gio.bus_get_sync(Gio.BusType.SYSTEM) - # #首先设置systemd默认延长时间为1800 - # bus = dbus.SystemBus() - # logind_proxy = bus.get_object('org.freedesktop.login1', '/org/freedesktop/login1') - # getter_interface = dbus.Interface( - # logind_proxy, - # dbus_interface='org.freedesktop.login1.Manager') - # ret = getter_interface.SetInhibitDelayMaxSec(1800) + #首先设置systemd默认延长时间为1800 + bus = dbus.SystemBus() + logind_proxy = bus.get_object('org.freedesktop.login1', '/org/freedesktop/login1') + getter_interface = dbus.Interface( + logind_proxy, + dbus_interface='org.freedesktop.login1.Manager') + ret = getter_interface.SetInhibitDelayMaxSec(1800) var, fdlist = connection.call_with_unix_fd_list_sync( 'org.freedesktop.login1', '/org/freedesktop/login1', @@ -958,11 +958,6 @@ class UpdateInstallMode(): self._start_install_shutdown() - #只要是关机更新模式就监听抑制关机 - self.inhibit_lock = self._inhibit_sleep() - if self.inhibit_lock == None: - logging.error("Prepare inhibit lock failed...") - self.logind_proxy.connect_to_signal( "PrepareForShutdown", prepare_for_shutdown_handler) @@ -992,3 +987,10 @@ class UpdateInstallMode(): else: logging.info("No need to shutdown install in the normal model...") return 0 + + def get_inhibit_lock(self): + #只要是关机更新模式就监听抑制关机 + if self.inhibit_lock == None: + self.inhibit_lock = self._inhibit_sleep() + if self.inhibit_lock == None: + logging.error("Prepare inhibit lock failed...") diff --git a/backend/SystemUpdater/backend/__init__.py b/backend/SystemUpdater/backend/__init__.py index 53f93cc..398b3bc 100644 --- a/backend/SystemUpdater/backend/__init__.py +++ b/backend/SystemUpdater/backend/__init__.py @@ -642,6 +642,8 @@ class InstallBackend(): #如果下载成功 就标志需要 安装重启 if success == True: + #安装成功的话再获取关机锁 + self.window_main.install_mode.get_inhibit_lock() self.window_main.configs.setValue("InstallMode","manual_install",str(True),True) else: self.window_main.configs.setValue("InstallMode","manual_install",str(False),True) diff --git a/backend/data/kylin-system-updater.service b/backend/data/kylin-system-updater.service index b1ac217..df4c1f2 100644 --- a/backend/data/kylin-system-updater.service +++ b/backend/data/kylin-system-updater.service @@ -7,7 +7,7 @@ Type=dbus Restart=always RestartSec=3 BusName=com.kylin.systemupgrade -ExecStart=/usr/share/kylin-system-updater/kylin-system-updater -n +ExecStart=/usr/share/kylin-system-updater/kylin-system-updater [Install] WantedBy=multi-user.target \ No newline at end of file