|
|
#-*- coding: utf-8 -*-
|
|
|
|
|
|
# Copyright 2010-2012 Calculate Ltd. http://www.calculate-linux.org
|
|
|
#
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
# You may obtain a copy of the License at
|
|
|
#
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
#
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
# See the License for the specific language governing permissions and
|
|
|
# limitations under the License.
|
|
|
|
|
|
import soaplib, sys, time
|
|
|
|
|
|
import lxml.etree
|
|
|
from soaplib.serializers.primitive import String, Integer, Any
|
|
|
from soaplib.serializers.clazz import Array
|
|
|
|
|
|
from soaplib.serializers.clazz import ClassSerializer
|
|
|
from soaplib.service import rpc
|
|
|
|
|
|
class NewType (ClassSerializer):
|
|
|
helper = Integer
|
|
|
value = Any
|
|
|
|
|
|
class UserInfo(ClassSerializer):
|
|
|
name = String
|
|
|
surname = String
|
|
|
|
|
|
class GroupInfo(ClassSerializer):
|
|
|
name = String
|
|
|
gid = Integer
|
|
|
|
|
|
class UserInfoValue (ClassSerializer):
|
|
|
table = UserInfo
|
|
|
|
|
|
class GroupInfoValue (ClassSerializer):
|
|
|
table = GroupInfo
|
|
|
|
|
|
# Класс с выполняемым кодом
|
|
|
class Wsdl:
|
|
|
|
|
|
def install (self, name, times) :
|
|
|
try:
|
|
|
results = []
|
|
|
self.writeFile()
|
|
|
for i in range( 0, times ) :
|
|
|
results.append('Hello!!!, %s %d'%(name, i))
|
|
|
# Помещение данных в словарь процессов
|
|
|
self.setData (results)
|
|
|
|
|
|
# Учёт процесса выполнения
|
|
|
while self.getPercent() < 100:
|
|
|
time.sleep(2)
|
|
|
# Увеличение процента выполнения процесса
|
|
|
self.addPercent (20)
|
|
|
return True
|
|
|
# Обработка сигнала прерывания работы процесса
|
|
|
except KeyboardInterrupt:
|
|
|
# Необходимо передать Fasle для сохранения данных о процессе
|
|
|
return False
|
|
|
|
|
|
import sys, os
|
|
|
#sys.path.insert(0,os.path.abspath('~/Home/mydir/source/my/soap/temp'))
|
|
|
from baseClass import Basic, check_permissions
|
|
|
|
|
|
@rpc( NewType, UserInfoValue, _returns = Array( String ) )
|
|
|
def func (self, a, b):
|
|
|
return []
|
|
|
|
|
|
@rpc( String, Integer, Array(String), Integer, Integer, String,\
|
|
|
#_inVariableNames = {'_stri':'stri', "a" : "a"},\
|
|
|
_returns = NewType, _outVariableName='return') #Array( String ) )
|
|
|
# проверка прав на вызов функции
|
|
|
@check_permissions()
|
|
|
# кэширование параметров
|
|
|
@Basic.cache
|
|
|
# команда для консоли
|
|
|
@Basic.console('cl-say-hello')
|
|
|
@Basic.gui('Misc')
|
|
|
#def say_hello_view
|
|
|
def say_hello ( self, cert, sid, name, times, a = 5, _stri = "stri_"):
|
|
|
install = type("CommonInstall",(self.Common, Wsdl, object), {})
|
|
|
return self.startprocess(sid, target=install,method="install",
|
|
|
args_proc = (name[0], times))
|