Browse Source

Add call update world command

master3.1.6
parent
commit
4faa555324
  1. 21
      update/cl_update.py
  2. 15
      update/cl_wsdl_update.py
  3. 1
      update/variables/__init__.py
  4. 2
      update/variables/action.py
  5. 5
      update/variables/update.py

21
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

15
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")

1
update/variables/__init__.py

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

2
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 ""

5
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):

Loading…
Cancel
Save