From f019452b975db3ece868244407c86826e5bcfef5 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 8 Nov 2022 17:27:40 +0300 Subject: [PATCH] =?UTF-8?q?=09=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE:=20=20=20=20=20=20pym/update/update.py=20=09=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=BE:=20=20=20=20=20=20pym/upda?= =?UTF-8?q?te/variables/update.py=20=09=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE:=20=20=20=20=20=20pym/update/wsdl=5Fupdate.p?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/update/update.py | 20 +++++++++++++++-- pym/update/variables/update.py | 40 ++++++++++++++++++++++++---------- pym/update/wsdl_update.py | 7 +++--- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/pym/update/update.py b/pym/update/update.py index e009328..2fc351e 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -66,7 +66,7 @@ from calculate.lib.utils.files import (getProgPath, STDOUT, removeDir, PercentProgress, process, getRunCommands, readFile, listDirectory, pathJoin, find, FindFileType,quite_unlink, - writeFile, makeDirectory) + writeFile, makeDirectory, clearDirectory) from . import emerge_parser import logging from .emerge_parser import (EmergeParser, EmergeCommand, EmergeError, @@ -388,9 +388,11 @@ class Update(MethodsInterface): git = self.getGit() working_host = '' # проверка необходимости синхронизации других оверлеев - if self.clVars.Get("cl_update_inner_other_set"): + 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 'cl_update_rep_list' in dv.allVars and dv.Get('cl_update_rep_list'): + #if dv.Get("cl_update_rep_hosting_choice"): # Берем первый доступный хостинг из списка for host_urls, host in dv.Get('cl_update_inner_rep_list'): url, rpath, revision = ( @@ -570,8 +572,22 @@ class Update(MethodsInterface): for perc in p.progress(): self.setProgress(perc) else: + rpath_old = f"{rpath}_old" + makeDirectory(rpath_old) + for root, dirs, files in os.walk(rpath): + for f in files: + os.replace(os.join(rpath, d), os.path.join(rpath_old, f)) + for d in dirs: + shutil.move(os.join(rpath, d), os.join(rpath_old, d)) p = process(emerge, "--sync", repname, stderr=STDOUT) if p.failed(): + clearDirectory(rpath) + for root, dirs, files in os.walk(rpath_old): + for f in files: + os.replace(os.join(rpath_old, d), os.path.join(rpath, f)) + for d in dirs: + shutil.move(os.join(rpath_old, d), os.join(rpath, d)) + removeDir(rpath_old) raise UpdateError( _("Failed to update the {rname} repository").format( rname=repname), diff --git a/pym/update/variables/update.py b/pym/update/variables/update.py index 30bd823..e9566a9 100644 --- a/pym/update/variables/update.py +++ b/pym/update/variables/update.py @@ -194,6 +194,18 @@ class VariableClUpdateRepHosting(Variable): value = '' +class VariableClUpdateRepHostingChoice(Variable): + type = "choice" + value = '' + + 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"] + + class VariableClUpdateLaymanStorage(Variable): """ Путь к репозиториям @@ -621,28 +633,31 @@ class VariableClUpdateOtherSet(Variable): Обновить остальные оверлеи """ type = "bool" - value = "on" - - - def init(self): - self.help = _("update other overlays") - self.label = _("Update other overlays") + value = "" def get(self): + if self.Get('cl_update_inner_other_set'): return self.Get('cl_update_inner_other_set') return self.value class VariableClUpdateInnerOtherSet(Variable): - type = "string" - value = '' + type = "bool" + value = 'on' + metavalue = 'ON/OFF' opt = ["-o", "--update-other"] - def get(self): - if self.value in ["on", "off"]: - return True - return False + def init(self): + self.help = _("update other overlays") + self.label = _("Update other overlays") + + + # def get(self): + # if self.value in ["on", "off"]: + # return True + # return False + class VariableClUpdateOtherRepData(ReadonlyTableVariable): """ @@ -1685,6 +1700,7 @@ class VariableClUpdateBinhostChoice(Variable): return self.Get("cl_update_binhost_list") + class VariableClUpdateBinhost(Variable): """ Хост с бинарными обновлениями diff --git a/pym/update/wsdl_update.py b/pym/update/wsdl_update.py index 73703fb..6b19f4d 100644 --- a/pym/update/wsdl_update.py +++ b/pym/update/wsdl_update.py @@ -69,14 +69,15 @@ class Wsdl(WsdlBase): 'cl_update_binhost_stable_opt_set', 'cl_update_binhost_recheck_set', 'cl_update_with_bdeps_opt_set', - 'cl_update_other_set' + + 'cl_update_inner_other_set' ), expert=( - 'cl_update_binhost_choice', 'cl_update_sync_only_set', - 'cl_update_pretend_set', + 'cl_update_binhost_choice', + 'cl_update_rep_hosting_choice', 'cl_update_sync_rep', 'cl_update_emergelist_set', 'cl_update_check_rep_set',