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

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

@ -377,6 +377,19 @@ class Update(MethodsInterface):
self.endTask(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")
def syncRepositories(self, repname, fallback_sync=False,
clean_on_error=True):
@ -386,30 +399,39 @@ class Update(MethodsInterface):
dv = self.clVars
check_status = dv.GetBool('update.cl_update_check_rep_set')
git = self.getGit()
saved_host = dv.Get('cl_update_rep_hosting') if 'cl_update_rep_hosting' in dv.allVars else ''
working_host = ''
# проверка необходимости синхронизации других оверлеев
a = self.clVars.Get("cl_update_inner_other_set")
if self.clVars.Get("cl_update_inner_other_set") != '':
self.clVars.Write("cl_update_other_set", self.clVars.Get("cl_update_inner_other_set"), header="update")
if dv.Get("cl_update_inner_other_set") != 'auto':
dv.Write("cl_update_other_set", dv.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 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:
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"))
dv.Write('cl_update_rep_hosting', working_host)
if working_host:
dv.Write('cl_update_rep_hosting', working_host)
#--------------DEPRECATED--------------#
else:
@ -482,7 +504,6 @@ class Update(MethodsInterface):
"{repname} repository").format(
repname=repname) + _(": ") + str(e))
finally:
self.clVars.Write('cl_update_rep_hosting', val='', header='update')
if path.exists(rpath_new):
removeDir(rpath_new)
else:
@ -572,8 +593,6 @@ class Update(MethodsInterface):
for perc in p.progress():
self.setProgress(perc)
else:
p = process(emerge, "--sync", repname, stderr=STDOUT)
if p.failed():
rpath_old = f"{rpath}_old"
makeDirectory(rpath_old)
for root, dirs, files in os.walk(rpath):
@ -582,6 +601,8 @@ class Update(MethodsInterface):
for d in dirs:
shutil.move(os.path.join(rpath, d), os.path.join(rpath_old, d))
clearDirectory(rpath)
p = process(emerge, "--sync", repname, stderr=STDOUT)
if p.failed():
for root, dirs, files in os.walk(rpath_old):
for f in files:
os.replace(os.path.join(rpath_old, d), os.path.join(rpath, f))

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

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

Loading…
Cancel
Save