fix json load problems
This commit is contained in:
parent
9ca7310c7c
commit
24afa7a094
|
@ -457,7 +457,8 @@ class KylinSystemUpdater:
|
|||
self.update_interface = dbus.Interface(self.update_proxy,dbus_interface='com.kylin.systemupgrade.interface')
|
||||
self.success = False
|
||||
self.whitelist_with_candidate_version = []
|
||||
|
||||
self.group_rec=[]
|
||||
self.single_rec=[]
|
||||
|
||||
def DataBackendCollect(self,updateinfo,json_file):
|
||||
self.data_collect_interface.DataBackendCollect(updateinfo,json_file)
|
||||
|
@ -497,6 +498,10 @@ class KylinSystemUpdater:
|
|||
self.whitelist_with_candidate_version.append((key,row_data['upgrade_list'][key]['new_version']))
|
||||
for key in row_data['install_list'].keys():
|
||||
self.whitelist_with_candidate_version.append((key,row_data['install_list'][key]['new_version']))
|
||||
for key in row_data['group_json'].keys():
|
||||
self.group_rec.append((key,row_data['group_json'][key]['new_version'],row_data['group_json'][key]['changelog']))
|
||||
for key in row_data['single_json'].keys():
|
||||
self.single_rec.append((key,row_data['single_json'][key]['new_version'],row_data['single_json'][key]['changelog']))
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
self.loop.quit()
|
||||
|
@ -2672,15 +2677,67 @@ def main(options, rootdir="/"):
|
|||
release = original_version
|
||||
release = original_version
|
||||
'''
|
||||
date = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
history = {}
|
||||
if res.success and len(res.pkgs) > 0 and res.result_str == "total_install":
|
||||
logging.info("total install")
|
||||
# with open(TIME_STAMP,'w') as f:
|
||||
# f.write(time.time())
|
||||
kylin_system_updater.SetConfigValue("SYSTEM","os_version",release)
|
||||
kylin_system_updater.SetConfigValue("SYSTEM","update_version",original_version)
|
||||
kylin_system_updater.SetConfigValue("SYSTEM","update_version",original_version)
|
||||
for rec in kylin_system_updater.group_rec:
|
||||
history.update({"appname":rec[0]+"(unattended upgrade)"})
|
||||
history.update({"version":rec[1]})
|
||||
history.update({"description":""})
|
||||
history.update({"date":date})
|
||||
history.update({"status":"success"})
|
||||
history.update({"keyword":""})
|
||||
history.update({"errorcode":""})
|
||||
history.update({"appname_cn":""})
|
||||
history.update({"status_cn":"成功"})
|
||||
history.update({"changelog":rec[2]})
|
||||
kylin_system_updater.InsertUpgradeHistory(history)
|
||||
for rec in kylin_system_updater.single_rec:
|
||||
history.update({"appname":rec[0]+"(unattended upgrade)"})
|
||||
history.update({"version":rec[1]})
|
||||
history.update({"description":""})
|
||||
history.update({"date":date})
|
||||
history.update({"status":"success"})
|
||||
history.update({"keyword":""})
|
||||
history.update({"errorcode":""})
|
||||
history.update({"appname_cn":""})
|
||||
history.update({"status_cn":"成功"})
|
||||
history.update({"changelog":rec[2]})
|
||||
kylin_system_updater.InsertUpgradeHistory(history)
|
||||
elif not res.success:
|
||||
for rec in kylin_system_updater.group_rec:
|
||||
history.update({"appname":rec[0]+"(unattended upgrade"})
|
||||
history.update({"version":rec[1]})
|
||||
history.update({"description":""})
|
||||
history.update({"date":date})
|
||||
history.update({"status":"failed"})
|
||||
history.update({"keyword":""})
|
||||
history.update({"errorcode":""})
|
||||
history.update({"appname_cn":""})
|
||||
history.update({"status_cn":"失败"})
|
||||
history.update({"changelog":rec[2]})
|
||||
kylin_system_updater.InsertUpgradeHistory(history)
|
||||
for rec in kylin_system_updater.single_rec:
|
||||
history.update({"appname":rec[0]+"(unattended upgrade"})
|
||||
history.update({"version":rec[1]})
|
||||
history.update({"description":""})
|
||||
history.update({"date":date})
|
||||
history.update({"status":"failed"})
|
||||
history.update({"keyword":""})
|
||||
history.update({"errorcode":""})
|
||||
history.update({"appname_cn":""})
|
||||
history.update({"status_cn":"失败"})
|
||||
history.update({"changelog":rec[2]})
|
||||
kylin_system_updater.InsertUpgradeHistory(history)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
if 'PROJECT_CODENAME' in os_release_info:
|
||||
if os_release_info['PROJECT_CODENAME']=='V10SP1-edu':
|
||||
if 'SUB_PROJECT_CODENAME' in os_release_info:
|
||||
|
@ -3006,6 +3063,7 @@ def run(options, # type: Options
|
|||
# cache.clear()
|
||||
|
||||
pkg_install_success = True
|
||||
install_result = ''
|
||||
if len(pkgs_to_upgrade) > 0:
|
||||
if 'PROJECT_CODENAME' in os_release_info:
|
||||
if os_release_info['PROJECT_CODENAME']=='V10SP1-edu':
|
||||
|
@ -3045,12 +3103,12 @@ def run(options, # type: Options
|
|||
if pkg_install_success:
|
||||
clean_downloaded_packages(fetcher)
|
||||
kylin_system_updater.CheckRebootRequired("unattended-upgrades")
|
||||
install_result = ''
|
||||
logging.debug("pkg number:%d,pkg in whitelist number:%d"%(len(pkgs),len(white_list_with_version)))
|
||||
if len(pkgs) == len(white_list_with_version):
|
||||
install_result = "total_install"
|
||||
else:
|
||||
install_result = "partial_install"
|
||||
|
||||
logging.debug("pkg number:%d,pkg in whitelist number:%d"%(len(pkgs),len(white_list_with_version)))
|
||||
if len(pkgs) == len(white_list_with_version):
|
||||
install_result = "total_install"
|
||||
else:
|
||||
install_result = "partial_install"
|
||||
logging.debug("install result:%s"%install_result)
|
||||
return UnattendedUpgradesResult(pkg_install_success,
|
||||
install_result,
|
||||
|
|
Loading…
Reference in New Issue