изменено: pym/update/update.py

изменено:      pym/update/variables/update.py
	изменено:      pym/update/wsdl_update.py
master 3.7.2.34
root 2 years ago
parent 9f69807513
commit 91d05b39e9

@ -377,6 +377,19 @@ class Update(MethodsInterface):
self.endTask(True) self.endTask(True)
return True return True
def checkUrl(self, host, host_urls, repname, dv, git):
url, rpath, revision = (
dv.Select([host_urls, "cl_update_rep_path",
"cl_update_rep_rev"],
where="cl_update_rep_name", eq=repname, limit=1))
if git.checkUrl(url):
working_host = host
return working_host, url, rpath, revision
self.printWARNING(_("Git %s is unavailable, scaning next host") % url)
return None, url, rpath, revision
@variable_module("update") @variable_module("update")
def syncRepositories(self, repname, fallback_sync=False, def syncRepositories(self, repname, fallback_sync=False,
clean_on_error=True): clean_on_error=True):
@ -386,30 +399,39 @@ class Update(MethodsInterface):
dv = self.clVars dv = self.clVars
check_status = dv.GetBool('update.cl_update_check_rep_set') check_status = dv.GetBool('update.cl_update_check_rep_set')
git = self.getGit() git = self.getGit()
saved_host = dv.Get('cl_update_rep_hosting') if 'cl_update_rep_hosting' in dv.allVars else ''
working_host = '' working_host = ''
# проверка необходимости синхронизации других оверлеев # проверка необходимости синхронизации других оверлеев
a = self.clVars.Get("cl_update_inner_other_set") if dv.Get("cl_update_inner_other_set") != 'auto':
if self.clVars.Get("cl_update_inner_other_set") != '': dv.Write("cl_update_other_set", dv.Get("cl_update_inner_other_set"), header="update")
self.clVars.Write("cl_update_other_set", self.clVars.Get("cl_update_inner_other_set"), header="update") dv.Set("cl_update_other_set", dv.Get("cl_update_inner_other_set"))
if 'cl_update_rep_list' in dv.allVars and dv.Get('cl_update_rep_list'): if 'cl_update_rep_list' in dv.allVars and dv.Get('cl_update_rep_list'):
#if dv.Get("cl_update_rep_hosting_choice"): chosen_hosting = dv.Get("cl_update_rep_hosting_choice")
if chosen_hosting:
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
if host == chosen_hosting:
working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git)
if working_host:
break
elif saved_host:
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
if host == saved_host:
working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git)
if working_host:
break
# Берем первый доступный хостинг из списка # Берем первый доступный хостинг из списка
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
url, rpath, revision = (
dv.Select([host_urls, "cl_update_rep_path",
"cl_update_rep_rev"],
where="cl_update_rep_name", eq=repname, limit=1))
if not url or not rpath:
raise UpdateError(_("Configuration variables for repositories "
"are not setup for %s") % host)
if git.checkUrl(url):
working_host = host
break
else:
self.printWARNING(_("Git %s is unavailable, scaning next host") % url)
if not working_host: if not working_host:
for host_urls, host in dv.Get('cl_update_inner_rep_list'):
if chosen_hosting == host:
continue
working_host, url, rpath, revision = self.checkUrl(host, host_urls, repname, dv, git)
if working_host:
break
if not working_host:
dv.Write('cl_update_rep_hosting', ' ')
raise UpdateError(_("Git is unavailable")) raise UpdateError(_("Git is unavailable"))
dv.Write('cl_update_rep_hosting', working_host) if working_host:
dv.Write('cl_update_rep_hosting', working_host)
#--------------DEPRECATED--------------# #--------------DEPRECATED--------------#
else: else:
@ -482,7 +504,6 @@ class Update(MethodsInterface):
"{repname} repository").format( "{repname} repository").format(
repname=repname) + _(": ") + str(e)) repname=repname) + _(": ") + str(e))
finally: finally:
self.clVars.Write('cl_update_rep_hosting', val='', header='update')
if path.exists(rpath_new): if path.exists(rpath_new):
removeDir(rpath_new) removeDir(rpath_new)
else: else:
@ -572,8 +593,6 @@ class Update(MethodsInterface):
for perc in p.progress(): for perc in p.progress():
self.setProgress(perc) self.setProgress(perc)
else: else:
p = process(emerge, "--sync", repname, stderr=STDOUT)
if p.failed():
rpath_old = f"{rpath}_old" rpath_old = f"{rpath}_old"
makeDirectory(rpath_old) makeDirectory(rpath_old)
for root, dirs, files in os.walk(rpath): for root, dirs, files in os.walk(rpath):
@ -582,6 +601,8 @@ class Update(MethodsInterface):
for d in dirs: for d in dirs:
shutil.move(os.path.join(rpath, d), os.path.join(rpath_old, d)) shutil.move(os.path.join(rpath, d), os.path.join(rpath_old, d))
clearDirectory(rpath) clearDirectory(rpath)
p = process(emerge, "--sync", repname, stderr=STDOUT)
if p.failed():
for root, dirs, files in os.walk(rpath_old): for root, dirs, files in os.walk(rpath_old):
for f in files: for f in files:
os.replace(os.path.join(rpath_old, d), os.path.join(rpath, f)) os.replace(os.path.join(rpath_old, d), os.path.join(rpath, f))

@ -177,17 +177,19 @@ class VariableClUpdateInnerRepList(Variable):
value = [] value = []
def get(self): def get(self):
val = self.Get('cl_update_rep_list') def gen():
prev_host = self.Get('cl_update_rep_hosting') val = self.Get('cl_update_rep_list')
if prev_host: prev_host = self.Get('cl_update_rep_hosting')
if prev_host:
for dct in val:
for key, value in dct.items():
if key == prev_host:
yield value, key.lower()
for dct in val: for dct in val:
for key, value in dct.items(): for key, value in dct.items():
if key == prev_host: if key != prev_host:
yield value, key yield value, key.lower()
for dct in val: return [x for x in gen()]
for key, value in dct.items():
if key != prev_host:
yield value, key
class VariableClUpdateRepHosting(Variable): class VariableClUpdateRepHosting(Variable):
@ -197,13 +199,16 @@ class VariableClUpdateRepHosting(Variable):
class VariableClUpdateRepHostingChoice(Variable): class VariableClUpdateRepHostingChoice(Variable):
type = "choice" type = "choice"
value = '' value = ''
opt = ["--hosting"]
def init(self): def init(self):
self.label = (_("Hosting name")) self.label = (_("Hosting name"))
self.help = (_("Hosting to download from")) self.help = (_("Hosting to download from"))
def choice(self): def choice(self):
return [x[1] for x in self.Get('cl_update_inner_rep_list')] or ["Calculate"] a = [x[1] for x in self.Get('cl_update_inner_rep_list')]
b = self.Get('cl_update_inner_rep_list')
return [x[1] for x in self.Get('cl_update_inner_rep_list')]
class VariableClUpdateLaymanStorage(Variable): class VariableClUpdateLaymanStorage(Variable):
@ -633,17 +638,17 @@ class VariableClUpdateOtherSet(Variable):
Обновить остальные оверлеи Обновить остальные оверлеи
""" """
type = "bool" type = "bool"
value = "" value = "on"
def get(self): def get(self):
if self.Get('cl_update_inner_other_set'): if self.Get('cl_update_inner_other_set') != 'auto':
return self.Get('cl_update_inner_other_set') return self.Get('cl_update_inner_other_set')
return self.value return self.value
class VariableClUpdateInnerOtherSet(Variable): class VariableClUpdateInnerOtherSet(Variable):
type = "bool" type = "bool3"
value = 'on' value = Variable.Auto
metavalue = 'ON/OFF' metavalue = 'ON/OFF'
opt = ["-o", "--update-other"] opt = ["-o", "--update-other"]

@ -69,11 +69,9 @@ class Wsdl(WsdlBase):
'cl_update_binhost_stable_opt_set', 'cl_update_binhost_stable_opt_set',
'cl_update_binhost_recheck_set', 'cl_update_binhost_recheck_set',
'cl_update_with_bdeps_opt_set', 'cl_update_with_bdeps_opt_set',
'cl_update_inner_other_set'
), ),
expert=( expert=(
'cl_update_inner_other_set',
'cl_update_sync_only_set', 'cl_update_sync_only_set',
'cl_update_pretend_set', 'cl_update_pretend_set',
'cl_update_binhost_choice', 'cl_update_binhost_choice',

Loading…
Cancel
Save