From 74ac41a590487509620967087a76e482783e2589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BF=D0=B8=D1=80=D0=B8=D0=B4=D0=BE=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=94=D0=B5=D0=BD=D0=B8=D1=81?= Date: Tue, 28 Feb 2012 16:01:05 +0400 Subject: [PATCH] modified for xfce --- api/server/baseClass.py | 13 ++++----- api/server/cl_template.py | 5 ++-- api/server/clean.py | 1 + api/server/func.py | 11 +++++--- api/server/gen_pid.py | 4 +-- api/server/sid_pid_file.py | 2 ++ api/server/test.py | 54 +++++++++++++++++++++++++++++++------- api/server/test2.py | 3 ++- scripts/cl-api-server | 2 +- 9 files changed, 70 insertions(+), 25 deletions(-) diff --git a/api/server/baseClass.py b/api/server/baseClass.py index caa959c..15a774c 100644 --- a/api/server/baseClass.py +++ b/api/server/baseClass.py @@ -174,7 +174,7 @@ class Basic (DefinitionBase) : Basic.max_sid = int(max_sid) Basic.max_pid = int(max_pid) - # start monitor and sid_monitor threads + #start monitor and sid_monitor threads monitoring = threading.Thread(target=monitor,\ args = (Basic.certbase, Basic.sids_file)) sid_mon = threading.Thread(target=sid_monitor,\ @@ -426,11 +426,11 @@ class Basic (DefinitionBase) : cert_id = int(cert_id) except: self.printERROR("Error input certificate ID!") - return ["-2"] + return True cert_file = data_path+'/client_certs/%s.crt' %str(cert_id) if not os.path.exists(cert_file): self.printERROR ("Certificate not found in server!") - return ["-1"] + return True cert = open(cert_file, 'r').read() #try: @@ -491,7 +491,7 @@ class Basic (DefinitionBase) : for i in results: self.printSUCCESS(message = i) return True - return results + #return results # Обработка сигнала прерывания работы процесса except KeyboardInterrupt: @@ -503,7 +503,7 @@ class Basic (DefinitionBase) : @rpc(Integer, ViewCert, _returns = Array(ReturnedMessage)) @Dec.check_permissions(["view_cert_right"]) @Dec.console('view_cert') - @Dec.gui('System', 'View Cert', 'certificate-server') + @Dec.gui('System', 'View Cert', 'certificate-server,application-certificate') def view_cert ( self, sid, VC): cert_id = VC.cert_id @@ -517,7 +517,8 @@ class Basic (DefinitionBase) : view_cert_meth = type("CommonInstall",(self.Common, Basic, object), {}) pid = self.startprocess(sid, target=view_cert_meth, \ - method="view_cert_meth", args_proc = (cert_id, self.data_path)) + method="view_cert_meth", method_name='view_cert', \ + args_proc = (cert_id, self.data_path)) returnmess = ReturnedMessage(type = 'pid', message = pid) return [returnmess] diff --git a/api/server/cl_template.py b/api/server/cl_template.py index 0f7ffee..d0009af 100644 --- a/api/server/cl_template.py +++ b/api/server/cl_template.py @@ -85,7 +85,7 @@ class ApiWsdl: @rpc(Integer, ClTemplate, _returns = Array(ReturnedMessage)) @Dec.check_permissions(['cl_template']) @Dec.console('cl-template') - @Dec.gui('Utilities','Overlay Templates', 'tab-duplicate') + @Dec.gui('Utilities','Overlay Templates', 'tab-duplicate,edit-copy') def cl_template ( self, sid, cltemplate): cl_template_meth = type("CommonInstall",(self.Common, ApiWsdl, object), {}) @@ -94,7 +94,8 @@ class ApiWsdl: except: args = '' pid = self.startprocess(sid, target=cl_template_meth, \ - method="cl_template_meth", args_proc = (args, )) + method_name='cl_template', \ + method="cl_template_meth", args_proc = (args, )) # must be returned to the client process PID returnmess = ReturnedMessage(type = 'pid', message = pid) return [returnmess] diff --git a/api/server/clean.py b/api/server/clean.py index d7dc62b..56488b9 100644 --- a/api/server/clean.py +++ b/api/server/clean.py @@ -53,6 +53,7 @@ class ApiWsdl: print _("killed %d") %pid # send process signal KeyboardInterrupt os.kill(meth.pid, 2) + return 0 # read data if self.glob_process_dict[pid]['status'] == 0 or\ diff --git a/api/server/func.py b/api/server/func.py index 66450fe..8ce6174 100644 --- a/api/server/func.py +++ b/api/server/func.py @@ -15,7 +15,7 @@ # limitations under the License. import pickle, time -import threading, subprocess +import threading import multiprocessing, datetime import sys, os import fcntl, socket, struct @@ -263,7 +263,8 @@ class ApiWsdl () : #sid = self.process_dict['sid'] #self.args[sid] = collections.OrderedDict() - def startprocess (self, sid, target=None, method=None, args_proc = {}): + def startprocess (self, sid, target=None, method=None, method_name=None, \ + args_proc = {}): """ start process """ pid = self.gen_pid() self.add_sid_pid(sid, pid) @@ -291,7 +292,7 @@ class ApiWsdl () : # start helper p = multiprocessing.process.Process(target = self.target_helper,\ - args = (com, getattr(com,method)) + args_proc) + args = (com, getattr(com,method)) +(method_name, )+ args_proc) p.start() # start watcher (for kill process on signal) @@ -302,7 +303,7 @@ class ApiWsdl () : return str(pid) # wrap all method - def target_helper(self, com, target_proc, *args_proc): + def target_helper(self, com, target_proc, method_name, *args_proc): if not os.path.exists(self.pids): os.system('mkdir %s' %self.pids) PID_FILE = self.pids + '/%d.pid'%com.pid @@ -310,6 +311,8 @@ class ApiWsdl () : com.process_dict['status'] = 1 com.process_dict['time'] = dat + #if method_name: + com.process_dict['method_name'] = method_name com.process_dict['name'] = target_proc.__func__.__name__ result = target_proc(*args_proc) diff --git a/api/server/gen_pid.py b/api/server/gen_pid.py index 37f8468..49c0c5c 100644 --- a/api/server/gen_pid.py +++ b/api/server/gen_pid.py @@ -121,9 +121,9 @@ class ApiWsdl () : except: break # when session id equal readable... - if sid == list_sid[0]: + if int(sid) == list_sid[0]: # ... and certificate id equal launched this session... - if cert_id == list_sid[1]: + if int(cert_id) == list_sid[1]: # ... set flag flag = 1 fd.close() diff --git a/api/server/sid_pid_file.py b/api/server/sid_pid_file.py index 045a3c0..c01dfc4 100644 --- a/api/server/sid_pid_file.py +++ b/api/server/sid_pid_file.py @@ -139,6 +139,8 @@ class ApiWsdl () : results.append(str(self.glob_process_dict[pid]['time'])) # process (function) name results.append(str(self.glob_process_dict[pid]['name'])) + # process soap method name + results.append(str(self.glob_process_dict[pid]['method_name'])) lock.release() return results diff --git a/api/server/test.py b/api/server/test.py index c244754..08507b0 100644 --- a/api/server/test.py +++ b/api/server/test.py @@ -45,6 +45,8 @@ class SH (ClassSerializer): Steps = Array(Array(String)) isopath = Array(String) + comboLang = String + # for check parameters without call method CheckOnly = Boolean @@ -64,8 +66,8 @@ class ApiWsdl: # Учёт процесса выполнения perc = 0 while self.getProgress() < 100: - time.sleep(0.6) - perc += 20 + time.sleep(1.6) + perc += 10 # Увеличение процента выполнения процесса self.setProgress (perc) #question = self.askQuestion('enter name: ', None) @@ -133,7 +135,8 @@ class ApiWsdl: @rpc(Integer, SH, _returns = Array(ReturnedMessage)) @Dec.check_permissions(["test"]) @Dec.console('cl-test') - @Dec.gui('Utilities.Тестовые.Подгруппа', 'Первый тест','/usr/share/wallpapers/Horos/contents/screenshot.png') + @Dec.gui('Utilities.Тестовые.Подгруппа', 'Первый тест', \ + '/usr/share/wallpapers/Horos/contents/screenshot.png,system-log-out') def test ( self, sid, rrr): #print '>>>>>>>', sid, rrr name_meth = 'test' @@ -182,6 +185,7 @@ class ApiWsdl: say_hello_meth = type("CommonInstall",(self.Common, ApiWsdl, object), {}) name = sh.name pid = self.startprocess(sid, target=say_hello_meth, method="say_hello_meth",\ + method_name='test', \ args_proc = (name, times, town)) returnmess = ReturnedMessage(type = 'pid', message = pid) #returnmess.type = "pid" @@ -266,12 +270,13 @@ class ApiWsdl: type = 'steps', # Table tablevalue = Table( - head = ['Табличка','Завершение'], + head = ['Табличка','Второй шаг','Завершение'], body = [['times','name','isopath','Partition_table',\ 'boolvariable2','boolvariable', 'combovariable', \ 'combovariable2'],\ ['radiovariable2','radiovariable','comboEdit1', \ - 'comboEdit2', 'multichoice_add', 'multichoice']] + 'comboEdit2', 'multichoice_add', 'multichoice'], \ + ['comboLang']] ))) if expert: group.fields.append(Field( @@ -384,7 +389,7 @@ class ApiWsdl: elif step == 1: view = ViewInfo(groups=[]) - group = GroupField(name=_("TEST_METHOD"),nextlabel=_("Next"),last=True) + group = GroupField(name=_("TEST_METHOD"),nextlabel=_("Next")) group.fields = [] group.fields.append(Field( @@ -469,7 +474,38 @@ class ApiWsdl: #opt = Option(longopt="--bot", #metavalue="BOT"), #element = "button")) - - view.groups.append(group) + elif step == 2: + view = ViewInfo(groups=[]) - return view + group = GroupField(name=_("Gratulations!"),nextlabel=_("Next"),last=True) + group.fields = [] + + group.fields.append(Field( + name = "final_label", + label = _("Final step in system install!!! Congratulation!\n"\ + "Please, select language now!"), + #default = "border-style: solid; border-width: " + #"2px;border-color: #ff2222;", + default = 'border: 0px outset gray;' + 'border-radius: 6px;' + 'subcontrol-origin: margin;' + 'color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 1,' + 'stop: 0.1 #bb1111, stop: 0.5 #11bb11, stop: 0.9 #1111bb);' + 'subcontrol-position: top left; ', + element = "label")) + group.fields.append(Field( + name = "comboLang", + label = _("check language: "), + choice = ['Russian','English'], + type = "str", + #default = 'London', + opt = Option(longopt="--bot", + metavalue="BOT"), + help = \ + _("you not human? This is a anti-bot test"), + element = "combo")) + + + view.groups.append(group) + + return view diff --git a/api/server/test2.py b/api/server/test2.py index 1750bf1..2c37081 100644 --- a/api/server/test2.py +++ b/api/server/test2.py @@ -136,7 +136,7 @@ class ApiWsdl: @rpc(Integer, SH2, _returns = Array(ReturnedMessage)) @Dec.check_permissions(["test2"]) @Dec.console('cl-test2') - @Dec.gui('Utilities.Тестовые', 'test2 install', 'voicecall') + @Dec.gui('Utilities.Тестовые', 'test2 install', 'voicecall,system-software-install') def test2 ( self, sid, rrr): import threading curThread = threading.currentThread() @@ -190,6 +190,7 @@ class ApiWsdl: name = sh.name pid = self.startprocess(sid, target=test2_meth, method="test2_meth",\ + method_name = 'test2', \ args_proc = (name[0], times, town)) returnmess = ReturnedMessage(type = 'pid', message = pid) #returnmess.type = "pid" diff --git a/scripts/cl-api-server b/scripts/cl-api-server index e41f0ea..cf6df03 100644 --- a/scripts/cl-api-server +++ b/scripts/cl-api-server @@ -210,7 +210,7 @@ def main(*args, **keywords): max_pid, cert_path, cert, key) man_num = 99999999 - dispatcher = WSGIPathInfoDispatcher( { '/App' : App } ) + dispatcher = WSGIPathInfoDispatcher( { '' : App } ) server = CherryPyWSGIServer(('0.0.0.0', port), dispatcher,\ numthreads = 10, max = man_num, request_queue_size = man_num)