Merge branch 'backend_manual' of gitlab2.kylin.com:kylin-desktop/update-manager-group/kylin-system-updater into backend_manual

This commit is contained in:
wangsong 2022-05-05 14:58:35 +08:00
commit d9d88c88f5
2 changed files with 54 additions and 10 deletions

View File

@ -202,6 +202,10 @@ class Sqlite3Server(object):
InstallInfos.update({"errorCode":str(error_string+" "+error_desc)})
json_file = json.dumps(InstallInfos.copy())
self.window_main.collector.UpdateMsg("InstallInfos", json_file)
# 系统升级完成 ..判断版本号
if status == "success" and "kylin-update-desktop-system" in pkg_group:
# 更新版本号
self._refresh_system_version()
elif pkg_list:
# 单包更新 # 获取单包数据插入数据库
pkgname = pkg_list.pop(0)
@ -336,6 +340,12 @@ class Sqlite3Server(object):
self.init_sqlit()
self.insert_into_updateinfo(str(i), pkgversion, pkgdescription, timestr, status, "1", errstr)
self.window_main.dbusController.UpdateSqlitSingle(str(i), timestr)
# 系统升级完成 ..判断版本号
if status == "success" and "kylin-update-desktop-system" in pkg_group:
# 更新版本号
self._refresh_system_version()
elif mode == InstallBackend.MODE_INSTALL_SYSTEM: # 全盘升级
self.insert_into_updateinfo(str("Upgrade System"), "", "This is a complete system upgrade, equivalent to the implementation of apt dist-upgrade", timestr, status, "1", errstr)
self.window_main.dbusController.UpdateSqlitSingle(str("Upgrade System"), timestr)
@ -419,6 +429,26 @@ class Sqlite3Server(object):
except Exception as e:
logging.error(str(e))
def _refresh_system_version(self):
try:
#初始化系统版本号:version
version_path = "/etc/kylin-version/kylin-system-version.conf"
if os.path.isfile(version_path):
version = UpgradeConfig(datadir = "/etc/kylin-version/", name = "kylin-system-version.conf").getWithDefault("SYSTEM", "version", " ")
self.ucconfigs.setValue("SYSTEM","version",str(version),True)
version = ""
#初始化系统版本号:kylin_release_id
version_path = "/etc/os-release"
if os.path.isfile(version_path):
with open(version_path, "r+") as f:
lines = f.readlines()
for line in lines:
if "KYLIN_RELEASE_ID" in line:
version = line.split('=')[1]
self.ucconfigs.setValue("SYSTEM","kylin_release_id",str(version),True)
except Exception as e:
logging.error(str(e))
def listtojsonstr(lists):
import json
jsonfile = json.dumps(lists)

View File

@ -230,22 +230,36 @@ class UpdateManagerDbusController(dbus.service.Object):
def SetConfigValue(self,section, option, value):
try:
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' SetConfigValue ...')
if self.parent.configs.has_section(str(section)) and self.parent.configs.has_option(str(section),str(option)):
if self.parent.configs.setValue(str(section), str(option),str(value)) == True:
return True
else:
return False
except Exception:
elif self.parent.sqlite3_server.ucconfigs.has_section(str(section)) and self.parent.sqlite3_server.ucconfigs.has_option(str(section),str(option)):
if self.parent.sqlite3_server.ucconfigs.setValue(str(section), str(option),str(value)) == True:
return True
else:
return False
except Exception as e:
logging.error(e)
return False
#get config value
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ss',out_signature='bs')
def GetConfigValue(self,section, option):
try:
if self.parent.configs.has_section(str(section)) and self.parent.configs.has_option(str(section),str(option)):
value = str(self.parent.configs.get(str(section), str(option)))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+" GetConfigValue section:%s option:%s value:%s ...",section,option,value)
return True,value
except Exception:
logging.error("Error: GetConfigValue section:%s option:%s value:%s",section, option)
elif self.parent.sqlite3_server.ucconfigs.has_section(str(section)) and self.parent.sqlite3_server.ucconfigs.has_option(str(section),str(option)):
value = str(self.parent.sqlite3_server.ucconfigs.get(str(section), str(option)))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+" GetConfigValue section:%s option:%s value:%s ...",section,option,value)
return True,value
else:
logging.warning("Warning: Can't found section:%s option:%s ... ",section, option)
except Exception as e:
logging.error("Error: GetConfigValue section:%s option:%s, %s.",section, option, e)
return False,''
#Remove all downloaded files.