From aced1c4eabd85f5cd82604cf7cfb47563f707af4 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: Wed, 11 Jan 2012 13:34:11 +0400 Subject: [PATCH] Add connection to server --- ClientClass.py | 24 +++ client.py | 10 +- Box.py => gui/Box.py | 36 +++-- gui/__init__.py | 0 gui/conf_connection.py | 159 ++++++++++++++++++++ gui/helpwidget.py | 22 +++ leftmenu.py => gui/leftmenu.py | 14 +- mainframe.py => gui/mainframe.py | 4 +- gui/mainmenu.py | 33 ++++ statusfield.py => gui/statusfield.py | 2 +- gui/tools.py | 14 ++ image/help.png | Bin 0 -> 4395 bytes image/tool.png | Bin 0 -> 2443 bytes mainmenu.py | 16 -- soap/__init__.py | 0 soap/more.py | 216 +++++++++++++++++++++++++++ 16 files changed, 511 insertions(+), 39 deletions(-) create mode 100644 ClientClass.py rename Box.py => gui/Box.py (73%) create mode 100644 gui/__init__.py create mode 100644 gui/conf_connection.py create mode 100644 gui/helpwidget.py rename leftmenu.py => gui/leftmenu.py (83%) rename mainframe.py => gui/mainframe.py (94%) create mode 100644 gui/mainmenu.py rename statusfield.py => gui/statusfield.py (96%) create mode 100644 gui/tools.py create mode 100644 image/help.png create mode 100644 image/tool.png delete mode 100644 mainmenu.py create mode 100644 soap/__init__.py create mode 100644 soap/more.py diff --git a/ClientClass.py b/ClientClass.py new file mode 100644 index 0000000..1926267 --- /dev/null +++ b/ClientClass.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +#-*- coding: utf-8 -*- +from calculate.lib.cl_datavars import DataVars +from calculate.api.cl_api import DataVarsApi + +class ApiClient: + def __init__(self): + # Initialization of system variables + Vars = DataVarsApi() + Vars.importApi() + Vars.flIniFile() + clVars = DataVars() + clVars.flIniFile() + + # Initialization other variables + self.homePath = clVars.Get('ur_home_path') + path_to_cert = '~/.calculate/client_cert/' + self.path_to_cert = path_to_cert.replace("~",self.homePath) + + self.WindowTitle = 'cl-api-client' + self.default_host = 'localhost' + self.default_port = '8888' + + self.client = None \ No newline at end of file diff --git a/client.py b/client.py index d17f4f6..f9ffa0d 100644 --- a/client.py +++ b/client.py @@ -1,14 +1,16 @@ #!/usr/bin/python -# messagebox.py +#-*- coding: utf-8 -*- import sys from PySide import QtGui -from Box import Example +from gui.Box import Example +from ClientClass import ApiClient app = QtGui.QApplication(sys.argv) -ex = Example() -f = QtGui.QStyleFactory().create('Motif') +ClientObj = ApiClient() +ex = Example(ClientObj) +#f = QtGui.QStyleFactory().create('Motif') #ex.setStyle(f) #ex.setStyle('Windows') ex.show() diff --git a/Box.py b/gui/Box.py similarity index 73% rename from Box.py rename to gui/Box.py index e1a0c74..716bfc5 100644 --- a/Box.py +++ b/gui/Box.py @@ -1,19 +1,22 @@ #!/usr/bin/python #-*- coding: utf-8 -*- from PySide import QtGui, QtCore -from PySide.QtGui import QScrollArea, QLabel, QMessageBox from leftmenu import LeftMenu from statusfield import StatusField from mainframe import MainFrame from mainmenu import MainMenu +from helpwidget import HelpWgt +from tools import ToolsWidget + +from conf_connection import FrameConnection #class Example(QtGui.QWidget): class Example(QtGui.QMainWindow): - def __init__(self): + def __init__(self, ClientObj): super(Example, self).__init__() - + self.ClientObj = ClientObj self.initUI() def initUI(self): @@ -29,15 +32,18 @@ class Example(QtGui.QMainWindow): # левое верхнее меню topleft = LeftMenu(self) # верхнее правое - self.main_frame = MainFrame(self) + self.main_frame = FrameConnection(self, self.ClientObj) + self.main_frame.resize(700,900) # создание нижнего фрейма bottom = StatusField(self) + bottom.resize(800,100) # объединение в один виджет splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal) splitter1.addWidget(topleft) splitter1.addWidget(self.main_frame) - splitter1.setGeometry(0, 0, 0, 140) + splitter1.resize(800,700) +# splitter1.setGeometry(0, 0, 0, 140) splitter2 = QtGui.QSplitter(QtCore.Qt.Vertical) splitter2.addWidget(splitter1) @@ -46,18 +52,30 @@ class Example(QtGui.QMainWindow): hbox.addWidget(splitter2) # self.setLayout(hbox) - QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks')) +# QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks')) +# QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('CDE')) CentralWidget = QtGui.QWidget() CentralWidget.setLayout(hbox) self.setCentralWidget(CentralWidget) - self.setGeometry(200, 200, 800, 800) - self.setWindowTitle('QtGui.QSplitter') + + self.move(200, 200) + + self.resize(800,800) + self.setWindowTitle(self.ClientObj.WindowTitle) def onChanged(self, text): self.lbl.setText(text) self.lbl.adjustSize() - + + def help(self): + self.HelpWidget = HelpWgt(self) + self.HelpWidget.show() + + def tools(self): + self.ToolsWgt = ToolsWidget(self) + self.ToolsWgt.show() + # def closeEvent(self, event): ## reply = QtGui.QMessageBox.question(self, 'Message', ## "Close your session?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No,\ diff --git a/gui/__init__.py b/gui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gui/conf_connection.py b/gui/conf_connection.py new file mode 100644 index 0000000..d422340 --- /dev/null +++ b/gui/conf_connection.py @@ -0,0 +1,159 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from PySide import QtGui, QtCore +from calculate.api.client.client_class import Client_suds +from calculate.api.client.client_class import HTTPSClientCertTransport +from suds import WebFault +from suds.transport import TransportError, Request +from calculate.api.cl_api import DataVarsApi + +from calculate.api.client.function import * +from calculate.api.client.pid_information import * +from calculate.api.client.cert_func import * +from calculate.api.client.cert_verify import get_CRL, VerifyError +from calculate.api.client.sid_func import * + +import soap +from soap.more import https_server, client_signal, show_msg, test + +class Conn(QtGui.QWidget): + + def __init__(self, ClientObj): + super(Conn, self).__init__() + self.ClientObj = ClientObj + self.initUI() + + def initUI(self): + grid = QtGui.QGridLayout() + grid.setSpacing(10) + + self.lbl_host = QtGui.QLabel("Host: ") + self.lbl_port = QtGui.QLabel("Port: ") + self.text_host = QtGui.QLineEdit(self.ClientObj.default_host) + self.text_port = QtGui.QLineEdit(self.ClientObj.default_port) + + grid.setRowMinimumHeight(0,20) + grid.setColumnMinimumWidth(0,30) +# grid.addWidget(QtGui.QSpacerItem(10,10),0,0) + + grid.addWidget(self.lbl_host, 1, 1) + grid.addWidget(self.lbl_port, 2, 1) + grid.addWidget(self.text_host, 1, 2) + grid.addWidget(self.text_port, 2, 2) + + + self.cmd_connect = QtGui.QPushButton('Connect') + grid.addWidget(self.cmd_connect, 3, 2) + + self.cmd_connect.connect \ + (self.cmd_connect, QtCore.SIGNAL('clicked()'), self.onClick) + + self.setLayout(grid) + self.setGeometry(0, 0, 150, 180) + self.show() + + # establish a connection + def onClick(self): + # write parameters + self.str_host = self.text_host.text() + self.str_port = self.text_port.text() + self.lbl_host.setText(self.str_host) + self.lbl_port.setText(self.str_port) + + try: + int_port = int(self.str_port) + except: + show_msg("Enter correctly port!") + return 1 + + # get server hostname + url = "https://%s:%d/?wsdl" %(self.str_host, int_port) + path_to_cert = self.ClientObj.path_to_cert + try: + client = Client_suds(url, transport = \ + HTTPSClientCertTransport(None,None, path_to_cert)) + except: + show_msg("Not connected!") + return 1 + server_host_name = client.service.get_server_host_name() + del (client) + self.lbl_port.setText(server_host_name) + + try: + import glob + all_cert_list = glob.glob(path_to_cert + '*.crt') + fit_cert_list = [] + + for client_cert_path in all_cert_list: + client_cert = client_cert_path.replace(path_to_cert, '') + client_cert_name = client_cert.replace('.crt', '') + if server_host_name.endswith(client_cert_name): + fit_cert_list.append(client_cert_name) + fit_cert_list.sort(key = len) + Connect_Error = 1 + for i in range (0, len(fit_cert_list)): + #print 'fit_cert_list = ',fit_cert_list + cert_name = fit_cert_list.pop() + CERT_FILE = path_to_cert + cert_name + '.crt' + CERT_KEY = path_to_cert + cert_name + '.key' +# print "cert_name = ",cert_name + try: + self.ClientObj.client = Client_suds(url,\ + transport = HTTPSClientCertTransport(CERT_KEY, \ + CERT_FILE, path_to_cert)) + self.ClientObj.client.set_parameters \ + (path_to_cert, CERT_FILE, CERT_KEY) + client_post_cert(self.ClientObj.client) + Connect_Error = 0 + except VerifyError, e: + show_msg (e.value) + Connect_Error = 1 + except Exception, e: + print 1111111 + print dir(e) + show_msg (e.message) + Connect_Error = 1 + #sys.exit() + if Connect_Error == 0: + break + #If the certificate file misses + if Connect_Error: + CERT_FILE = None + CERT_KEY = None + self.ClientObj.client = Client_suds(url,\ + transport = HTTPSClientCertTransport(CERT_KEY, CERT_FILE,\ + path_to_cert)) + + self.ClientObj.client.set_parameters (path_to_cert, CERT_FILE, CERT_KEY) + + Vars = DataVarsApi() + Vars.importApi() + Vars.flIniFile() + try: + self.ClientObj.client.frame_period = Vars.Get('cl_api_get_frame_period') + except: + self.ClientObj.client.frame_period = 2 + + signaling = threading.Thread(target=client_signal, args = (self.ClientObj.client, )) + signaling.setDaemon(True) + https_server(self.ClientObj.client, signaling) +#---------------------------------------------------- + except WebFault, f: + show_msg ("Exception: %s" %f) + print f.fault + except TransportError, te: + show_msg ("Exception: %s" %te) + except Exception, e: + show_msg ("Exception: %s" %e) +# tb.print_exc() + + +class FrameConnection (QtGui.QScrollArea): + def __init__(self, parent, ClientObj): + self.ClientObj = ClientObj + QtGui.QScrollArea.__init__(self) + # верхнее правое + connection = Conn(self.ClientObj) + self.setWidget(connection) +# self.resize(700,900) \ No newline at end of file diff --git a/gui/helpwidget.py b/gui/helpwidget.py new file mode 100644 index 0000000..f39eee3 --- /dev/null +++ b/gui/helpwidget.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +from PySide import QtGui, QtCore + +class HelpWgt(QtGui.QWidget): + def __init__(self, parent): + QtGui.QWidget.__init__(self) + + helpLabel = QtGui.QLabel('about calculate Inc.') + helpQuit = QtGui.QPushButton("Quit") + + layout = QtGui.QVBoxLayout() + layout.addWidget(helpLabel) + layout.addWidget(helpQuit) + self.setLayout(layout) + self.connect(helpQuit, QtCore.SIGNAL("clicked()"), + self, QtCore.SLOT("close()")) + + self.move(100+parent.frameGeometry().x(), \ + 100+parent.frameGeometry().y()) + self.resize(200,200) +# self.show() \ No newline at end of file diff --git a/leftmenu.py b/gui/leftmenu.py similarity index 83% rename from leftmenu.py rename to gui/leftmenu.py index 375c398..4c333ae 100644 --- a/leftmenu.py +++ b/gui/leftmenu.py @@ -25,7 +25,6 @@ class Checkbox(QtGui.QWidget): combo.activated[str].connect(self.onActivated) self.setGeometry(0, 0, 150, 180) - self.setWindowTitle('QtGui.QComboBox') self.show() def onActivated(self, text): @@ -40,21 +39,22 @@ class Checkbox(QtGui.QWidget): self.lbl.show() self.lbl.setText(text) self.lbl.adjustSize() - + class LeftMenu(QtGui.QFrame): def __init__(self, parent): QtGui.QFrame.__init__(self) - # верхнее левое меню + # верхнее левое меню # topleft = QtGui.QFrame(self) # self.setFrameShape(QtGui.QFrame.NoFrame) - self.setGeometry(0, 0, 100, 20) check1 = Checkbox() self.scrollArea1 = QtGui.QScrollArea() self.scrollArea1.setWidget(check1) - tempbox = QtGui.QHBoxLayout(self) - tempbox.addWidget(self.scrollArea1) - self.setLayout(tempbox) \ No newline at end of file + tempbox = QtGui.QHBoxLayout(self) + tempbox.addWidget(self.scrollArea1) + self.setLayout(tempbox) + +# self.resize(100,900) \ No newline at end of file diff --git a/mainframe.py b/gui/mainframe.py similarity index 94% rename from mainframe.py rename to gui/mainframe.py index c3bfeef..812b0ce 100644 --- a/mainframe.py +++ b/gui/mainframe.py @@ -24,7 +24,6 @@ class Check(QtGui.QWidget): combo.activated[str].connect(self.onActivated) self.setGeometry(0, 0, 150, 180) - self.setWindowTitle('QtGui.QComboBox') self.show() def onActivated(self, text): @@ -45,4 +44,5 @@ class MainFrame (QtGui.QScrollArea): QtGui.QScrollArea.__init__(self) # верхнее правое check2 = Check() - self.setWidget(check2) \ No newline at end of file + self.setWidget(check2) +# self.resize(700,900) \ No newline at end of file diff --git a/gui/mainmenu.py b/gui/mainmenu.py new file mode 100644 index 0000000..77dd411 --- /dev/null +++ b/gui/mainmenu.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +from PySide import QtGui + +class MainMenu(): + def __init__(self, parent): + exitAction = QtGui.QAction(QtGui.QIcon('image/Exit.png'), \ + '&Exit', parent) + exitAction.setShortcut('Ctrl+Q') + exitAction.setStatusTip('Exit application') + exitAction.triggered.connect(parent.close) + + toolAction = QtGui.QAction(QtGui.QIcon('image/tool.png'), \ + '&Tool', parent) + toolAction.setShortcut('Ctrl+T') + toolAction.setStatusTip('Tool application') + toolAction.triggered.connect(parent.tools) + + helpAction = QtGui.QAction(QtGui.QIcon('image/help.png'), \ + '&Help', parent) + helpAction.setShortcut('Ctrl+H') + helpAction.setStatusTip('Help') + helpAction.triggered.connect(parent.help) + + parent.toolbar = parent.addToolBar('Main') + + parent.toolbar.addAction(toolAction) + parent.toolbar.addAction(helpAction) + parent.toolbar.addAction(exitAction) + +# menubar = parent.menuBar() +# fileMenu = menubar.addMenu('&File') +# fileMenu.addAction(exitAction) \ No newline at end of file diff --git a/statusfield.py b/gui/statusfield.py similarity index 96% rename from statusfield.py rename to gui/statusfield.py index ebde9bb..63f0a6b 100644 --- a/statusfield.py +++ b/gui/statusfield.py @@ -22,7 +22,6 @@ class Checkbox(QtGui.QWidget): self.combo.activated[str].connect(self.onActivated) self.setGeometry(50, 50, 200, 100) - self.setWindowTitle('QtGui.QComboBox') self.show() def onActivated(self, text): @@ -48,6 +47,7 @@ class StatusField (QtGui.QFrame): self.scrollArea3 = QtGui.QScrollArea() self.scrollArea3.horizontalScrollBar().hide() self.scrollArea3.setWidget(check3) +# self.resize(800,10) tempbox3.addWidget(self.scrollArea3) self.setLayout(tempbox3) diff --git a/gui/tools.py b/gui/tools.py new file mode 100644 index 0000000..187382d --- /dev/null +++ b/gui/tools.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from PySide import QtGui + +class ToolsWidget (QtGui.QWidget): + def __init__(self, parent): + + QtGui.QWidget.__init__(self) + helpLabel = QtGui.QLabel('about calculate Inc.') + helpQuit = QtGui.QPushButton("Quit") + + layout = QtGui.QVBoxLayout() + layout.addWidget(helpLabel) + layout.addWidget(helpQuit) + self.setLayout(layout) \ No newline at end of file diff --git a/image/help.png b/image/help.png new file mode 100644 index 0000000000000000000000000000000000000000..e86b24eb070c32a7928adddc8a2e79ac2cc7860c GIT binary patch literal 4395 zcmV+`5!CL9P)k&j0;ui+Gn0QUd@40*LQj1xbJk;vE2a*VZ%d%2TKSNrg%U)leiP1wfEO zNkIvHCO?r*em5}ut!|=*QW_#2LPG11Iw&YoQ^YB8)_8GByo0kH8dCsu=m9uw@(zG_ z7kQg>ym$*zK|~-vdB?K6V+{}lNKhFBK~X^|W0Ot@@5@1Pcwcd7^YlPvd}ppOxJhYU zBB{Oe9cMcW&D#8Ht=jC#Ze#A4h?_TIF*c@<*re@k+!i4-g}i;Oylo8-1VAVg!sJRu zybr`imD0%0_l|D4?PFV~4&1qGYU}vU?HhBG8!Iwg$s?CDR7xR^tu$K^=9ij0cWK4G za{5yJ)zc@QzkK1D@2$+f@R)bWtjP^TF7CP{YWmcE?7IaZ{fVN2$yb!3Ha2Mw4Q;yd zfo=Ql|Ke?j4juf!Z9Brri6LmCV6DJ8KmY+ev-<@gH6bP-lz=PsHl96pNq%ui)R-**JR0{|++Fke(0CHy6?_i zdZ>~|yX!NhE0C(s05Y{!5%xJD5P^4u0zyNOf@hA-$oGHp^u^;(J@O9=7ms`+2upSA zqQpi`Nu9&BDW%_3bP`Gj$^?bL#;u{T9q<3_2S4%`4}ak^zrX*so3^RM5#5OJq9CFm zAiNOXgI)md0r6mV4L(&1MHIXcaY96~U~+trcO04;%n$9lccoL@zC3sAn0HCb1V!&% z@}>syrT~-aW)#6y7f=L z^2twq?sNBkaBt9Pc{opsXn3d$1n9iLdeD2&dB6#njn%maT>3r53p_F~Ucn2{?Rps- zDdEQHofB8u*S-JBrK3-YjTV#+y?5~&YT}vzOi&1&j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k>-CmU zO8W>QOK;YG)&T%O*Y*GCy1u=)x7Rcb1G=tT=|czs$8oUR?IkP6#CPpkkWl2FBP2bJ@Bl002NKy;N9O_@K|{gWYaNrb1=*2-7s7X&Tb$G=jn4 z=Z0ZyVT^s@=;odQ5JCh(NKbx#zQ3ZP!U7 zo-K?ql`*z7olXbG#>S9JrKXN*7_&-iCL*FJ!teJNh@$vgLdZ8}+PP;DupF3?m*#Bao3yBoc{4FdB_wa&i)eVSo?< zQ50dCrWFy>G*MMm<;cs+dzTRMByb-@AS0PbxZQ5QBuQ3vVvNCNvssVgnGJAoa4?-t zrysrN5y(g;5)%^>pN)@?LzZPL5&$5}vh_}(C<^?3f4(3HhwmEzz=BwI_3G8$Xf$f= z(yFRjr{g@&!|irsWMl++d3lNZCWU6obUJhb>)|8c%S+hShGz3*uCtNO9btn|NcHaU37Q`Q1F4q%2pAV5p1cqTmola-< z@bK_B0NmD5MlKbAjZ*rmD2j2X(|Jacq@t`JtK?E{`L71kWsS_Cn5Ugf*o-!#CIEIT zFZb6)fJ}KuFttO^Y-jfux;Ni-%<9htW=^-pbl(7=&r;1wp;?a4=lnwL-TH1uGmfjX zQ~@9ZP`m135W{{h+TzEh!XDER;Y002ov JPDHLkV1h$hnNR=# literal 0 HcmV?d00001 diff --git a/mainmenu.py b/mainmenu.py deleted file mode 100644 index 0d66f64..0000000 --- a/mainmenu.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from PySide import QtGui - -class MainMenu(): - def __init__(self, parent): - exitAction = QtGui.QAction(QtGui.QIcon('image/Exit.png'), '&Exit', parent) - exitAction.setShortcut('Ctrl+Q') - exitAction.setStatusTip('Exit application') - exitAction.triggered.connect(parent.close) - - parent.toolbar = parent.addToolBar('Exit') - parent.toolbar.addAction(exitAction) -# menubar = parent.menuBar() -# fileMenu = menubar.addMenu('&File') -# fileMenu.addAction(exitAction) \ No newline at end of file diff --git a/soap/__init__.py b/soap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/soap/more.py b/soap/more.py new file mode 100644 index 0000000..937b7a4 --- /dev/null +++ b/soap/more.py @@ -0,0 +1,216 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from PySide import QtGui, QtCore +import os, time, sys + +from calculate.api.client.cert_func import client_post_auth +from calculate.api.cl_api import DataVarsApi +from calculate.api.client.pid_information import client_list_methods, \ + client_list_pid +from calculate.api.client.function import get_entire_frame, create_obj, \ + get_sid, analysis +from calculate.api.client.sid_func import client_del_sid + +def _(s): + return s + +def show_msg(text): + msgBox = QtGui.QMessageBox() + msgBox.setText(text) + msgBox.setStandardButtons(QtGui.QMessageBox.Ok) + msgBox.exec_() + +def client_signal(client): + Vars = DataVarsApi() + Vars.importApi() + Vars.flIniFile() + try: + client_active = Vars.Get('cl_api_client_active_period') + except: + client_active = 15 + while True: + if os.path.exists(client.SID_FILE) : + fi = open(client.SID_FILE, 'r') + temp = fi.read() + fi.close() + sid = int(temp) + else: + sid = 0 + try: + reply = client.service.active_client(sid) + except: + print _('no connection to server!') + sys.exit() + print 1111111111 + time.sleep(float(client_active)) + +def https_server(client, signaling): + global url + client_post_auth(client) + signaling.start() + client_list_methods(client) + + get_entire_frame(client) + #create_obj(client, "install_system") + + show_msg("Connection OK!") + +# while True: +# try: +# command = raw_input ("\nCommand: ") +# except KeyboardInterrupt, e: +# print +# sys.exit() +# if (command == 'halt' or command == 'server_shutdown'): +# client_shut(client) +# +# #elif (command == 'say_hello' or command == 'say'): +# #client_say_hello(client) +# +# #elif (command == 'say_hello2' or command == 'say2'): +# #client_say_hello2(client) +# +# elif (command == 'server_start' or command == 'run'): +# if os.path.exists(client.CERT_KEY) and\ +# os.path.exists(client.CERT_FILE) : +# client = Client_suds(url,\ +# transport = HTTPSClientCertTransport(client.CERT_KEY,\ +# client.CERT_FILE)) +# #If the certificate file misses +# else: +# CERT_FILE = None +# CERT_KEY = None +# client = Client_suds(url,\ +# transport = HTTPSClientCertTransport(CERT_KEY, CERT_FILE)) +# +# elif (command == 'login' or command == 'cl-login'): +# client_login(client) +# +# elif (command == 'useradd' or command == 'cl-unix-useradd'): +# client_useradd(client) +# +# elif (command == 'sid-del' or command == 'del-sid'): +# client_del_sid(client) +# +# elif (command == 'lsp' or command == 'list-pid'): +# client_list_pid(client) +# +# elif (command == 'ins' or command == 'install'): +# client_install(client) +# +# elif (command == 'lsr' or command == 'list-method'\ +# or command == 'list-right'): +# client_list_methods(client) +# +# elif (command == 'lss' or command == 'list-session'\ +# or command == 'sls'): +# client_list_sessions(client) +# +# elif (command == 'pi' or command == 'pid-info'): +# client_pid_info(client) +# +# elif (command == 'si' or command == 'session-info'): +# client_session_info(client) +# +# elif (command == 'kill' or command == 'pid-kill'): +# client_pid_kill(client) +# +# elif (command == 'userdel' or command == 'cl-unix-userdel'): +# client_userdel(client) +# +# elif (command == 'vcr' or command == 'view-cert-right'): +# client_view_cert_right(client) +# +# elif command.split(' ',1)[0] in ['t', 'template', 'cl-template']: +# #client_template(client, command) +# test(client, 'cl_template') +# +# elif command.lower() in ['test']: +# test(client) +# +# elif (command == 'help' or command == 'h'): +# print help_ +# +# elif command in ['q', 'quit', 'exit']: +# print _("Closing\n") +# signaling._Thread__stop() +# time.sleep(0.3) +# num = client_list_pid(client) +# if num: +# print _('at closing session, ' +# 'data %d processes will be deleted!' %num) +# c = raw_input (_("Close your session y/[n]: ")) +# if c in ['y', 'yes', 'Y', 'YES']: +# client_del_sid(client) +# #signaling.killed = True +## client_shut(client) +# return 0 +# else: +# print _("Input Error") + +def test(client, com=None): + if not com: + method_name = 'test' + else: + method_name = com + view = client.service[0][method_name + '_view']() + #print '==>', view + + cr = create_obj(client, method_name) + #print 'ddd',cr + #print type (cr) + list_param = dir (cr) + + param_list = [] + for param in list_param: + if not param.startswith('_'): + param_list.append(param) + + for Group in view.groups.GroupField: + print "GroupField name : ", Group.name + + for field in Group.fields.Field: + if field.element == 'input': + if field.type == 'str': + cr[field.name] = raw_input(field.label) + if field.type == 'int': + while True: + try: + var = raw_input(field.label) + cr[field.name] = int (var) + break + except (TypeError, ValueError): + print _('Это не целое число') + elif field.element == 'bool': + while 1: + bool_var = raw_input(field.label+' (y/n): ') + if bool_var.lower() in ['y','yes']: + cr[field.name] = True + break + if bool_var.lower() in ['n','no']: + cr[field.name] = False + break + print _('Enter "Yes" or "No"!') + + elif field.element == 'check': + choice = field.choice[0] + while 1: + print _('Select one: ') + for i in range(1,len(choice)+1): + print choice[i-1], ' - %d' %i + try: + bool_var = int (raw_input(field.label)) + if bool_var > 0: + cr[field.name] = choice[bool_var - 1] + print 'your choice %s' %cr[field.name] + break + except: + pass + + #field.choice + #print field.help + + sid = get_sid(client.SID_FILE) + s = client.service[0][method_name](sid, cr) + analysis(client, sid, s) \ No newline at end of file