fixed filling in empty update_level in calculate.env

master 3.7.2.2
idziubenko 3 years ago
parent d99c45dda3
commit 9157e7061d

@ -1634,6 +1634,7 @@ class Update(MethodsInterface):
return None return None
return level - int(self.clVars.Get("update.cl_update_level")) return level - int(self.clVars.Get("update.cl_update_level"))
def check_current_binhost(self, binhost_url): def check_current_binhost(self, binhost_url):
""" """
Проверка текущего сервера обновлений на валидность Проверка текущего сервера обновлений на валидность
@ -1641,9 +1642,9 @@ class Update(MethodsInterface):
if not binhost_url in self.binhosts_data.binhost_list: if not binhost_url in self.binhosts_data.binhost_list:
raise UpdateError(_("Current binhost is absent in list of update servers")) raise UpdateError(_("Current binhost is absent in list of update servers"))
binhost = self.binhosts_data.get_binhost(binhost_url) binhost = self.binhosts_data.get_binhost(binhost_url)
cur_level_valid = self.check_current_level()
if binhost.valid and not binhost.outdated and not binhost.downgraded \ if binhost.valid and not binhost.outdated and not binhost.downgraded \
and self.is_binhost_level_valid(binhost): and (not cur_level_valid or self.is_binhost_level_valid(binhost)):
if binhost.status == self.binhosts_data.BinhostStatus.Success: if binhost.status == self.binhosts_data.BinhostStatus.Success:
self.clVars.Set('update.cl_update_binhost_data', self.clVars.Set('update.cl_update_binhost_data',
[[binhost.host, binhost.data, [[binhost.host, binhost.data,
@ -1651,6 +1652,8 @@ class Update(MethodsInterface):
str(binhost.duration), str(binhost.duration),
str(binhost.level)]], str(binhost.level)]],
force=True) force=True)
if not cur_level_valid:
self.pull_level_from_binhost(binhost)
self.endTask() self.endTask()
else: else:
if not binhost.valid: if not binhost.valid:
@ -1663,16 +1666,13 @@ class Update(MethodsInterface):
raise UpdateError( raise UpdateError(
_("Binary packages on the current binhost {} " _("Binary packages on the current binhost {} "
"are older than local").format(binhost_url)) "are older than local").format(binhost_url))
elif self.check_current_level(): elif not self.is_binhost_level_valid(binhost):
if not self.is_binhost_level_valid(binhost):
# self.stash_binhost(binhost_url) # self.stash_binhost(binhost_url)
self.set_migration_mode(True) self.set_migration_mode(True)
#TODO translate #TODO translate
raise UpdateError( raise UpdateError(
_("Current binhost {} has a wrong update level. Current level: {} Binhost level: {}").\ _("Current binhost {} has a wrong update level. Current level: {} Binhost level: {}").\
format(binhost_url, self.clVars.Get("update.cl_update_level"), binhost.level, )) format(binhost_url, self.clVars.Get("update.cl_update_level"), binhost.level, ))
else:
self.pull_level_from_binhost(binhost)
if self.binhosts_data.gpg: if self.binhosts_data.gpg:
packages_fn = self.clVars.Get('update.cl_update_package_cache') packages_fn = self.clVars.Get('update.cl_update_package_cache')
@ -1889,21 +1889,21 @@ class Update(MethodsInterface):
""" """
Возвращает True если есть значение в calculate.env Возвращает True если есть значение в calculate.env
""" """
return int(self.clVars.Get('cl_update_level')) >= 0 # isdigit - True if it can be interp-ed as a number >=0
return self.clVars.Get('cl_update_level').isdigit()
def pull_level_from_binhost(self, binhost): def pull_level_from_binhost(self, binhost):
self._set_update_level(binhost.level) self._set_update_level(binhost.level)
return True
def _set_update_level(self, level): def _set_update_level(self, level):
if level: if level:
self.clVars.Write('cl_update_level', self.clVars.Write('cl_update_level',
str(level), location="system") str(level), location="system")
return True
else: else:
self.clVars.Write('cl_update_level', self.clVars.Write('cl_update_level',
str(0), location="system") str(0), location="system")
return False
# def stash_binhost(self, binhost_url): # def stash_binhost(self, binhost_url):
# """ # """

@ -1867,7 +1867,7 @@ class VariableClUpdateLevel(Variable):
Используется для выбора зеркала Используется для выбора зеркала
""" """
type = "int" type = "int"
value = "-1" value = ""
class VariableClUpdateUseMigrationHost(Variable): class VariableClUpdateUseMigrationHost(Variable):
""" """

Loading…
Cancel
Save