check_change

This commit is contained in:
luoxueyi 2022-10-14 15:20:35 +08:00
parent 18cfb09716
commit da6c96f06a
3 changed files with 68 additions and 49 deletions

View File

@ -17,6 +17,7 @@ class LogInstallProgress(apt.progress.base.InstallProgress):
self.filename=file self.filename=file
self.error_pkg="" self.error_pkg=""
self.errormsg="" self.errormsg=""
# raise Exception("for test!!!")
def error(self,pkg, errormsg): def error(self,pkg, errormsg):
logging.error(("Install mode - dpkg, Install error: %s"), errormsg) logging.error(("Install mode - dpkg, Install error: %s"), errormsg)

View File

@ -639,7 +639,7 @@ class UpdateManager():
if depends.split('_')[0] == debfile.split('_')[0] and depends.split('_')[1] == debfile.split('_')[1] and debfile not in satisfy_list: if depends.split('_')[0] == debfile.split('_')[0] and depends.split('_')[1] == debfile.split('_')[1] and debfile not in satisfy_list:
depends_count += 1 depends_count += 1
satisfy_list.append(debfile) satisfy_list.append(debfile)
if depends_count < len(noSatisfyList): if depends_count < len(noSatisfyList) or depends_count < len(depends_pkg):
#本地依赖不满足 #本地依赖不满足
error_string = str(debname.split("_")[0])+_("dependency is not satisfied")+", ".join(noSatisfyList) error_string = str(debname.split("_")[0])+_("dependency is not satisfied")+", ".join(noSatisfyList)
logging.error(error_string) logging.error(error_string)
@ -687,12 +687,12 @@ class UpdateManager():
# 检查本地破损 # 检查本地破损
try: try:
deb_cache = Cache() deb_cache = Cache()
logging.info("Install deb package, check broken") logging.info("Install deb_package, check broken")
broken_count = deb_cache._depcache.broken_count broken_count = deb_cache._depcache.broken_count
deb = DebPackage(deb_path, deb_cache) debPackage = DebPackage(deb_path, deb_cache)
deb.check(allow_downgrade=True) debPackage.check(allow_downgrade=True)
logging.info("Install deb package, required changes") logging.info("Install deb_package, required changes")
(install, remove, unauth) = deb.required_changes # need in cach (install, remove, unauth) = debPackage.required_changes # need in cach
if broken_count > 0: if broken_count > 0:
self._is_broken = True self._is_broken = True
else : else :
@ -712,7 +712,7 @@ class UpdateManager():
raise UpdateBaseError(ERROR_INSTALL_DEB_BASE) raise UpdateBaseError(ERROR_INSTALL_DEB_BASE)
self._need_downgrade = False self._need_downgrade = False
# 不满足的依赖列表 # 不满足的依赖列表
depends = deb.depends depends = debPackage.depends
self.noSatisfyList = self._gen_noSatisfyList(depends, deb_cache) self.noSatisfyList = self._gen_noSatisfyList(depends, deb_cache)
_list = [] _list = []
# cache是否满足 # cache是否满足
@ -736,8 +736,8 @@ class UpdateManager():
_group_satify = False _group_satify = False
providers = [] providers = []
for or_group in depends: for or_group in depends:
for deb in or_group: for deb_info in or_group:
debname,ver,oper = deb debname,ver,oper = deb_info
if ":" in debname: if ":" in debname:
debname=debname.split(":")[0] debname=debname.split(":")[0]
try: try:

View File

@ -54,6 +54,13 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
self.transaction = None self.transaction = None
def __check_change__(self, _config = None, _section = "", _option = "", _value = ""):
if _config == None:
return False
if _value == _config.getWithDefault(_section,_option,_value," "):
return True
return False
@dbus.service.method(UPDATER_DBUS_INTERFACE, @dbus.service.method(UPDATER_DBUS_INTERFACE,
in_signature="", out_signature="", in_signature="", out_signature="",
sender_keyword="caller_name") sender_keyword="caller_name")
@ -74,13 +81,16 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetPreDownloadState, state is %r, time: %s, sender name: %s .',state,time,sender_name) logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetPreDownloadState, state is %r, time: %s, sender name: %s .',state,time,sender_name)
try: try:
if state: if state:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownload", "on", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "preDownload", "on"):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownloadTime", time, True) self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownload", "on", True)
self.PropertyChanged("preDownload","on") self.PropertyChanged("preDownload","on")
self.PropertyChanged("preDownloadTime",time) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "preDownloadTime", time):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownloadTime", time, True)
self.PropertyChanged("preDownloadTime",time)
else: else:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownload", "off", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "preDownload", "off"):
self.PropertyChanged("preDownload","off") self.parent.uuconfigs.setValue("autoUpgradePolicy", "preDownload", "off", True)
self.PropertyChanged("preDownload","off")
except Exception as e: except Exception as e:
logging.error(str(e)) logging.error(str(e))
return False return False
@ -94,8 +104,9 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetUpdateDays, days: %d , sender:%s .'\ logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetUpdateDays, days: %d , sender:%s .'\
,_days,sender_name) ,_days,sender_name)
try: try:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "updateDays", _days, True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "updateDays", _days):
self.PropertyChanged("updateDays",str(_days)) self.parent.uuconfigs.setValue("autoUpgradePolicy", "updateDays", str(_days), True)
self.PropertyChanged("updateDays",str(_days))
except Exception as e: except Exception as e:
logging.error(str(e)) logging.error(str(e))
return False return False
@ -106,11 +117,12 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
def SetAutoUpgradeRandomRange(self,randomRange,sender=None): def SetAutoUpgradeRandomRange(self,randomRange,sender=None):
_randomRange = str(randomRange) _randomRange = str(randomRange)
sender_name = get_proc_from_dbus_name(sender) sender_name = get_proc_from_dbus_name(sender)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' SetAutoUpgradeRandomRange will be set value %d, sender: %s .',\ logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' SetAutoUpgradeRandomRange will be set value %s, sender: %s .',\
_randomRange,sender_name) _randomRange,sender_name)
try: try:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "randomRange", _randomRange, True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "randomRange", _randomRange):
self.PropertyChanged("randomRange",_randomRange) self.parent.uuconfigs.setValue("autoUpgradePolicy", "randomRange", _randomRange, True)
self.PropertyChanged("randomRange",_randomRange)
except Exception as e: except Exception as e:
logging.error(str(e)) logging.error(str(e))
return True,"success" return True,"success"
@ -125,13 +137,16 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
,_state,_reboot_time,sender_name) ,_state,_reboot_time,sender_name)
try: try:
if _state: if _state:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "automaticReboot", "on", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "automaticReboot", "on"):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "automaticRebootTime", _reboot_time, True) self.parent.uuconfigs.setValue("autoUpgradePolicy", "automaticReboot", "on", True)
self.PropertyChanged("automaticReboot","on") self.PropertyChanged("automaticReboot","on")
self.PropertyChanged("preDownloadTime",_reboot_time) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "automaticRebootTime", _reboot_time):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "automaticRebootTime", _reboot_time, True)
self.PropertyChanged("automaticRebootTime",_reboot_time)
else: else:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "automaticReboot", "off", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "automaticReboot", "off"):
self.PropertyChanged("automaticReboot","off") self.parent.uuconfigs.setValue("autoUpgradePolicy", "automaticReboot", "off", True)
self.PropertyChanged("automaticReboot","off")
except Exception as e: except Exception as e:
logging.error(str(e)) logging.error(str(e))
return False return False
@ -144,15 +159,17 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetAutoUpgradeState, state is %r ...',state) logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetAutoUpgradeState, state is %r ...',state)
try: try:
if state: if state:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "autoUpgradeState", "on", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "autoUpgradeState", "on"):
self.parent.sqlite3_server.insert_into_display("autoupdate_allow", "true") self.parent.uuconfigs.setValue("autoUpgradePolicy", "autoUpgradeState", "on", True)
self.parent.sqlite3_server.insert_into_display("autoupdate_allow", "true")
self.PropertyChanged("autoUpgradeState","on")
self.ButtonStatusChange("autoUpgradeStatus", "true") self.ButtonStatusChange("autoUpgradeStatus", "true")
self.PropertyChanged("autoUpgradeState","on")
else : else :
self.parent.uuconfigs.setValue("autoUpgradePolicy", "autoUpgradeState", "off", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "autoUpgradeState", "off"):
self.parent.sqlite3_server.insert_into_display("autoupdate_allow", "false") self.parent.uuconfigs.setValue("autoUpgradePolicy", "autoUpgradeState", "off", True)
self.parent.sqlite3_server.insert_into_display("autoupdate_allow", "false")
self.PropertyChanged("autoUpgradeState","off")
self.ButtonStatusChange("autoUpgradeStatus", "false") self.ButtonStatusChange("autoUpgradeStatus", "false")
self.PropertyChanged("autoUpgradeState","off")
except Exception as e: except Exception as e:
logging.error(str(e)) logging.error(str(e))
return False return False
@ -165,27 +182,28 @@ class UpgradeStrategiesDbusController(dbus.service.Object):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetAutoUpgradeMode, mode is %s, time is %s ...',mode,_time) logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetAutoUpgradeMode, mode is %s, time is %s ...',mode,_time)
try: try:
if mode == UU_UPGRADE_MODE_AUTOMATIC_DOWNLOAD: if mode == UU_UPGRADE_MODE_AUTOMATIC_DOWNLOAD:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadMode", "timing", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "downloadMode", "timing"):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadTime", str(_time), True) self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadMode", "timing", True)
self.PropertyChanged("downloadMode","timing")
if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "downloadTime", str(_time)):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadTime", str(_time), True)
self.PropertyChanged("downloadTime",str(_time))
self.ButtonStatusChange("autoUpgradeTime", str(_time)) self.ButtonStatusChange("autoUpgradeTime", str(_time))
self.PropertyChanged("downloadMode","timing")
self.PropertyChanged("downloadTime",str(_time))
elif mode == UU_UPGRADE_MODE_AUTOMATIC_INSTALL: elif mode == UU_UPGRADE_MODE_AUTOMATIC_INSTALL:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "installMode", "timing", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "installMode", "timing"):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "installTime", str(_time), True) self.parent.uuconfigs.setValue("autoUpgradePolicy", "installMode", "timing", True)
self.PropertyChanged("installMode","timing")
self.PropertyChanged("installMode","timing") if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "installTime", str(_time)):
self.PropertyChanged("installTime",str(_time)) self.parent.uuconfigs.setValue("autoUpgradePolicy", "installTime", str(_time), True)
self.PropertyChanged("installTime",str(_time))
elif mode == UU_UPGRADE_MODE_BEFORE_SHUTDOWN: elif mode == UU_UPGRADE_MODE_BEFORE_SHUTDOWN:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "installMode", "bshutdown", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "installTime", "bshutdown"):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "installMode", "bshutdown", True)
self.PropertyChanged("installMode","bshutdown") self.PropertyChanged("installMode","bshutdown")
elif mode == UU_UPGRADE_MODE_MANUAL: elif mode == UU_UPGRADE_MODE_MANUAL:
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadMode", "manual", True) if not self.__check_change__(self.parent.uuconfigs, "autoUpgradePolicy", "downloadMode", "manual"):
self.parent.uuconfigs.setValue("autoUpgradePolicy", "downloadMode", "manual", True)
self.PropertyChanged("downloadMode","manual") self.PropertyChanged("downloadMode","manual")
except Exception as e: except Exception as e:
logging.error(str(e)) logging.error(str(e))
return False return False