From 4faa555324bec014c095d7531d27a497c3d9fb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Fri, 2 Nov 2012 09:04:40 +0400 Subject: [PATCH] Add call update world command --- update/cl_update.py | 21 +++++---------------- update/cl_wsdl_update.py | 15 ++++----------- update/variables/__init__.py | 1 + update/variables/action.py | 2 +- update/variables/update.py | 5 +++-- 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/update/cl_update.py b/update/cl_update.py index 327890c..f6f83a6 100644 --- a/update/cl_update.py +++ b/update/cl_update.py @@ -49,21 +49,11 @@ class Update: self.clTempl = None self.clVars = None - def displayTemplatesApplied(self,dirsFiles): - """ - Display templates are applied (--verbose) - """ - self.printSUCCESS(_("The following files were changed")+":") - for nameF in dirsFiles[1]: - nameFile = nameF - if nameFile[:1] != "/": - nameFile = "/" + nameFile - self.printSUCCESS(" "*5 + nameFile) - - def applyTemplatesFromUser(self): + def applyTemplates(self): """Apply templates for user""" if self.clTempl: self.closeClTemplate() + self.clVars.Set("cl_chroot_path","/", True) self.clTempl = ProgressTemplate(self.setProgress,self.clVars, cltObj=False) dirsFiles = self.clTempl.applyTemplates() @@ -71,8 +61,7 @@ class Update: self.printERROR(self.clTempl.getError().strip()) return False else: - if self.verbose: - self.displayTemplatesApplied(dirsFiles) + print dirsFiles return dirsFiles def initVars(self,datavars=None): @@ -84,14 +73,13 @@ class Update: else: self.clVars = datavars - def closeClTemplate(self): + def closeClTemplate(self,*args): if self.clTempl: if self.clTempl.cltObj: self.clTempl.cltObj.closeFiles() self.clTempl.closeFiles() self.clTempl = None - @safetyWrapper(native_errors=(TemplatesError,UpdateError), man_int=__("Update manually interrupted"), post_action=closeClTemplate, @@ -101,4 +89,5 @@ class Update: Creating user profile and userdir """ self.initVars(datavars) + return bool(self.applyTemplates()) return True diff --git a/update/cl_wsdl_update.py b/update/cl_wsdl_update.py index 8f07aed..784dcff 100644 --- a/update/cl_wsdl_update.py +++ b/update/cl_wsdl_update.py @@ -28,7 +28,7 @@ from cl_update import Update,DataVarsUpdate import cl_update from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate from calculate.core.server.decorators import Dec -from calculate.core.server.func import catchExcept +from calculate.core.server.func import catchExcept,commonView core_method = Dec.core_method setLocalTranslate('cl_update3',sys.modules[__name__]) import traceback @@ -58,7 +58,7 @@ class Wsdl: rights=['update']) def update(self, sid, info): return self.callMethod(sid,info,method_name="update", - logicClass=Desktop, + logicClass=Update, method="update") def update_vars(self,dv=None): @@ -66,7 +66,7 @@ class Wsdl: dv = DataVarsUpdate() dv.importUpdate() dv.flIniFile() - dv.Set('cl_action','update',True) + dv.Set('cl_action','sync',True) dv.addGroup(None, normal=('cl_update_world',), next_label=_("Update")) @@ -74,11 +74,4 @@ class Wsdl: @rpc(Integer, ViewParams,_returns = ViewInfo) def update_view (self, sid, params): - dv = self.get_cache(sid,"update","vars") - if not dv: - dv = self.update_vars() - else: - dv.processRefresh() - view = ViewInfo(dv,viewparams=params) - self.set_cache(sid, 'update', "vars",dv,smart=False) - return view + return commonView(self,sid,params,"update") diff --git a/update/variables/__init__.py b/update/variables/__init__.py index 2f4fe7e..d09e050 100644 --- a/update/variables/__init__.py +++ b/update/variables/__init__.py @@ -15,5 +15,6 @@ # limitations under the License. import action +import update section = "update" diff --git a/update/variables/action.py b/update/variables/action.py index 0ec7d63..9fe0c5c 100644 --- a/update/variables/action.py +++ b/update/variables/action.py @@ -30,5 +30,5 @@ class VariableAcUpdateSync(ReadonlyVariable): def get(self): action = self.Get("cl_action") if action in ("sync",): - return "world" + return "up" return "" diff --git a/update/variables/update.py b/update/variables/update.py index 4693f43..33f3763 100644 --- a/update/variables/update.py +++ b/update/variables/update.py @@ -41,11 +41,12 @@ class VariableClUpdateWorld(Variable): type = "choice" opt = ["--world"] value = "" - #syntax = "--{choice}-world" + syntax = "--{choice}-world" metavalue = 'ACTION' def init(self): - self.help = _("'update' - update world, 'rebuild' - rebuild world") + self.help = "'update' - " +_("update world file") + \ + ",\n'rebuild' - "+ _("rebuild world file") self.label = _("World") def choice(self):