Merge branch 'backend_dev' into 'dev_test'
Backend dev See merge request kylin-desktop/update-manager-group/kylin-system-updater!180
This commit is contained in:
commit
8999a61808
|
@ -25,7 +25,7 @@ LOCALTIDFILE = "tidfile.conf"
|
|||
MSGSNDDIR = "/var/lib/kylin-system-updater/sendinfos/"
|
||||
|
||||
class UpdateMsgCollector():
|
||||
def __init__(self, manager):
|
||||
def __init__(self, manager=None):
|
||||
self.UploadMessage = {}
|
||||
self.PackageInfo = {}
|
||||
self.waitSendList = []
|
||||
|
@ -110,6 +110,7 @@ class FormatConvert():
|
|||
|
||||
def dictConvertJson(self, dict_msg):
|
||||
#字典转换为json格式字符串
|
||||
json_file = ''
|
||||
try:
|
||||
json_file = json.dumps(dict_msg)
|
||||
except JSONDecodeError as e:
|
||||
|
@ -118,6 +119,7 @@ class FormatConvert():
|
|||
|
||||
def JsonConvertDict(self, json_file):
|
||||
# json格式字符串转换为字典
|
||||
dict_file = {}
|
||||
try:
|
||||
dict_file = json.loads(json_file)
|
||||
except JSONDecodeError as e:
|
||||
|
@ -170,7 +172,8 @@ class MessageSend():
|
|||
self.collector = UpdateMsgCollector()
|
||||
else:
|
||||
self.collector = DataCollector
|
||||
self.ReadFromFile("/var/lib/kylin-system-updater/sendinfos/testMsg.json")
|
||||
# self._ReadFromFile("/var/lib/kylin-system-updater/sendinfos/testMsg.json")
|
||||
# self._TimedTransmission()
|
||||
|
||||
def MsgSendToServer(self, UploadMessage, PackageInfo, encodeMsg):
|
||||
daqbus = dbus.SystemBus()
|
||||
|
@ -180,6 +183,18 @@ class MessageSend():
|
|||
except DBusException as e:
|
||||
logging.error(str(e))
|
||||
# 调用发送接口
|
||||
# PackageInfo = ("{\"messageType\":\"testDataa\",\"packageName\":\"testPack1\",\"tid\":\"HSx9qTy1TK3J06DRq7pkeTXptNEbVrDqq08yre+OLtE=\"}")
|
||||
# UploadMessage = ("{\"createTimeStamp\":\"2021-12-21 16:12:04.587\",\"myInt\":2}")
|
||||
# encodeMsg = ("fvlIx/KXjDIe3cbc1GMrs1FPRvqVBCt0LnrI1DSKYPc48e0pHPrkIwrSWISjrdu2Q7SqvlmrN9O3aGDKHBAyOovEtUPKKC18adfBQ6vDalhmHkHbrRhFwRrhDJ07PzTl8Lkw+hfW6eSAJ11LWqe00cNRRKgttfBM9IsHPJ82310KEwD3gieMVRwq1Zb9Ztc3hjP7mY0IhntffhRKnzou32A+dh8YT3B0jqQkEuMA2bOftEmDslKrspYSdV13Dj1QlPixiM6eF3G4sLSvcNwSwTG43e5eeqoWrsF0SE4hJUrLS/stGgX+2BabwZ9aX1Bsi+SQB+ZQy2uq5WEZcJO83w==")
|
||||
# print(PackageInfo)
|
||||
# PackageInfo = self.collector.convertor.JsonConvertDict(PackageInfo)
|
||||
# print(PackageInfo)
|
||||
# PackageInfo = self.collector.convertor.dictConvertJson(PackageInfo)
|
||||
# print(PackageInfo)
|
||||
# UploadMessage = self.collector.convertor.JsonConvertDict(UploadMessage)
|
||||
# print(UploadMessage)
|
||||
# UploadMessage = self.collector.convertor.dictConvertJson(UploadMessage)
|
||||
# print(UploadMessage)
|
||||
try:
|
||||
retval,retid = daqinterface.UploadMessage(PackageInfo, UploadMessage, encodeMsg)
|
||||
except AttributeError:
|
||||
|
@ -209,7 +224,7 @@ class MessageSend():
|
|||
result = "The createTimeStamp field of UploadedMessage is abnormal"
|
||||
logging.info("Sent Status: false - packageName: %s : result: %s.", PackageInfo['packageName'], result)
|
||||
# 上传失败写入本地json
|
||||
if retval != self.ERR_NO_LOACLTID:
|
||||
if retval != self.ERR_NO_LOACLTID or retval == self.ERR_NO_LOACLTID:
|
||||
self.WriteToJson(PackageInfo['messageType'], json_PackageInfo, json_UploadMessage, encodeMsg)
|
||||
elif retval == 0:
|
||||
result = "Send to server success"
|
||||
|
@ -258,13 +273,65 @@ class MessageSend():
|
|||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
|
||||
def ReadFromFile(self, json_path):
|
||||
def _TimedTransmission(self, file_path = MSGSNDDIR):
|
||||
classify_list = [name for name in os.listdir(file_path) if name.endswith(".json")]
|
||||
for f in classify_list:
|
||||
# 循环发送每一个文件
|
||||
self._ReadFromFile(os.path.join(file_path, f))
|
||||
|
||||
def _ReadFromFile(self, json_path):
|
||||
new_lines = []
|
||||
# 从本地文件读取
|
||||
if not os.path.exists(json_path):
|
||||
return
|
||||
# with open(json_path, "w") as f:
|
||||
# while True:
|
||||
# line =
|
||||
with open(json_path, "r+") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# file is empty and path is exit -> remove file
|
||||
if len(lines) == 0 and os.path.exists(json_path):
|
||||
os.remove(json_path)
|
||||
return
|
||||
|
||||
#send installinfo or updateinfo
|
||||
for line in lines:
|
||||
(retval,retid) = self._file_send_server(line)
|
||||
if retval != 0: # success
|
||||
new_lines.append(line)
|
||||
if os.path.exists(json_path):
|
||||
os.remove(json_path)
|
||||
if len(new_lines) != 0:
|
||||
with open(json_path, "w+") as f:
|
||||
for line in lines:
|
||||
f.write(line)
|
||||
|
||||
def _file_send_server(self, json):
|
||||
UploadMessage = {}
|
||||
PackageInfo = {}
|
||||
encodeMsg = ''
|
||||
dict_msg = self.collector.convertor.JsonConvertDict(json)
|
||||
if 'UploadMessage' in dict_msg.keys():
|
||||
UploadMessage = dict_msg['UploadMessage']
|
||||
UploadMessage = self.collector.convertor.dictConvertJson(UploadMessage)
|
||||
if 'PackageInfo' in dict_msg.keys():
|
||||
PackageInfo = dict_msg['PackageInfo']
|
||||
PackageInfo = self.collector.convertor.dictConvertJson(PackageInfo)
|
||||
if 'encodeMsg' in dict_msg.keys():
|
||||
encodeMsg = str(dict_msg['encodeMsg'])
|
||||
if len(UploadMessage) == 0 or len(PackageInfo) == 0 or encodeMsg == '':
|
||||
logging.error("Msg error")
|
||||
return 6, ''
|
||||
daqbus = dbus.SystemBus()
|
||||
try:
|
||||
daqobj = daqbus.get_object('com.kylin.daq', '/com/kylin/daq')
|
||||
daqinterface = dbus.Interface(daqobj, dbus_interface='com.kylin.daq.interface')
|
||||
except DBusException as e:
|
||||
logging.error(str(e))
|
||||
try:
|
||||
retval,retid = daqinterface.UploadMessage(PackageInfo, UploadMessage, encodeMsg)
|
||||
except AttributeError:
|
||||
logging.error("Call UploadMessage: Attribute Error.")
|
||||
return (retval,retid)
|
||||
|
||||
|
||||
class UniqueKey():
|
||||
keyvalue = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FR\
|
||||
|
@ -302,4 +369,4 @@ def get_east_8_time():
|
|||
if __name__ == "__name__":
|
||||
# 执行定时发送
|
||||
ms = MessageSend()
|
||||
ms.ReadFromFile("/var/lib/kylin-system-updater/sendinfos/testMsg.json")
|
||||
ms._ReadFromFile("/var/lib/kylin-system-updater/sendinfos/testMsg.json")
|
|
@ -82,7 +82,7 @@ class UpdateManager():
|
|||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
#进行升级的操作
|
||||
#进行修复破损的包的操作 apt install -f
|
||||
def start_fix_broken(self):
|
||||
try:
|
||||
fix_backend = get_backend(self, InstallBackend.ACTION_FIX_BROKEN)
|
||||
|
@ -90,7 +90,7 @@ class UpdateManager():
|
|||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
#进行升级的操作
|
||||
#进行 dpkg --configure
|
||||
def start_fix_incomplete(self):
|
||||
try:
|
||||
fix_backend = get_backend(self, InstallBackend.ACTION_FIX_INCOMPLETE)
|
||||
|
|
|
@ -471,7 +471,7 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
#查询解决依赖 信号
|
||||
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='bbasasasss')
|
||||
def UpdateDependResloveStatus(self, resolver_status, remove_status,remove_pkgs,pkg_raw_description,delete_desc,error_string='',error_desc=''):
|
||||
logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" UpdateDependResloveStatus:resolver_status = %r , resolver_status = %r , remove_pkgs = %a,pkg_raw_description = %s ,delete_desc = %s,error_string = %s , error_desc = %s ",\
|
||||
logging.info(COLORLOG_PREFIX + "Emitting" + COLORLOG_SUFFIX +" UpdateDependResloveStatus:resolver_status = %r , remove_status = %r , remove_pkgs = %a,pkg_raw_description = %s ,delete_desc = %s,error_string = %s , error_desc = %s ",\
|
||||
resolver_status,remove_status,remove_pkgs,pkg_raw_description,delete_desc,error_string,error_desc)
|
||||
|
||||
#查询dist-upgrade解决依赖
|
||||
|
@ -527,7 +527,7 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='s', out_signature='b', sender_keyword='sender')
|
||||
def InstallSnap(self, path, sender=None):
|
||||
|
||||
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+" InstallSnap Install Path = %s...",path)
|
||||
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+" Install Snap Packages(%s)...",path)
|
||||
try:
|
||||
status= subprocess.getstatusoutput("snap install " +path+" --dangerous")
|
||||
except Exception as e:
|
||||
|
|
|
@ -84,7 +84,7 @@ if __name__ == "__main__":
|
|||
|
||||
app = UpdateManager(options)
|
||||
|
||||
#当出现安装过程中异常的重启时 直接开机直接进行修复操作
|
||||
#当出现安装过程中异常的重启时 开机直接进行修复操作
|
||||
if app.configs.getWithDefault("SystemStatus", "isabnormalreboot", False) == True:
|
||||
app.start_update()
|
||||
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
kylin-system-updater (1.3.2kord) v101; urgency=medium
|
||||
|
||||
* BUG: 无
|
||||
* 需求号: 无
|
||||
* 其他改动说明: 修改与旧版本控制面板的冲突
|
||||
* 其他改动影响域:系统更新插件
|
||||
|
||||
-- luoxueyi <luoxueyi@kylinos.cn> Thu, 23 Dec 2021 16:44:11 +0800
|
||||
|
||||
kylin-system-updater (1.3.1kord) v101; urgency=medium
|
||||
|
||||
* BUG: wu
|
||||
* BUG: 无
|
||||
* 需求号: 无
|
||||
* 其他改动说明: 无
|
||||
* 其他改动影响域:系统更新
|
||||
* 其他改动说明: 修复点击全部升级后执行更新检测的问题
|
||||
* 其他改动影响域:系统更新全部升级
|
||||
|
||||
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 21 Dec 2021 17:07:57 +0800
|
||||
|
||||
|
|
Loading…
Reference in New Issue