|
|
|
@ -1501,18 +1501,16 @@ class Update(MethodsInterface):
|
|
|
|
|
|
|
|
|
|
class Reason():
|
|
|
|
|
Success = 0
|
|
|
|
|
LevelWrong = 1
|
|
|
|
|
BadSign = 2
|
|
|
|
|
Outdated = 3
|
|
|
|
|
BadSign = 1
|
|
|
|
|
Outdated = 2
|
|
|
|
|
LevelWrong = 3
|
|
|
|
|
Skip = 4
|
|
|
|
|
Updating = 5
|
|
|
|
|
WrongBinhost = 6
|
|
|
|
|
BadEnv = 7
|
|
|
|
|
EnvNotFound = 8
|
|
|
|
|
SkipSlower = 9
|
|
|
|
|
UnknownError = 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnknownError = 10
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def humanReadable(reason):
|
|
|
|
@ -1528,7 +1526,7 @@ class Update(MethodsInterface):
|
|
|
|
|
Update.Reason.SkipSlower: "",
|
|
|
|
|
Update.Reason.Success: "",
|
|
|
|
|
#TODO formulate better
|
|
|
|
|
# Update.Reason.LevelWrong: "FAILED (binhost level is wrong)"
|
|
|
|
|
Update.Reason.LevelWrong: "FAILED (binhost level is low)"
|
|
|
|
|
}.get(reason,reason)
|
|
|
|
|
|
|
|
|
|
def _get_binhost_logger(self):
|
|
|
|
@ -1590,6 +1588,8 @@ class Update(MethodsInterface):
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
# SUCCESS
|
|
|
|
|
if self.compare_update_level(binhost.level) < 0:
|
|
|
|
|
reason = self.Reason.LevelWrong
|
|
|
|
|
if not binhost.downgraded or stabilization:
|
|
|
|
|
host = "-> %s" % host
|
|
|
|
|
reason = self.Reason.Success
|
|
|
|
@ -1613,7 +1613,10 @@ class Update(MethodsInterface):
|
|
|
|
|
timestamp=binhost.timestamp,
|
|
|
|
|
reason=Update.Reason.humanReadable(reason)))
|
|
|
|
|
if not retval:
|
|
|
|
|
if actual_reason is self.Reason.BadSign:
|
|
|
|
|
if actual_reason is self.Reason.LevelWrong:
|
|
|
|
|
#TODO translate
|
|
|
|
|
raise UpdateError(_("Failed to find the reliable server with appropriate level"))
|
|
|
|
|
elif actual_reason is self.Reason.BadSign:
|
|
|
|
|
raise UpdateError(_("Failed to find the reliable server with appropriate updates"))
|
|
|
|
|
elif actual_reason in (self.Reason.Outdated,
|
|
|
|
|
self.Reason.Skip,
|
|
|
|
@ -1680,7 +1683,8 @@ class Update(MethodsInterface):
|
|
|
|
|
"are older than local").format(binhost_url))
|
|
|
|
|
elif not ignore_level and not self.is_binhost_level_valid(binhost):
|
|
|
|
|
# self.stash_binhost(binhost_url)
|
|
|
|
|
self.set_migration_mode(True)
|
|
|
|
|
if self.compare_update_level(binhost.level) > 0:
|
|
|
|
|
self.set_migration_mode(True)
|
|
|
|
|
#TODO translate
|
|
|
|
|
raise UpdateError(
|
|
|
|
|
_("Current binhost {} has a wrong update level. Current level: {} Binhost level: {}").\
|
|
|
|
@ -1737,19 +1741,31 @@ class Update(MethodsInterface):
|
|
|
|
|
retval or Variable.EmptyTable, force=True)
|
|
|
|
|
|
|
|
|
|
if not ignore_level:
|
|
|
|
|
best_binhost_level = int(self.clVars.Get("update.cl_update_binhost_level")[0])
|
|
|
|
|
|
|
|
|
|
best_binhost_level = int(sorted(self.clVars.Get("update.cl_update_binhost_level"), key=int)[-1])
|
|
|
|
|
# int(self.clVars.Get("update.cl_update_binhost_level")[0])
|
|
|
|
|
|
|
|
|
|
if not current_level_is_valid:
|
|
|
|
|
self._set_update_level(best_binhost_level)
|
|
|
|
|
|
|
|
|
|
elif self.compare_update_level(best_binhost_level) != 0:
|
|
|
|
|
self.set_migration_mode(True)
|
|
|
|
|
#TODO reformulate, add translation
|
|
|
|
|
raise UpdateError(_("Update server's level is higher than local level"))
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
cmpr = self.compare_update_level(best_binhost_level)
|
|
|
|
|
if cmpr > 0:
|
|
|
|
|
self.set_migration_mode(True)
|
|
|
|
|
#TODO reformulate, add translation
|
|
|
|
|
raise UpdateError(_("Current level: {} Binhosts highest level: {}".\
|
|
|
|
|
format(self.clVars.Get("update.cl_update_level"), best_binhost_level)))
|
|
|
|
|
if cmpr < 0:
|
|
|
|
|
# self.clVars.Delete('update.cl_update_binhost_host', location="system")
|
|
|
|
|
#self.clVars.Get("update.cl_update_binhost_host")
|
|
|
|
|
self.delete_binhost()
|
|
|
|
|
# raise UpdateError(_("Failed to find binhost with level equal or higher than local level"))
|
|
|
|
|
return False
|
|
|
|
|
self.endTask()
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
#нужен так как detect_best_binhost не essential, ошибка не останавливает
|
|
|
|
|
def interrupt_on_no_leveled_binhost(self):
|
|
|
|
|
raise UpdateError(_("Failed to find binhost with level equal or higher than local level"))
|
|
|
|
|
|
|
|
|
|
def set_migration_mode(self, val=True):
|
|
|
|
|
val_to_write = Variable.On if val else Variable.Off
|
|
|
|
|
# self.clVars.Write("cl_update_use_migration_host", val_to_write, location="system")
|
|
|
|
@ -1848,24 +1864,6 @@ class Update(MethodsInterface):
|
|
|
|
|
self.printWARNING(str(e))
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
# #TODO rename
|
|
|
|
|
# def action_to_do_when_migr_is_set(self):
|
|
|
|
|
# print("DEBUG")
|
|
|
|
|
# dv = self.clVars
|
|
|
|
|
# git = self.getGit()
|
|
|
|
|
# repname = "calculate"#TODO check if there's a var for this
|
|
|
|
|
# url, rpath, revision = (
|
|
|
|
|
# dv.Select(["cl_update_rep_url", "cl_update_rep_path",
|
|
|
|
|
# "cl_update_rep_rev"],
|
|
|
|
|
# where="cl_update_rep_name", eq=repname, limit=1))
|
|
|
|
|
# ref_type = git.reference_type(rpath, revision)
|
|
|
|
|
# tag_cr = git.getCommit(rpath, revision)
|
|
|
|
|
# cr = git.getCurrentCommit(rpath)
|
|
|
|
|
# if ref_type == Git.Reference.Branch:
|
|
|
|
|
# pass #TODO
|
|
|
|
|
|
|
|
|
|
# return True
|
|
|
|
|
|
|
|
|
|
def save_portage_state_hash(self):
|
|
|
|
|
"""
|
|
|
|
|
Сохранить состояние
|
|
|
|
|