移植更改apt限速接口

update完成信号推迟至源过滤完成
This commit is contained in:
luoxueyi 2021-10-30 16:11:37 +08:00
parent f4e8db7a00
commit b3ebb0123d
4 changed files with 45 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import time
from gettext import gettext as _
from SystemUpdater.backend import DownloadBackend as downb
from SystemUpdater.Core.Database import MODE_UPGRADE_SINGLE
from aptdaemon.enums import get_status_string_from_enum
import apt_pkg
GROUPS_PKG_NAME = 'kylin-update-desktop-config'
@ -104,8 +105,10 @@ class UpdateManager():
return
else:
upgrade_list = []
trans_status = get_status_string_from_enum('status-finished')
if self.update_list != None:
upgrade_list = self.update_list.local_upgrade_data.upgrade_groups + self.update_list.local_upgrade_data.single_pkgs
self.dbusController.UpdateDetectStatusChanged(100,'status-finished')
#发送更新升级列表完成的标志
self.dbusController.UpdateDetectFinished(_success,upgrade_list,header,desc)
#检查安装完成之后需要重启吗

View File

@ -1,4 +1,5 @@
#!/usr/bin/python3
import os
import dbus
import dbus.service
import logging
@ -228,6 +229,35 @@ class UpdateManagerDbusController(dbus.service.Object):
times -= 1
return True
#
# dbus接口改变apt下载速度
#
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='sb')
def set_downloadspeed_max(self, speed, set):
if set:
with open("/etc/apt/apt.conf.d/80apt-download", "w+") as f:
text = f.write("Acquire::http::Dl-Limit" + " \"" + "%s" % str(speed) + "\";\n")
text = f.write("Acquire::https::Dl-Limit" + " \"" + "%s" % str(speed) + "\";\n")
return True
else:
if os.path.exists("/etc/apt/apt.conf.d/80apt-download"):
os.remove("/etc/apt/apt.conf.d/80apt-download")
return False
else:
return False
#
# dbus接口获取apt下载速度
#
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='bs')
def get_downloadspeed_limit_value(self):
try:
f = open("/etc/apt/apt.conf.d/80apt-download", "r")
value = f.readline().split()
return True, int(value[1][1:-2])
except:
return False, 0
#更新进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='is')
def UpdateDetectStatusChanged(self,progress,status):
@ -282,3 +312,5 @@ class UpdateManagerDbusController(dbus.service.Object):
def UpdateSqlitSingle(self, appname, date):
logging.info(COLORLOG_PREFIX + "emit" + COLORLOG_SUFFIX +" UpdateSqlitSingle: [ %s ]: date: %s .",\
appname, date)

View File

@ -167,8 +167,9 @@ class InstallBackendAptdaemon(InstallBackend):
if progress == 101:
return
self.trans_progress = progress
if action == self.ACTION_UPDATE:
self.window_main.dbusController.UpdateDetectStatusChanged(self.trans_progress,self.trans_status)
if action == self.ACTION_UPDATE: # 更新进度100后推迟发出100%的信号 -- 等待源过滤完成
if progress != 100:
self.window_main.dbusController.UpdateDetectStatusChanged(self.trans_progress,self.trans_status)
else:
if progress >= 50 and action != self.ACTION_DOWNLOADONLY:
LockedPreventShutdown()
@ -181,8 +182,9 @@ class InstallBackendAptdaemon(InstallBackend):
#转化词条
self.trans_status = get_status_string_from_enum(status)
if action == self.ACTION_UPDATE:
self.window_main.dbusController.UpdateDetectStatusChanged(self.trans_progress,self.trans_status)
if action == self.ACTION_UPDATE: # 更新进度100后推迟发出100%的信号 -- 等待源过滤完成
if self.trans_progress != 100:
self.window_main.dbusController.UpdateDetectStatusChanged(self.trans_progress,self.trans_status)
elif action == self.ACTION_INSTALL and action == self.ACTION_INSTALL_DEB:
#升级的时候发送状态信号时需要上传更新组信息self.upgrade_groups_list
upgrade_content = self.now_upgrade.upgrade_groups+self.now_upgrade.single_pkgs

View File

@ -15,6 +15,7 @@ from SystemUpdater.Core.utils import (
unLockedEnableShutdown,
check_free_space
)
from aptdaemon.enums import get_status_string_from_enum
from ..Core.Database import MODE_DEFAULT_STATUS,MODE_UPGRADE_PARTIAL,MODE_UPGRADE_ALL,MODE_UPGRADE_SYSTEM,MODE_UPGRADE_SINGLE
class NowUpgradePara:
@ -318,13 +319,16 @@ class InstallBackend():
self.window_main.dbusController.UpdateInstallFinished(success,upgrade_content,error_string,error_desc)
elif action == self.ACTION_UPDATE:
self.window_main.is_updating = False
trans_status = get_status_string_from_enum('status-finished')
if success:
#开始生成列表
self.window_main.start_available()
elif error_string or error_desc:
self.window_main.dbusController.UpdateDetectStatusChanged(100,trans_status)
logging.warning(error_string + error_desc)
self.window_main.dbusController.UpdateDetectFinished(success,[],error_string,error_desc)
else:
self.window_main.dbusController.UpdateDetectStatusChanged(100,trans_status)
self.window_main.dbusController.UpdateDetectFinished(success,[],'','')
elif action == self.ACTION_DOWNLOADONLY:
self.window_main.is_upgrading = False