add exception catch before removing the timer task

This commit is contained in:
shenyafeng 2022-06-10 14:17:20 +08:00
parent db2c439e4e
commit 1a2fa03e3d
2 changed files with 39 additions and 15 deletions

View File

@ -182,6 +182,8 @@ def ReadOsRelease(file):
osreleasedict.update({ls[0]:ls[1].strip('"')})
except Exception as e:
pass
if 'SUB_PROJECT_CODENAME' not in osreleasedict.keys():
osreleasedict.update({'SUB_PROJECT_CODENAME':''})
return osreleasedict
@ -426,6 +428,7 @@ class KylinSystemUpdater:
self.update_interface = dbus.Interface(self.update_proxy,dbus_interface='com.kylin.systemupgrade.interface')
self.success = False
self.whitelist_with_candidate_version = []
def DataBackendCollect(self,updateinfo,json_file):
self.update_interface.DataBackendCollect(updateinfo,json_file)
@ -628,7 +631,7 @@ class UnattendedUpgradesCache(apt.Cache):
"Unattended-Upgrade::Package-Blacklist")
'''
# logging.info(_("Initial blacklist: %s"), " ".join(self.blacklist))
logging.info("pkg list with version:",whitelist_with_version)
# logging.info("pkg list with version:",whitelist_with_version)
self.whitelist_with_version = whitelist_with_version
self.whitelist = []
self.get_white_list()
@ -811,7 +814,7 @@ class UnattendedUpgradesCache(apt.Cache):
def open(self, progress=None):
apt.Cache.open(self, progress)
# apply pinning generated from unattended-upgrades configuration
self.apply_pinning(self.pinning_from_config())
# self.apply_pinning(self.pinning_from_config())
def adjust_candidate_with_version(self,pkg,version):
@ -2829,7 +2832,10 @@ def run(options, # type: Options
'''
white_list_with_version = kylin_system_updater.whitelist_with_candidate_version#config_manager.ReadListFromFile(WHITE_LIST_FILE_PATH,'AutoUpgrade','upgradelist')
# logging.debug("whitelist from kylin system updater:%s"%("\n".join(white_list_with_version)))
whitelistwithversion = []
for w in white_list_with_version:
whitelistwithversion.append('-'.join(w))
logging.debug("whitelist from kylin system updater:%s"%("\n".join(whitelistwithversion)))
# namelist = []
# namelist_with_version = []

View File

@ -155,6 +155,8 @@ def ReadOsRelease(file):
osreleasedict.update({ls[0]:ls[1].strip('"')})
except Exception as e:
pass
if 'SUB_PROJECT_CODENAME' not in osreleasedict.keys():
osreleasedict.update({'SUB_PROJECT_CODENAME':''})
return osreleasedict
def FindRuningUnattendedUpgrades():
@ -605,28 +607,44 @@ class UnattendedUpgradesShutdown():
self.download_time['m'] = tmpminute
self.download_time_r = convert_time_by_random(self.download_time, DOWNLOAD_RANDOM)
if self.download_job is not None:
self.download_job.remove()
try:
if self.download_job is not None:
self.download_job.remove()
except Exception as e:
logging.error(e)
self.download_job = self.scheduler.add_job(self.timing_download, 'cron', hour=self.download_time_r['h'], minute=self.download_time_r['m'])
else: #close download timing
self.download_job.pause()
try:
self.download_job.pause()
except Exception as e:
logging.error(e)
if autoUpgrade == FeatureSwitch.ON.value and install_mode == InstallMode.TIMING_INSTALL.value: #open install timing
self.install_time['h'] = self.download_time_r['h']
self.install_time['m'] = self.download_time_r['m'] + INTERVAL_DOWN_INSTALL
self.install_time_r = convert_time_by_random(self.install_time, INSTALL_RANDOM)
if self.install_job is not None:
self.install_job.remove()
try:
if self.install_job is not None:
self.install_job.remove()
except Exception as e:
logging.error(e)
self.install_job = self.scheduler.add_job(self.timing_install, 'cron', hour=self.install_time_r['h'], minute=self.install_time_r['m'])
elif install_mode == InstallMode.BEFORE_SHUTDOWN_INSTALL.value:
if self.install_job is not None:
self.install_job.remove()
try:
if self.install_job is not None:
self.install_job.remove()
except Exception as e:
logging.error(e)
else: #close install timing
self.install_job.pause()
try:
self.install_job.pause()
except Exception as e:
logging.error(e)
if self.install_mode == InstallMode.BEFORE_SHUTDOWN_INSTALL.value:
if self.install_job is not None:
self.install_job.remove()
try:
if self.install_job is not None:
self.install_job.remove()
except Exception as e:
logging.error(e)
logging.debug("install job removed,installation will conduct before shutdown")
logging.debug("upgrade time: [%d:%d] [%d:%d] predown[%s] autoupgrade[%s] d-mode[%s] i-mode[%s]",