Изменены критерии сортировки серверов обновления

1. по актуальности
2. у актуальных по скорости и свежести
3. у неактуальных по свежести и скорости
master3.4 3.4.5.3
parent bbcec6fbf0
commit 72393cf50f

@ -43,11 +43,13 @@ _ = lambda x: x
setLocalTranslate('cl_update3', sys.modules[__name__]) setLocalTranslate('cl_update3', sys.modules[__name__])
class VariableAcUpdateSync(ReadonlyVariable): class VariableAcUpdateSync(ReadonlyVariable):
""" """
Action variable which has value "up" for package install and Action variable which has value "up" for package install and
install this package install this package
""" """
def get(self): def get(self):
action = self.Get("cl_action") action = self.Get("cl_action")
if action in ("sync",): if action in ("sync",):
@ -55,12 +57,14 @@ class VariableAcUpdateSync(ReadonlyVariable):
return self.Get('cl_update_world') return self.Get('cl_update_world')
return "" return ""
class VariableClUpdateWorldDefault(Variable): class VariableClUpdateWorldDefault(Variable):
""" """
Ad-hoc Ad-hoc
""" """
value = "update" value = "update"
class VariableClUpdateWorld(Variable): class VariableClUpdateWorld(Variable):
type = "choice" type = "choice"
opt = ["--world"] opt = ["--world"]
@ -95,6 +99,7 @@ class VariableClRebuildWorldSet(Variable):
self.help = _("Rebuild world") self.help = _("Rebuild world")
self.label = _("Rebuild world") self.label = _("Rebuild world")
class VariableClUpdateRevSet(Variable): class VariableClUpdateRevSet(Variable):
""" """
List of action update world, rebuild world, List of action update world, rebuild world,
@ -104,14 +109,15 @@ class VariableClUpdateRevSet(Variable):
untrusted = True untrusted = True
value = "on" value = "on"
check_after = ["cl_update_sync_rep", check_after = ["cl_update_sync_rep",
"cl_update_metadata_force", "cl_update_metadata_force",
"cl_update_other_set", "cl_update_other_set",
"cl_update_eixupdate_force"] "cl_update_eixupdate_force"]
def init(self): def init(self):
self.help = _("make a revision update") self.help = _("make a revision update")
self.label = _("Make a revision update") self.label = _("Make a revision update")
class VariableClUpdateRep(Variable): class VariableClUpdateRep(Variable):
""" """
Обновлять репозитории до конкретной ревизии или до последней Обновлять репозитории до конкретной ревизии или до последней
@ -122,6 +128,7 @@ class VariableClUpdateRep(Variable):
def choice(self): def choice(self):
return ["last", "rev"] return ["last", "rev"]
class VariableClUpdateRepData(ReadonlyTableVariable): class VariableClUpdateRepData(ReadonlyTableVariable):
""" """
Информация о репозиториях Информация о репозиториях
@ -131,6 +138,7 @@ class VariableClUpdateRepData(ReadonlyTableVariable):
'cl_update_rep_path', 'cl_update_rep_path',
'cl_update_rep_rev'] 'cl_update_rep_rev']
class VariableClUpdateRepName(Variable): class VariableClUpdateRepName(Variable):
""" """
Список имен используемых репозиториев Список имен используемых репозиториев
@ -138,6 +146,7 @@ class VariableClUpdateRepName(Variable):
type = "list" type = "list"
value = [] value = []
class VariableClUpdateRepUrl(Variable): class VariableClUpdateRepUrl(Variable):
""" """
Список путей до репозиториев Список путей до репозиториев
@ -145,6 +154,7 @@ class VariableClUpdateRepUrl(Variable):
type = "list" type = "list"
value = [] value = []
class VariableClUpdateLaymanConfig(ReadonlyVariable): class VariableClUpdateLaymanConfig(ReadonlyVariable):
""" """
Объект конфига layman Объект конфига layman
@ -157,6 +167,7 @@ class VariableClUpdateLaymanConfig(ReadonlyVariable):
cp.read(path.join(chroot, 'etc/layman/layman.cfg')) cp.read(path.join(chroot, 'etc/layman/layman.cfg'))
return cp return cp
class VariableClUpdateLaymanStorage(Variable): class VariableClUpdateLaymanStorage(Variable):
""" """
Путь к репозиториям layman Путь к репозиториям layman
@ -169,6 +180,7 @@ class VariableClUpdateLaymanStorage(Variable):
res = cp.get('MAIN', self.param_name, fallback=self.fallback_value) res = cp.get('MAIN', self.param_name, fallback=self.fallback_value)
return pathJoin(self.Get('cl_chroot_path'), res) return pathJoin(self.Get('cl_chroot_path'), res)
class VariableClUpdateRepPath(ReadonlyVariable): class VariableClUpdateRepPath(ReadonlyVariable):
""" """
Пути до репозиториев Пути до репозиториев
@ -187,6 +199,7 @@ class VariableClUpdateRepPath(ReadonlyVariable):
yield path.join(chroot_path, self.mapPath[name]) yield path.join(chroot_path, self.mapPath[name])
else: else:
yield path.join(repPath, name) yield path.join(repPath, name)
return list(generatePaths(self.Get('cl_update_rep_name'))) return list(generatePaths(self.Get('cl_update_rep_name')))
@ -212,6 +225,7 @@ class VariableClUpdateRepRev(Variable):
yield cp.get("vcs", repname, fallback=branch) yield cp.get("vcs", repname, fallback=branch)
else: else:
yield branchname yield branchname
return list(generateBranch()) return list(generateBranch())
@ -221,6 +235,7 @@ class VariableClUpdateBranch(Variable):
""" """
value = Git.Reference.Master value = Git.Reference.Master
class VariableClUpdateBranchData(TableVariable): class VariableClUpdateBranchData(TableVariable):
""" """
Выбор веток репозиториев до которых необходимо обновиться Выбор веток репозиториев до которых необходимо обновиться
@ -239,7 +254,8 @@ class VariableClUpdateBranchData(TableVariable):
""" """
Неизвестный оврелей Неизвестный оврелей
""" """
raise VariableError(_("Repository %s not found")%value) raise VariableError(_("Repository %s not found") % value)
class VariableClUpdateBranchRep(ReadonlyVariable): class VariableClUpdateBranchRep(ReadonlyVariable):
""" """
@ -253,6 +269,7 @@ class VariableClUpdateBranchRep(ReadonlyVariable):
def get(self): def get(self):
return self.Get('cl_update_rep_name') return self.Get('cl_update_rep_name')
class VariableClUpdateBinhostData(ReadonlyTableVariable): class VariableClUpdateBinhostData(ReadonlyTableVariable):
""" """
Таблица содержащая Таблица содержащая
@ -292,6 +309,10 @@ class VariableClUpdateBinhostData(ReadonlyTableVariable):
-int(time)) -int(time))
def get_timestamp(self, binhost): def get_timestamp(self, binhost):
"""
Возвращает таймстам полученный от сервера, время доступа,
актуальность (не более 5 суток)
"""
DAY = 60 * 60 * 24 DAY = 60 * 60 * 24
timeout = self.GetInteger('cl_update_binhost_timeout') timeout = self.GetInteger('cl_update_binhost_timeout')
timestamp_file = path.join(binhost, timestamp_file = path.join(binhost,
@ -300,34 +321,57 @@ class VariableClUpdateBinhostData(ReadonlyTableVariable):
t = time.time() t = time.time()
data = urllib2.urlopen(timestamp_file, data = urllib2.urlopen(timestamp_file,
timeout=timeout).read().strip() timeout=timeout).read().strip()
if data.isdigit() and t - int(data) < 5 * DAY: if data.isdigit():
return data, int((time.time() - t)*1000) return (data, int((time.time() - t) * 1000),
t - int(data) < 5 * DAY)
except urllib2.URLError as e: except urllib2.URLError as e:
pass pass
except BaseException as e: except BaseException as e:
if isinstance(e, KeyboardInterrupt): if isinstance(e, KeyboardInterrupt):
raise raise
pass pass
return "", -1 return "", -1, False
def get(self, hr=HumanReadable.No): def get(self, hr=HumanReadable.No):
DAY = 60 * 60 * 24
binhost = self.Get('cl_update_binhost') binhost = self.Get('cl_update_binhost')
recheck = self.GetBool('cl_update_binhost_recheck_set') recheck = self.GetBool('cl_update_binhost_recheck_set')
cur_t = time.time()
def generate_by_timestamp(): def generate_by_timestamp():
for host in self.Get('cl_update_binhost_list'): for host in self.Get('cl_update_binhost_list'):
if host: if host:
ts_content, duration = self.get_timestamp(host) ts_content, duration, good = self.get_timestamp(host)
if ts_content: if ts_content:
yield host, ts_content, str(duration) yield host, ts_content, str(duration), good
if not recheck and binhost: if not recheck and binhost:
ts, t = self.get_timestamp(binhost) ts, t, good = self.get_timestamp(binhost)
if ts: # условие актуальности текущего сервера
if ts and cur_t - int(ts) < 5 * DAY:
data = self.check_binhost(binhost) data = self.check_binhost(binhost)
if data: if data:
return [[binhost, data, str(t)]] return [[binhost, data, str(t)]]
for host, ts, t in sorted(generate_by_timestamp(), for host, ts, t, good in sorted(
key=lambda x: (-int(x[1]), int(x[2]))): generate_by_timestamp(),
# критерий сортировки между серверами
# актуальные сортируются по скорости
# неактульные по timestamp
# актуальность - 5 дней
reverse=True,
key=lambda x: (# приоритетны актуальные (не более 5 дней)
x[3],
# приоритет для неактуальных
# самое свежее
0 if x[3] else int(x[1]),
# приоритет для неактуальных
# самое быстрое
0 if x[3] else -int(x[2]),
# приоритет для актуальных
# самое быстрое
-int(x[2]) if x[3] else 0,
# самое свежее
int(x[1]) if x[3] else 0)):
data = self.check_binhost(host) data = self.check_binhost(host)
if data: if data:
return [[host, data, str(t)]] return [[host, data, str(t)]]
@ -356,7 +400,8 @@ class VariableClUpdateBinhostHost(FieldValue, ReadonlyVariable):
source_variable = "cl_update_binhost_data" source_variable = "cl_update_binhost_data"
column = 0 column = 0
class VariableClUpdateBinhostRevisions(FieldValue,ReadonlyVariable):
class VariableClUpdateBinhostRevisions(FieldValue, ReadonlyVariable):
""" """
Список имен прочих репозиториев Список имен прочих репозиториев
""" """
@ -364,7 +409,8 @@ class VariableClUpdateBinhostRevisions(FieldValue,ReadonlyVariable):
source_variable = "cl_update_binhost_data" source_variable = "cl_update_binhost_data"
column = 1 column = 1
class VariableClUpdateBinhostTime(FieldValue,ReadonlyVariable):
class VariableClUpdateBinhostTime(FieldValue, ReadonlyVariable):
""" """
Список имен прочих репозиториев Список имен прочих репозиториев
""" """
@ -418,7 +464,7 @@ class VariableClUpdateSyncRep(Variable):
def set(self, value): def set(self, value):
orderList = self.rep_name orderList = self.rep_name
return sorted(value, key=lambda x: return sorted(value, key=lambda x:
(orderList.index(x) if x in orderList else -1), reverse=True) (orderList.index(x) if x in orderList else -1), reverse=True)
def get(self): def get(self):
return list(reversed(self.rep_name)) return list(reversed(self.rep_name))
@ -426,6 +472,7 @@ class VariableClUpdateSyncRep(Variable):
def choice(self): def choice(self):
return self.rep_name return self.rep_name
class VariableClUpdateSyncOverlayRep(ReadonlyVariable): class VariableClUpdateSyncOverlayRep(ReadonlyVariable):
""" """
Обновляемые репозитории (исключая portage) Обновляемые репозитории (исключая portage)
@ -435,6 +482,7 @@ class VariableClUpdateSyncOverlayRep(ReadonlyVariable):
def get(self): def get(self):
return filter(lambda x: x != "portage", self.Get('cl_update_sync_rep')) return filter(lambda x: x != "portage", self.Get('cl_update_sync_rep'))
class VariableClUpdateOutdateSet(ReadonlyVariable): class VariableClUpdateOutdateSet(ReadonlyVariable):
""" """
Флаг устанавливаемый в ходе обновления репозиториев, Флаг устанавливаемый в ходе обновления репозиториев,
@ -447,10 +495,11 @@ class VariableClUpdateOutdateSet(ReadonlyVariable):
def get(self): def get(self):
if (self.Get('cl_update_other_set') == 'on' and if (self.Get('cl_update_other_set') == 'on' and
self.Get('cl_update_other_rep_name')): self.Get('cl_update_other_rep_name')):
return "on" return "on"
return "off" return "off"
class VariableClUpdateMetadataForce(Variable): class VariableClUpdateMetadataForce(Variable):
""" """
Принудительное действие с метаданными Принудительное действие с метаданными
@ -460,7 +509,7 @@ class VariableClUpdateMetadataForce(Variable):
opt = ["--update-metadata"] opt = ["--update-metadata"]
syntax = "--{choice}-update-metadata" syntax = "--{choice}-update-metadata"
metavalue = "MODE" metavalue = "MODE"
#untrusted = True # untrusted = True
def init(self): def init(self):
self.help = ("'force' - " + _("force the update ebuilds metadata") + self.help = ("'force' - " + _("force the update ebuilds metadata") +
@ -483,12 +532,13 @@ class VariableClUpdateEgencacheForce(Variable):
opt = ["--egencache"] opt = ["--egencache"]
syntax = "--{choice}-egencache" syntax = "--{choice}-egencache"
metavalue = "MODE" metavalue = "MODE"
#untrusted = True # untrusted = True
def init(self): def init(self):
self.help = ("'force' - " + _("force the update of the overlays cache") + self.help = (
",\n'skip' - " + _("skip the update of the overlays cache") + "'force' - " + _("force the update of the overlays cache") +
",\n'auto' - " + _("update the overlays cache if outdated")) ",\n'skip' - " + _("skip the update of the overlays cache") +
",\n'auto' - " + _("update the overlays cache if outdated"))
self.label = _("Update the overlays cache") self.label = _("Update the overlays cache")
def choice(self): def choice(self):
@ -506,7 +556,7 @@ class VariableClUpdateEixupdateForce(Variable):
opt = ["--eix-update"] opt = ["--eix-update"]
syntax = "--{choice}-eix-update" syntax = "--{choice}-eix-update"
metavalue = "MODE" metavalue = "MODE"
#untrusted = True # untrusted = True
def init(self): def init(self):
self.help = ("'force' - " + _("force the eix cache update") + self.help = ("'force' - " + _("force the eix cache update") +
@ -520,6 +570,7 @@ class VariableClUpdateEixupdateForce(Variable):
("skip", _("Skip")), ("skip", _("Skip")),
("auto", _("If needed"))] ("auto", _("If needed"))]
class VariableClUpdateOtherSet(Variable): class VariableClUpdateOtherSet(Variable):
""" """
Обновить остальные оверлеи Обновить остальные оверлеи
@ -532,6 +583,7 @@ class VariableClUpdateOtherSet(Variable):
self.help = _("update other overlays") self.help = _("update other overlays")
self.label = _("Update other overlays") self.label = _("Update other overlays")
class VariableClUpdateOtherRepData(ReadonlyTableVariable): class VariableClUpdateOtherRepData(ReadonlyTableVariable):
""" """
Информация о прочих репозиториях Информация о прочих репозиториях
@ -558,7 +610,8 @@ class VariableClUpdateOtherRepData(ReadonlyTableVariable):
def get(self, hr=HumanReadable.No): def get(self, hr=HumanReadable.No):
return list(self.generator()) return list(self.generator())
class VariableClUpdateOtherRepName(FieldValue,ReadonlyVariable):
class VariableClUpdateOtherRepName(FieldValue, ReadonlyVariable):
""" """
Список имен прочих репозиториев Список имен прочих репозиториев
""" """
@ -566,7 +619,8 @@ class VariableClUpdateOtherRepName(FieldValue,ReadonlyVariable):
source_variable = "cl_update_other_rep_data" source_variable = "cl_update_other_rep_data"
column = 0 column = 0
class VariableClUpdateOtherRepPath(FieldValue,ReadonlyVariable):
class VariableClUpdateOtherRepPath(FieldValue, ReadonlyVariable):
""" """
Список путей до прочих репозиториев Список путей до прочих репозиториев
""" """
@ -574,6 +628,7 @@ class VariableClUpdateOtherRepPath(FieldValue,ReadonlyVariable):
source_variable = "cl_update_other_rep_data" source_variable = "cl_update_other_rep_data"
column = 1 column = 1
class VariableClUpdateLaymanInstalled(VariableClUpdateLaymanStorage): class VariableClUpdateLaymanInstalled(VariableClUpdateLaymanStorage):
""" """
Путь до файла layman installed.xml Путь до файла layman installed.xml
@ -581,6 +636,7 @@ class VariableClUpdateLaymanInstalled(VariableClUpdateLaymanStorage):
param_name = "installed" param_name = "installed"
fallback_value = "var/lib/layman/installed.xml" fallback_value = "var/lib/layman/installed.xml"
class VariableClUpdateLaymanMake(VariableClUpdateLaymanStorage): class VariableClUpdateLaymanMake(VariableClUpdateLaymanStorage):
""" """
Путь до файла make.conf изменяемого layman`ом Путь до файла make.conf изменяемого layman`ом
@ -588,6 +644,7 @@ class VariableClUpdateLaymanMake(VariableClUpdateLaymanStorage):
param_name = "make_conf" param_name = "make_conf"
fallback_value = "var/lib/layman/make.conf" fallback_value = "var/lib/layman/make.conf"
class VariableClUpdateLaymanConf(VariableClUpdateLaymanStorage): class VariableClUpdateLaymanConf(VariableClUpdateLaymanStorage):
""" """
Путь до конфигурационного файла репозиториев для layman Путь до конфигурационного файла репозиториев для layman
@ -595,6 +652,7 @@ class VariableClUpdateLaymanConf(VariableClUpdateLaymanStorage):
param_name = "repos_conf" param_name = "repos_conf"
fallback_value = "etc/portage/repos.conf/layman.conf" fallback_value = "etc/portage/repos.conf/layman.conf"
class VariableClUpdatePretendSet(Variable): class VariableClUpdatePretendSet(Variable):
""" """
Запустить предварительную проверку на обновления Запустить предварительную проверку на обновления
@ -609,6 +667,7 @@ class VariableClUpdatePretendSet(Variable):
"simply display the list of packages that " "simply display the list of packages that "
"will be installed") "will be installed")
class VariableClUpdateSyncOnlySet(Variable): class VariableClUpdateSyncOnlySet(Variable):
""" """
Не выполнять установку/обновление пакетов при обновлении Не выполнять установку/обновление пакетов при обновлении
@ -630,6 +689,7 @@ class VariableClUpdateSyncOnlySet(Variable):
self.Get('cl_update_eixupdate_force') != "force"): self.Get('cl_update_eixupdate_force') != "force"):
raise VariableError(_("Select at least one sync repository")) raise VariableError(_("Select at least one sync repository"))
class VariableClUpdateWaitAnotherSet(Variable): class VariableClUpdateWaitAnotherSet(Variable):
""" """
Ждать завершения другого процесса обновления Ждать завершения другого процесса обновления
@ -642,6 +702,7 @@ class VariableClUpdateWaitAnotherSet(Variable):
self.label = _("Wait for another update to be complete") self.label = _("Wait for another update to be complete")
self.help = _("wait until the running update is finished") self.help = _("wait until the running update is finished")
class VariableClUpdateProfileStorage(ReadonlyVariable): class VariableClUpdateProfileStorage(ReadonlyVariable):
type = "object" type = "object"
@ -650,10 +711,12 @@ class VariableClUpdateProfileStorage(ReadonlyVariable):
LocalStorage('/var/lib/layman'), LocalStorage('/var/lib/layman'),
CacheStorage('/var/calculate/tmp/update')) CacheStorage('/var/calculate/tmp/update'))
class VariableClUpdateRepHost(Variable): class VariableClUpdateRepHost(Variable):
type = "list" type = "list"
value = ['calculate'] value = ['calculate']
class VariableClUpdateRepHostUrl(Variable): class VariableClUpdateRepHostUrl(Variable):
type = "list" type = "list"
value = ['git://git.calculate.ru/calculate/%s.git'] value = ['git://git.calculate.ru/calculate/%s.git']
@ -674,10 +737,12 @@ class VariableClUpdateProfileDatavars(ReadonlyVariable):
return DataVarsUpdateProfile(path_profile) return DataVarsUpdateProfile(path_profile)
return "" return ""
class VariableClUpdateProfileLinuxFullname(ReadonlyVariable): class VariableClUpdateProfileLinuxFullname(ReadonlyVariable):
""" """
Имя системы в профиле Имя системы в профиле
""" """
def init(self): def init(self):
self.label = _("Distribution name") self.label = _("Distribution name")
@ -692,11 +757,12 @@ class VariableClUpdateProfileLinuxFullname(ReadonlyVariable):
linuxver = dv.Get('os_linux_ver') linuxver = dv.Get('os_linux_ver')
if subname: if subname:
return "%s %s %s" % (linuxname, linuxver, subname) return "%s %s %s" % (linuxname, linuxver, subname)
return "%s %s" %(linuxname,linuxver) return "%s %s" % (linuxname, linuxver)
except DataVarsError as s: except DataVarsError as s:
raise VariableError("Wrong Calculate Linux profile") raise VariableError("Wrong Calculate Linux profile")
return "" return ""
class VariableClUpdateProfileDependData(ReadonlyTableVariable): class VariableClUpdateProfileDependData(ReadonlyTableVariable):
""" """
Зависимые репозитории Зависимые репозитории
@ -717,12 +783,11 @@ class VariableClUpdateProfileDependData(ReadonlyTableVariable):
return match1.group(2).lower() == match2.group(2).lower() return match1.group(2).lower() == match2.group(2).lower()
return False return False
def get(self, hr=HumanReadable.No): def get(self, hr=HumanReadable.No):
dv = self.Get(self.datavars) dv = self.Get(self.datavars)
# TODO: неиспользуемая переменная возможно # TODO: неиспользуемая переменная возможно
# испольуется для инициализации # испольуется для инициализации
#url = self.Get('cl_update_profile_url').lower() # url = self.Get('cl_update_profile_url').lower()
if dv: if dv:
return reversed(zip(dv.Get('cl_update_rep_name'), return reversed(zip(dv.Get('cl_update_rep_name'),
dv.Get('cl_update_rep_url'))) dv.Get('cl_update_rep_url')))
@ -730,13 +795,14 @@ class VariableClUpdateProfileDependData(ReadonlyTableVariable):
setValue = Variable.setValue setValue = Variable.setValue
class VariableClUpdateTemplatesLocate(Variable): class VariableClUpdateTemplatesLocate(Variable):
""" """
Выбранные типы хранилищ шаблонов Выбранные типы хранилищ шаблонов
""" """
type = "choice-list" type = "choice-list"
element = "selecttable" element = "selecttable"
opt = ["-T","--templates"] opt = ["-T", "--templates"]
metavalue = "TEMPLATES" metavalue = "TEMPLATES"
untrusted = True untrusted = True
check_after = ['cl_update_profile_system'] check_after = ['cl_update_profile_system']
@ -754,7 +820,7 @@ class VariableClUpdateTemplatesLocate(Variable):
def init(self): def init(self):
self.label = _("Templates location") self.label = _("Templates location")
self.help = _("select the location for templates %s") \ self.help = _("select the location for templates %s") \
%",".join(self.get()) % ",".join(self.get())
def get(self): def get(self):
dv = self.Get(self.profile_datevars) dv = self.Get(self.profile_datevars)
@ -768,6 +834,7 @@ class VariableClUpdateTemplatesLocate(Variable):
_("%s overlay templates" % x)) _("%s overlay templates" % x))
return map(lambda x: (x, descr(x)), self.get()) return map(lambda x: (x, descr(x)), self.get())
class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable): class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable):
type = "list" type = "list"
source_variable = "cl_update_profile_depend_data" source_variable = "cl_update_profile_depend_data"
@ -776,6 +843,7 @@ class VariableClUpdateProfileDependName(FieldValue, ReadonlyVariable):
def init(self): def init(self):
self.label = _("Name") self.label = _("Name")
class VariableClUpdateProfileDependUrl(FieldValue, ReadonlyVariable): class VariableClUpdateProfileDependUrl(FieldValue, ReadonlyVariable):
type = "list" type = "list"
source_variable = "cl_update_profile_depend_data" source_variable = "cl_update_profile_depend_data"
@ -794,12 +862,14 @@ class VariableClUpdateProfileRepName(ReadonlyVariable):
return dv.Get('cl_update_rep_name') return dv.Get('cl_update_rep_name')
return [] return []
class VariableClUpdateProfileSyncRep(ReadonlyVariable): class VariableClUpdateProfileSyncRep(ReadonlyVariable):
type = "list" type = "list"
def get(self): def get(self):
return list(reversed(self.Get('cl_update_profile_rep_name'))) return list(reversed(self.Get('cl_update_profile_rep_name')))
class VariableClUpdateProfileRepUrl(ReadonlyVariable): class VariableClUpdateProfileRepUrl(ReadonlyVariable):
type = "list" type = "list"
@ -809,10 +879,12 @@ class VariableClUpdateProfileRepUrl(ReadonlyVariable):
return dv.Get('cl_update_rep_url') return dv.Get('cl_update_rep_url')
return [] return []
class VariableClUpdateProfileLinuxVer(ReadonlyVariable): class VariableClUpdateProfileLinuxVer(ReadonlyVariable):
""" """
Имя системы в профиле Имя системы в профиле
""" """
def init(self): def init(self):
self.label = _("System profile version") self.label = _("System profile version")
@ -822,16 +894,19 @@ class VariableClUpdateProfileLinuxVer(ReadonlyVariable):
return dv.Get('os_linux_ver') return dv.Get('os_linux_ver')
return "" return ""
class VariableClUpdateProfileLinuxName(ReadonlyVariable): class VariableClUpdateProfileLinuxName(ReadonlyVariable):
""" """
Имя системы в профиле Имя системы в профиле
""" """
def get(self): def get(self):
dv = self.Get('cl_update_profile_datavars') dv = self.Get('cl_update_profile_datavars')
if dv: if dv:
dv.Get('os_linux_name') dv.Get('os_linux_name')
return "" return ""
class VariableClUpdateProfileUrl(Variable): class VariableClUpdateProfileUrl(Variable):
""" """
URL текущего репозитория URL текущего репозитория
@ -852,7 +927,6 @@ class VariableClUpdateProfileUrl(Variable):
def current_root(self): def current_root(self):
return '/' return '/'
def init(self): def init(self):
self.label = _("Profile repository") self.label = _("Profile repository")
self.help = _("set the profile repository") self.help = _("set the profile repository")
@ -905,7 +979,7 @@ class VariableClUpdateProfileUrl(Variable):
except GitError as e: except GitError as e:
raise VariableError(str(e)) raise VariableError(str(e))
if not self.Get(self.profiles_shortname): if not self.Get(self.profiles_shortname):
raise VariableError(_("Repository %s has no profiles")%value) raise VariableError(_("Repository %s has no profiles") % value)
def get(self): def get(self):
try: try:
@ -922,6 +996,7 @@ class VariableClUpdateProfileUrl(Variable):
pass pass
return self.default_url return self.default_url
class VariableClUpdateProfileRepoName(ReadonlyVariable): class VariableClUpdateProfileRepoName(ReadonlyVariable):
def init(self): def init(self):
self.label = _("Repository name") self.label = _("Repository name")
@ -959,11 +1034,13 @@ class VariableClUpdateProfileBranch(Variable):
def check(self, value): def check(self, value):
pass pass
## TODO: проверка ветки ## TODO: проверка ветки
#try: # try:
# url = self.Get('cl_update_profile_url') # url = self.Get('cl_update_profile_url')
# self.Get('cl_update_profile_storage').get_profiles(url, value) # self.Get('cl_update_profile_storage').get_profiles(url, value)
#except GitError as e: # except GitError as e:
# raise VariableError(str(e))
# raise VariableError(str(e))
class VariableClProfileRepository(ReadonlyVariable): class VariableClProfileRepository(ReadonlyVariable):
@ -1017,6 +1094,7 @@ class VariableClProfileData(ReadonlyTableVariable):
setValue = Variable.setValue setValue = Variable.setValue
class VariableClUpdateProfileRepository(ReadonlyVariable): class VariableClUpdateProfileRepository(ReadonlyVariable):
""" """
Репозиторий из которого будет извлечён список профилей Репозиторий из которого будет извлечён список профилей
@ -1041,10 +1119,12 @@ class VariableClUpdateProfileRepository(ReadonlyVariable):
except GitError: except GitError:
return "" return ""
class VariableClUpdateProfileRepositoryName(ReadonlyVariable): class VariableClUpdateProfileRepositoryName(ReadonlyVariable):
""" """
Название репозитория, из которого будут извлечены профили Название репозитория, из которого будут извлечены профили
""" """
def get(self): def get(self):
rep = self.Get('cl_update_profile_repository') rep = self.Get('cl_update_profile_repository')
if rep: if rep:
@ -1069,6 +1149,7 @@ class VariableClUpdateProfileFullname(FieldValue, ReadonlyVariable):
source_variable = "cl_update_profile_data" source_variable = "cl_update_profile_data"
column = 0 column = 0
class VariableClUpdateProfileShortname(FieldValue, ReadonlyVariable): class VariableClUpdateProfileShortname(FieldValue, ReadonlyVariable):
""" """
Упрощенное название профиля Упрощенное название профиля
@ -1077,6 +1158,7 @@ class VariableClUpdateProfileShortname(FieldValue, ReadonlyVariable):
source_variable = "cl_update_profile_data" source_variable = "cl_update_profile_data"
column = 1 column = 1
class VariableClUpdateProfilePath(FieldValue, ReadonlyVariable): class VariableClUpdateProfilePath(FieldValue, ReadonlyVariable):
""" """
Путь от корня до профиля Путь от корня до профиля
@ -1085,6 +1167,7 @@ class VariableClUpdateProfilePath(FieldValue, ReadonlyVariable):
source_variable = "cl_update_profile_data" source_variable = "cl_update_profile_data"
column = 2 column = 2
class VariableClUpdateProfileArch(FieldValue, ReadonlyVariable): class VariableClUpdateProfileArch(FieldValue, ReadonlyVariable):
""" """
Архитектура профиля Архитектура профиля
@ -1093,6 +1176,7 @@ class VariableClUpdateProfileArch(FieldValue, ReadonlyVariable):
source_variable = "cl_update_profile_data" source_variable = "cl_update_profile_data"
column = 3 column = 3
class VariableClUpdateProfileSystem(Variable): class VariableClUpdateProfileSystem(Variable):
""" """
Профиль системы (симлинк /etc/make.profile') Профиль системы (симлинк /etc/make.profile')
@ -1141,7 +1225,7 @@ class VariableClUpdateProfileSystem(Variable):
raise VariableError( raise VariableError(
_("Overlay %s is not specified " _("Overlay %s is not specified "
"in cl_update_rep_name") % repo_name) "in cl_update_rep_name") % repo_name)
except (DataVarsError,VariableError) as e: except (DataVarsError, VariableError) as e:
if str(e): if str(e):
message = ". " + str(e) message = ". " + str(e)
else: else:
@ -1179,6 +1263,7 @@ class VariableClUpdateProfileSystem(Variable):
return zip(short_name, full_name) return zip(short_name, full_name)
return [] return []
class DataVarsUpdateProfile(SimpleDataVars): class DataVarsUpdateProfile(SimpleDataVars):
""" """
Упрощенная модель переменных для получения данных с удаленного профиля Упрощенная модель переменных для получения данных с удаленного профиля
@ -1188,6 +1273,7 @@ class DataVarsUpdateProfile(SimpleDataVars):
'cl_update_rep_path', 'cl_update_rep_path',
'cl_update_rep_rev', 'cl_update_rep_rev',
'cl_update_branch_name'] 'cl_update_branch_name']
def __init__(self, profile, chroot_path='/', recheck=None): def __init__(self, profile, chroot_path='/', recheck=None):
SimpleDataVars.__init__( SimpleDataVars.__init__(
self, self,
@ -1234,6 +1320,7 @@ class DataVarsUpdateProfile(SimpleDataVars):
def __repr__(self): def __repr__(self):
return "Profile variables" return "Profile variables"
class VariableClUpdateProfileSyncSet(Variable): class VariableClUpdateProfileSyncSet(Variable):
""" """
Синхронизировать репозиторий перед сменой профиля Синхронизировать репозиторий перед сменой профиля
@ -1273,9 +1360,9 @@ class VariableClUpdateAutocheckInterval(Variable):
self.help = _("set interval for the updates checking") self.help = _("set interval for the updates checking")
def choice(self): def choice(self):
return [["6h",_("every six hours")], return [["6h", _("every six hours")],
["12h",_("every twelve hours")], ["12h", _("every twelve hours")],
["1d",_("daily")]] ["1d", _("daily")]]
class VariableClUpdateAutocheckScheduleSet(Variable): class VariableClUpdateAutocheckScheduleSet(Variable):
@ -1298,7 +1385,7 @@ class VariableClUpdateEmergelistSet(Variable):
""" """
type = "bool" type = "bool"
value = "off" value = "off"
opt = ["-e","--emergelist"] opt = ["-e", "--emergelist"]
def init(self): def init(self):
self.label = _("Emerge-like packages list") self.label = _("Emerge-like packages list")
@ -1309,18 +1396,20 @@ class VariableClUpdateKernelVersion(ReadonlyVariable):
""" """
Текущая версия ядра Текущая версия ядра
""" """
def get(self): def get(self):
return process('/bin/uname','-r').read().strip() return process('/bin/uname', '-r').read().strip()
class VariableClUpdateKernelSrcPath(ReadonlyVariable): class VariableClUpdateKernelSrcPath(ReadonlyVariable):
""" """
Каталог содержащий исходный код текущего ядра Каталог содержащий исходный код текущего ядра
""" """
def get(self): def get(self):
kernel_ver = self.Get('cl_update_kernel_version') kernel_ver = self.Get('cl_update_kernel_version')
for template_path in ("/lib/modules/%s/build", for template_path in ("/lib/modules/%s/build",
"/usr/src/linux-%s"): "/usr/src/linux-%s"):
src_path = template_path % kernel_ver src_path = template_path % kernel_ver
if path.exists(src_path): if path.exists(src_path):
if path.islink(src_path): if path.islink(src_path):
@ -1335,6 +1424,7 @@ class VariableClUpdateKernelPkg(ReadonlyVariable):
""" """
Пакет текущего ядра Пакет текущего ядра
""" """
def get(self): def get(self):
src_path = self.Get('cl_update_kernel_src_path') src_path = self.Get('cl_update_kernel_src_path')
if src_path: if src_path:
@ -1409,6 +1499,7 @@ class VariableClUpdateOutdatedKernelSet(ReadonlyVariable):
ui = UpdateInfo(self.parent) ui = UpdateInfo(self.parent)
return "on" if ui.outdated_kernel else "off" return "on" if ui.outdated_kernel else "off"
class VariableClUpdateBinhostList(Variable): class VariableClUpdateBinhostList(Variable):
""" """
Список хостов с бинарными обновлениями Список хостов с бинарными обновлениями
@ -1416,12 +1507,14 @@ class VariableClUpdateBinhostList(Variable):
type = "list" type = "list"
value = ["ftp://ftp.calculate-linux.ru/pub/calculate"] value = ["ftp://ftp.calculate-linux.ru/pub/calculate"]
class VariableClUpdateBinhost(Variable): class VariableClUpdateBinhost(Variable):
""" """
Хост с бинарными обновлениями Хост с бинарными обновлениями
""" """
value = "" value = ""
class VariableClUpdateBinhostRevisionPath(Variable): class VariableClUpdateBinhostRevisionPath(Variable):
""" """
Путь до revisions файлов Путь до revisions файлов
@ -1434,12 +1527,14 @@ class VariableClUpdateBinhostRevisionPath(Variable):
"grp/x/ini.env" "grp/x/ini.env"
] ]
class VariableClUpdateBinhostTimestampPath(Variable): class VariableClUpdateBinhostTimestampPath(Variable):
""" """
Путь до файла timestamp Путь до файла timestamp
""" """
value = "timestamp" value = "timestamp"
class VariableClUpdateBinhostTimeout(Variable): class VariableClUpdateBinhostTimeout(Variable):
""" """
Таймаут на проверку одного binhost Таймаут на проверку одного binhost
@ -1447,6 +1542,7 @@ class VariableClUpdateBinhostTimeout(Variable):
type = "int" type = "int"
value = "5" value = "5"
class VariableClUpdateCheckRepSet(Variable): class VariableClUpdateCheckRepSet(Variable):
""" """
Удлять лишние файлы из репозиториев (например созданные пользователем) Удлять лишние файлы из репозиториев (например созданные пользователем)
@ -1460,6 +1556,7 @@ class VariableClUpdateCheckRepSet(Variable):
self.label = _("Check the repositories integrity") self.label = _("Check the repositories integrity")
self.help = _("check and fix the repositories integrity") self.help = _("check and fix the repositories integrity")
class VariableClUpdateOnedepthSet(Variable): class VariableClUpdateOnedepthSet(Variable):
""" """
Удлять лишние файлы из репозиториев (например созданные пользователем) Удлять лишние файлы из репозиториев (например созданные пользователем)

Loading…
Cancel
Save