選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

85 行
3.0 KiB

  1. # Copyright 2012 Calculate Ltd. http://www.calculate-linux.org
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import soaplib, sys, time, os
  15. import threading
  16. from soaplib.serializers.primitive import String, Integer, Any, Boolean
  17. from soaplib.serializers.clazz import Array, ClassSerializer
  18. from soaplib.service import rpc, DefinitionBase
  19. from calculate.core.server.api_types import ReturnedMessage
  20. from calculate.core.server.api_types import ChoiceValue, Table, Option, Field, \
  21. GroupField, ViewInfo, ViewParams
  22. from calculate.lib.datavars import VariableError,DataVarsError
  23. from calculate.update.cl_update import UpdateError
  24. from cl_update import Update,DataVarsUpdate
  25. import cl_update
  26. from calculate.lib.cl_lang import setLocalTranslate,getLazyLocalTranslate
  27. from calculate.core.server.decorators import Dec
  28. from calculate.core.server.func import catchExcept
  29. core_method = Dec.core_method
  30. setLocalTranslate('cl_update3',sys.modules[__name__])
  31. import traceback
  32. from functools import wraps,WRAPPER_ASSIGNMENTS
  33. __ = getLazyLocalTranslate(_)
  34. class UpdateInfo(ClassSerializer):
  35. """Parameters for method install"""
  36. cl_update_world = String
  37. Default = Array(String)
  38. CheckOnly = Boolean
  39. CheckAll = Boolean
  40. updateCatchExcept = catchExcept(VariableError,DataVarsError,
  41. cl_update.UpdateError)
  42. class Wsdl:
  43. """
  44. cl-update
  45. """
  46. @rpc(Integer, UpdateInfo, _returns = Array(ReturnedMessage))
  47. @core_method(category=__('Update'),title=__('Update world'),
  48. image='preferences-desktop',
  49. gui=True,command='cl-update',
  50. rights=['update'])
  51. def update(self, sid, info):
  52. return self.callMethod(sid,info,method_name="update",
  53. logicClass=Desktop,
  54. method="update")
  55. def update_vars(self,dv=None):
  56. if not dv:
  57. dv = DataVarsUpdate()
  58. dv.importUpdate()
  59. dv.flIniFile()
  60. dv.Set('cl_action','update',True)
  61. dv.addGroup(None,
  62. normal=('cl_update_world',),
  63. next_label=_("Update"))
  64. return dv
  65. @rpc(Integer, ViewParams,_returns = ViewInfo)
  66. def update_view (self, sid, params):
  67. dv = self.get_cache(sid,"update","vars")
  68. if not dv:
  69. dv = self.update_vars()
  70. else:
  71. dv.processRefresh()
  72. view = ViewInfo(dv,viewparams=params)
  73. self.set_cache(sid, 'update', "vars",dv,smart=False)
  74. return view