Add call update world command

master3.1.6
parent 9ce1fac11f
commit 4faa555324

@ -49,21 +49,11 @@ class Update:
self.clTempl = None self.clTempl = None
self.clVars = None self.clVars = None
def displayTemplatesApplied(self,dirsFiles): def applyTemplates(self):
"""
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):
"""Apply templates for user""" """Apply templates for user"""
if self.clTempl: if self.clTempl:
self.closeClTemplate() self.closeClTemplate()
self.clVars.Set("cl_chroot_path","/", True)
self.clTempl = ProgressTemplate(self.setProgress,self.clVars, self.clTempl = ProgressTemplate(self.setProgress,self.clVars,
cltObj=False) cltObj=False)
dirsFiles = self.clTempl.applyTemplates() dirsFiles = self.clTempl.applyTemplates()
@ -71,8 +61,7 @@ class Update:
self.printERROR(self.clTempl.getError().strip()) self.printERROR(self.clTempl.getError().strip())
return False return False
else: else:
if self.verbose: print dirsFiles
self.displayTemplatesApplied(dirsFiles)
return dirsFiles return dirsFiles
def initVars(self,datavars=None): def initVars(self,datavars=None):
@ -84,14 +73,13 @@ class Update:
else: else:
self.clVars = datavars self.clVars = datavars
def closeClTemplate(self): def closeClTemplate(self,*args):
if self.clTempl: if self.clTempl:
if self.clTempl.cltObj: if self.clTempl.cltObj:
self.clTempl.cltObj.closeFiles() self.clTempl.cltObj.closeFiles()
self.clTempl.closeFiles() self.clTempl.closeFiles()
self.clTempl = None self.clTempl = None
@safetyWrapper(native_errors=(TemplatesError,UpdateError), @safetyWrapper(native_errors=(TemplatesError,UpdateError),
man_int=__("Update manually interrupted"), man_int=__("Update manually interrupted"),
post_action=closeClTemplate, post_action=closeClTemplate,
@ -101,4 +89,5 @@ class Update:
Creating user profile and userdir Creating user profile and userdir
""" """
self.initVars(datavars) self.initVars(datavars)
return bool(self.applyTemplates())
return True return True

@ -28,7 +28,7 @@ from cl_update import Update,DataVarsUpdate
import cl_update import cl_update
from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate
from calculate.core.server.decorators import Dec 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 core_method = Dec.core_method
setLocalTranslate('cl_update3',sys.modules[__name__]) setLocalTranslate('cl_update3',sys.modules[__name__])
import traceback import traceback
@ -58,7 +58,7 @@ class Wsdl:
rights=['update']) rights=['update'])
def update(self, sid, info): def update(self, sid, info):
return self.callMethod(sid,info,method_name="update", return self.callMethod(sid,info,method_name="update",
logicClass=Desktop, logicClass=Update,
method="update") method="update")
def update_vars(self,dv=None): def update_vars(self,dv=None):
@ -66,7 +66,7 @@ class Wsdl:
dv = DataVarsUpdate() dv = DataVarsUpdate()
dv.importUpdate() dv.importUpdate()
dv.flIniFile() dv.flIniFile()
dv.Set('cl_action','update',True) dv.Set('cl_action','sync',True)
dv.addGroup(None, dv.addGroup(None,
normal=('cl_update_world',), normal=('cl_update_world',),
next_label=_("Update")) next_label=_("Update"))
@ -74,11 +74,4 @@ class Wsdl:
@rpc(Integer, ViewParams,_returns = ViewInfo) @rpc(Integer, ViewParams,_returns = ViewInfo)
def update_view (self, sid, params): def update_view (self, sid, params):
dv = self.get_cache(sid,"update","vars") return commonView(self,sid,params,"update")
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

@ -15,5 +15,6 @@
# limitations under the License. # limitations under the License.
import action import action
import update
section = "update" section = "update"

@ -30,5 +30,5 @@ class VariableAcUpdateSync(ReadonlyVariable):
def get(self): def get(self):
action = self.Get("cl_action") action = self.Get("cl_action")
if action in ("sync",): if action in ("sync",):
return "world" return "up"
return "" return ""

@ -41,11 +41,12 @@ class VariableClUpdateWorld(Variable):
type = "choice" type = "choice"
opt = ["--world"] opt = ["--world"]
value = "" value = ""
#syntax = "--{choice}-world" syntax = "--{choice}-world"
metavalue = 'ACTION' metavalue = 'ACTION'
def init(self): 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") self.label = _("World")
def choice(self): def choice(self):

Loading…
Cancel
Save