diff --git a/pym/update/update.py b/pym/update/update.py index 2161787..9503b7c 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -1634,6 +1634,7 @@ class Update(MethodsInterface): return None return level - int(self.clVars.Get("update.cl_update_level")) + def check_current_binhost(self, binhost_url): """ Проверка текущего сервера обновлений на валидность @@ -1641,9 +1642,9 @@ class Update(MethodsInterface): if not binhost_url in self.binhosts_data.binhost_list: raise UpdateError(_("Current binhost is absent in list of update servers")) 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 \ - 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: self.clVars.Set('update.cl_update_binhost_data', [[binhost.host, binhost.data, @@ -1651,6 +1652,8 @@ class Update(MethodsInterface): str(binhost.duration), str(binhost.level)]], force=True) + if not cur_level_valid: + self.pull_level_from_binhost(binhost) self.endTask() else: if not binhost.valid: @@ -1663,16 +1666,13 @@ class Update(MethodsInterface): raise UpdateError( _("Binary packages on the current binhost {} " "are older than local").format(binhost_url)) - elif self.check_current_level(): - if not self.is_binhost_level_valid(binhost): + elif not self.is_binhost_level_valid(binhost): # self.stash_binhost(binhost_url) self.set_migration_mode(True) #TODO translate raise UpdateError( _("Current binhost {} has a wrong update level. Current 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: packages_fn = self.clVars.Get('update.cl_update_package_cache') @@ -1889,21 +1889,21 @@ class Update(MethodsInterface): """ Возвращает 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): self._set_update_level(binhost.level) + return True def _set_update_level(self, level): if level: self.clVars.Write('cl_update_level', str(level), location="system") - return True else: self.clVars.Write('cl_update_level', str(0), location="system") - return False # def stash_binhost(self, binhost_url): # """ diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 75994bf..77e3d84 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -1867,7 +1867,7 @@ class VariableClUpdateLevel(Variable): Используется для выбора зеркала """ type = "int" - value = "-1" + value = "" class VariableClUpdateUseMigrationHost(Variable): """