You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
767 lines
28 KiB
767 lines
28 KiB
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from PySide import QtGui, QtCore
|
|
import os, time, sys
|
|
|
|
from calculate.api.cl_api import DataVarsApi
|
|
from pid_information import client_list_methods
|
|
from calculate.api.client.sid_func import client_del_sid
|
|
#from calculate.api.client.function import get_sid
|
|
|
|
class ButtonMenu(QtGui.QPushButton):
|
|
def __init__(self, name, label, image, group, parent = None):
|
|
QtGui.QPushButton.__init__(self, parent)
|
|
self.layout = QtGui.QVBoxLayout(self)
|
|
|
|
self.image_lbl = QtGui.QLabel(self)
|
|
if not image:
|
|
image = ''
|
|
|
|
icon = QtGui.QIcon.fromTheme(image)
|
|
if icon.isNull():
|
|
if os.path.isfile(image):
|
|
ir = QtGui.QImageReader(image)
|
|
ir.setScaledSize(QtCore.QSize(64, 64))
|
|
img = ir.read()
|
|
pm2 = QtGui.QPixmap().fromImage(img)
|
|
else:
|
|
icon = QtGui.QIcon.fromTheme('applications-utilities')
|
|
pm2 = icon.pixmap(64,64)
|
|
else:
|
|
pm2 = icon.pixmap(64,64)
|
|
|
|
self.image_lbl.setPixmap(pm2)
|
|
self.image_lbl.setAlignment(QtCore.Qt.AlignCenter)
|
|
|
|
# add transparency
|
|
self.image_lbl.setAttribute(QtCore.Qt.WA_NoSystemBackground)
|
|
|
|
|
|
self.layout.addWidget(self.image_lbl)
|
|
self.setFlat(True)
|
|
|
|
|
|
self.lbl = LabelWordWrap(label, self)
|
|
self.lbl.setAlignment(QtCore.Qt.AlignCenter)
|
|
|
|
# add transparency
|
|
self.lbl.setAttribute(QtCore.Qt.WA_NoSystemBackground)
|
|
|
|
self.layout.addWidget(self.lbl)
|
|
|
|
# if self.layout.sizeHint().width() > 96:
|
|
# self.setFixedSize(self.layout.sizeHint().width(),96)
|
|
# else:
|
|
self.setFixedSize(96,108)
|
|
self.setObjectName(name)
|
|
# for clear memory after closed this window
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
self.updateGeometry()
|
|
|
|
def text(self):
|
|
return self.lbl.text()
|
|
|
|
# def setObjectName(self, name):
|
|
#
|
|
# def objectName(self):
|
|
|
|
|
|
class ErrorLabel (QtGui.QLabel):
|
|
def __init__(self, parent = None):
|
|
QtGui.QLabel.__init__(self, parent)
|
|
self.parent = parent
|
|
self.setWordWrap(True)
|
|
self.hide()
|
|
# self.setAlignment(QtCore.Qt.AlignCenter)
|
|
# for clear memory after closed this window
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
class LabelWordWrap(QtGui.QLabel):
|
|
def __init__(self, name, parent = None):
|
|
QtGui.QLabel.__init__(self, _(name.decode('utf-8')), parent)
|
|
self.parent = parent
|
|
self.setWordWrap(True)
|
|
# for clear memory after closed this window
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
class ClearLineEdit(QtGui.QLineEdit):
|
|
def __init__(self,parent=None):
|
|
QtGui.QLineEdit.__init__(self,parent)
|
|
self.parent = parent
|
|
self.button=QtGui.QToolButton(self)
|
|
self.button.setCursor(QtCore.Qt.ArrowCursor)
|
|
self.button.hide()
|
|
self.button.setFocusPolicy(QtCore.Qt.NoFocus)
|
|
try:
|
|
self.button.setIcon(QtGui.QIcon.fromTheme("edit-clear"))
|
|
except:
|
|
self.button.setText('clear')
|
|
self.button.setStyleSheet("border: none;")
|
|
self.textChanged.connect(self.changed)
|
|
self.button.clicked.connect(self.clear)
|
|
|
|
# for clear memory after closed this window
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
layout=QtGui.QVBoxLayout(self)
|
|
layout.addWidget(self.button,0,QtCore.Qt.AlignRight)
|
|
layout.setSpacing(0)
|
|
|
|
def changed(self,text):
|
|
if len(text)==0: self.button.hide()
|
|
else: self.button.show()
|
|
|
|
def focusInEvent(self, FocusEvent):
|
|
if self.text() == self.parent:
|
|
self.clear()
|
|
|
|
def focusOutEvent(self, FocusEvent):
|
|
if self.text() == '':
|
|
self.setText(self.parent)
|
|
|
|
class CentralCheckBox (QtGui.QWidget):
|
|
def __init__(self, tristate, text = None, parent = None):
|
|
super(CentralCheckBox, self).__init__(parent)
|
|
self.lay = QtGui.QHBoxLayout(self)
|
|
self.pCheckB = QtGui.QCheckBox(self)
|
|
self.lay.addWidget(self.pCheckB)
|
|
self.lay.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
|
|
self.setLayout(self.lay)
|
|
self.pCheckB.clicked.connect(self.change_label)
|
|
if tristate:
|
|
self.pCheckB.setTristate()
|
|
self.change_label()
|
|
|
|
def setChecked(self, check = True):
|
|
self.pCheckB.setChecked(check)
|
|
self.change_label()
|
|
|
|
def isChecked(self):
|
|
return self.pCheckB.isChecked()
|
|
|
|
def set_label(self, text):
|
|
self.pCheckB.setText(_(text))
|
|
|
|
def change_label(self):
|
|
if self.pCheckB.checkState() == QtCore.Qt.CheckState.PartiallyChecked:
|
|
self.set_label('Auto')
|
|
elif self.pCheckB.checkState() == QtCore.Qt.CheckState.Checked:
|
|
self.set_label('Yes')
|
|
else:
|
|
self.set_label('No')
|
|
|
|
def setCheckState(self, CheckState):
|
|
self.pCheckB.setCheckState(CheckState)
|
|
self.change_label()
|
|
|
|
def getState(self):
|
|
if self.pCheckB.isTristate():
|
|
if self.pCheckB.checkState() == QtCore.Qt.CheckState.PartiallyChecked:
|
|
return 'auto'
|
|
elif self.pCheckB.checkState() == QtCore.Qt.CheckState.Checked:
|
|
return 'on'
|
|
else:
|
|
return 'off'
|
|
else:
|
|
if self.pCheckB.isChecked():
|
|
return 'on'
|
|
else:
|
|
return 'off'
|
|
|
|
class MultipleChoiceDialog (QtGui.QWidget):
|
|
""" Widget opens a dialog multiple select """
|
|
def __init__(self, parent, Available_list, Selected_list, add_ability):
|
|
super(MultipleChoiceDialog, self).__init__()
|
|
self.parent = parent
|
|
self.layout = QtGui.QGridLayout(self)
|
|
|
|
# if there is a possibility of adding
|
|
if add_ability:
|
|
# add "input new items" LineEdit
|
|
self.add_LineEdit = QtGui.QLineEdit(self)
|
|
self.layout.addWidget(self.add_LineEdit, 0,0,1,4)
|
|
|
|
# add "add new items" PushButton
|
|
self.add_Button = QtGui.QPushButton(self)
|
|
try:
|
|
self.add_Button.setIcon(QtGui.QIcon.fromTheme("list-add"))
|
|
except:
|
|
self.add_Button.setText('Add Item')
|
|
self.add_Button.clicked.connect(self.add_new_item)
|
|
self.layout.addWidget(self.add_Button, 0,4)
|
|
|
|
# add 2 labels
|
|
self.available_label = QtGui.QLabel('Available values', self)
|
|
self.layout.addWidget(self.available_label, 1,0,1,2)
|
|
|
|
self.selected_label = QtGui.QLabel('Selected values', self)
|
|
self.layout.addWidget(self.selected_label, 1,3,1,2)
|
|
|
|
#add left list
|
|
self.left_ListWidget = QtGui.QListWidget(self)
|
|
self.left_ListWidget.itemDoubleClicked.connect(self.plus_item)
|
|
self.layout.addWidget(self.left_ListWidget, 2,0,2,2)
|
|
|
|
# add '+' button
|
|
self.plus_Button = QtGui.QPushButton(self)
|
|
try:
|
|
self.plus_Button.setIcon(QtGui.QIcon.fromTheme("go-next-view"))
|
|
except:
|
|
self.plus_Button.setText('+')
|
|
self.plus_Button.clicked.connect(self.plus_item)
|
|
self.layout.addWidget(self.plus_Button, 2,2)
|
|
|
|
# add '-' button
|
|
self.minus_Button = QtGui.QPushButton(self)
|
|
try:
|
|
self.minus_Button.setIcon(QtGui.QIcon.fromTheme("go-previous-view"))
|
|
except:
|
|
self.minus_Button.setText('-')
|
|
self.minus_Button.clicked.connect(self.minus_item)
|
|
self.layout.addWidget(self.minus_Button, 3,2)
|
|
|
|
#add right list
|
|
self.right_ListWidget = QtGui.QListWidget(self)
|
|
self.right_ListWidget.itemDoubleClicked.connect(self.minus_item)
|
|
self.layout.addWidget(self.right_ListWidget, 2,3,2,2)
|
|
|
|
# add OK button
|
|
self.Ok_Button = QtGui.QPushButton('Ok', self)
|
|
self.Ok_Button.clicked.connect(self.ok_pressed)
|
|
self.layout.addWidget(self.Ok_Button, 4,3)
|
|
|
|
# add Cancel button
|
|
self.Cancel_Button = QtGui.QPushButton('Cancel', self)
|
|
self.Cancel_Button.clicked.connect(self.close)
|
|
self.layout.addWidget(self.Cancel_Button, 4,4)
|
|
|
|
#add Items in list
|
|
self.left_ListWidget.addItems(Available_list)
|
|
self.right_ListWidget.addItems(Selected_list)
|
|
|
|
self.setLayout(self.layout)
|
|
|
|
def add_new_item(self):
|
|
# Slot click event add_Button
|
|
if self.add_LineEdit.text() not in [None, '']:
|
|
self.right_ListWidget.addItem(self.add_LineEdit.text())
|
|
self.add_LineEdit.setText('')
|
|
self.add_LineEdit.setFocus()
|
|
|
|
def plus_item(self):
|
|
# get item in left_ListWidget and set this item in right_ListWidget
|
|
temp_item = self.left_ListWidget.takeItem(self.left_ListWidget.currentRow())
|
|
self.right_ListWidget.addItem(temp_item)
|
|
|
|
def minus_item(self):
|
|
# get item in right_ListWidget and set this item in left_ListWidget
|
|
temp_item = self.right_ListWidget.takeItem(self.right_ListWidget.currentRow())
|
|
self.left_ListWidget.addItem(temp_item)
|
|
|
|
def ok_pressed(self):
|
|
# save all lists and close this widget
|
|
self.parent.Selected = []
|
|
for i in range(self.right_ListWidget.count()):
|
|
self.parent.Selected.append(self.right_ListWidget.takeItem(0).text())
|
|
|
|
self.parent.avail = []
|
|
for i in range(self.left_ListWidget.count()):
|
|
self.parent.avail.append(self.left_ListWidget.takeItem(0).text())
|
|
# self.parent.Selected = ','.join(self.parent.select)
|
|
self.parent.change_value()
|
|
self.close()
|
|
|
|
def keyPressEvent(self, key):
|
|
if key.key() in [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]:
|
|
if hasattr (self, 'add_Button'):
|
|
self.add_new_item()
|
|
|
|
|
|
class MultipleChoice (QtGui.QWidget):
|
|
# multiple-choice widget displayed in the table
|
|
def __init__(self, parent, Available_list, Selected, comments, add_ability = False):
|
|
super(MultipleChoice, self).__init__()
|
|
# Available_list is string list, Selected_list is string, add_ability is boolean
|
|
self.avail = Available_list
|
|
self.Selected = Selected
|
|
self.Comments = comments
|
|
# self.select = Selected if Selected else []
|
|
self.ability = add_ability
|
|
|
|
self.value_dict = None
|
|
if self.Comments:
|
|
self.value_dict = {}
|
|
for i in range (len(self.Comments.string)):
|
|
self.value_dict[self.avail[i]] = self.Comments.string[i]
|
|
|
|
layout = QtGui.QHBoxLayout(self)
|
|
|
|
self.label_text = ','.join(self.Selected)
|
|
self.lbl = QtGui.QLineEdit(self.label_text, self)
|
|
self.lbl.setDisabled(True)
|
|
layout.addWidget(self.lbl)
|
|
|
|
self.button=QtGui.QToolButton(self)
|
|
self.button.setCursor(QtCore.Qt.ArrowCursor)
|
|
# self.button.hide()
|
|
self.button.setFocusPolicy(QtCore.Qt.NoFocus)
|
|
try:
|
|
self.button.setIcon(QtGui.QIcon.fromTheme("list-add"))
|
|
except:
|
|
self.button.setText('+')
|
|
self.button.setStyleSheet("border: none;")
|
|
self.button.clicked.connect(self.mousePressEvent)
|
|
layout.addWidget(self.button,QtCore.Qt.AlignRight)
|
|
|
|
self.setLayout(layout)
|
|
|
|
def mousePressEvent(self, button = None):
|
|
# call widget MultipleChoiceDialog in new window
|
|
self.MCD = MultipleChoiceDialog(self, self.avail, self.Selected, self.ability)
|
|
self.MCD.setAttribute(QtCore.Qt.WA_ShowModal)
|
|
self.MCD.move(QtGui.QCursor.pos ())
|
|
self.MCD.show()
|
|
|
|
def change_value(self):
|
|
# show values in label
|
|
# self.select = self.Selected.split(',') if self.Selected else []
|
|
self.label_text = ','.join(self.Selected)
|
|
self.lbl.setText(self.label_text)
|
|
|
|
def text(self):
|
|
return self.lbl.text()
|
|
|
|
def values(self):
|
|
if self.Comments:
|
|
result = []
|
|
for i in self.Selected:
|
|
if self.value_dict.has_key(i):
|
|
result.append(self.value_dict[i])
|
|
else:
|
|
result.append(i)
|
|
return result
|
|
else:
|
|
return self.Selected
|
|
|
|
|
|
class PlusRow (QtGui.QWidget):
|
|
""" Widget opens a dialog multiple select """
|
|
def __init__(self, parent, table, field):
|
|
super(PlusRow, self).__init__()
|
|
# self.parent = parent
|
|
|
|
self.grid = QtGui.QGridLayout(self)
|
|
self.field = field
|
|
self.table = table
|
|
x = 0
|
|
y = 0
|
|
self.widget_dict = {}
|
|
|
|
for i in range (len(field.tablevalue.values.ChoiceValue)):
|
|
element = field.tablevalue.values.ChoiceValue[i].typefield
|
|
name = field.tablevalue.head.string[i]
|
|
# add element in frame
|
|
if element == 'input':
|
|
#add label
|
|
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
|
|
|
|
self.widget_dict[str(i)] = QtGui.QLineEdit(self)
|
|
if field.default:
|
|
self.widget_dict[str(i)].setText(field.default)
|
|
if field.type == 'int':
|
|
self.rx = QtCore.QRegExp ("^[\d]{1,50}$")
|
|
self.validator = QtGui.QRegExpValidator(self.rx, self)
|
|
self.widget_dict[str(i)].setValidator(self.validator)
|
|
elif field.type == 'float':
|
|
self.rx = QtCore.QRegExp ("^[\d]{1,50}[.][\d]{1,50}$")
|
|
self.validator = QtGui.QRegExpValidator(self.rx, self)
|
|
self.widget_dict[str(i)].setValidator(self.validator)
|
|
x += 1
|
|
|
|
elif element == 'check':
|
|
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
|
|
self.widget_dict[str(i)] = CentralCheckBox(_('Yes'),self)
|
|
|
|
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
|
|
x += 1
|
|
|
|
elif element == 'combo':
|
|
choice = field.tablevalue.values.ChoiceValue[i].values.string
|
|
#add label
|
|
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
|
|
self.ComboBox = QtGui.QComboBox(self)
|
|
for j in range(0,len(choice)):
|
|
self.ComboBox.addItem(choice[j])
|
|
|
|
self.widget_dict[str(i)] = self.ComboBox
|
|
|
|
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
|
|
x += 1
|
|
|
|
elif element == 'comboEdit':
|
|
choice = field.tablevalue.values.ChoiceValue[i].values.string
|
|
#add label
|
|
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
|
|
self.ComboBox = QtGui.QComboBox(self)
|
|
self.ComboBox.setDuplicatesEnabled(False)
|
|
self.ComboBox.setEditable(True)
|
|
self.ComboBox.setLineEdit(QtGui.QLineEdit(self))
|
|
for j in range(0,len(choice)):
|
|
self.ComboBox.addItem(choice[j])
|
|
|
|
self.widget_dict[str(i)] = self.ComboBox
|
|
|
|
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
|
|
x += 1
|
|
|
|
elif element in ['multichoice', 'multichoice_add']:
|
|
if field.element == 'multichoice_add':
|
|
add_ability = True
|
|
else:
|
|
add_ability = False
|
|
choice = field.tablevalue.values.ChoiceValue[i].values.string
|
|
default = ''
|
|
|
|
self.widget_dict[str(i)] = \
|
|
MultipleChoice(self, choice, default, add_ability)
|
|
#add label
|
|
self.grid.addWidget(QtGui.QLabel(name, self), x, y)
|
|
self.grid.addWidget(self.widget_dict[str(i)], x, y+1)
|
|
x += 1
|
|
|
|
# add OK button
|
|
self.Ok_Button = QtGui.QPushButton('Ok', self)
|
|
self.Ok_Button.clicked.connect(self.ok_pressed)
|
|
self.grid.addWidget(self.Ok_Button, x,y)
|
|
|
|
# add Cancel button
|
|
self.Cancel_Button = QtGui.QPushButton('Cancel', self)
|
|
self.Cancel_Button.clicked.connect(self.close)
|
|
self.grid.addWidget(self.Cancel_Button, x,y+1)
|
|
|
|
self.move(parent.frameGeometry().x() + parent.size().width()/2 - 150,\
|
|
parent.frameGeometry().y() + parent.size().height()/2 - 100)
|
|
self.setLayout(self.grid)
|
|
|
|
def ok_pressed(self):
|
|
row = self.table.rowCount()
|
|
self.table.setRowCount(row + 1);
|
|
# add widgets in table
|
|
for i in range (len(self.field.tablevalue.values.ChoiceValue)):
|
|
if type(self.widget_dict[str(i)]) == QtGui.QCheckBox:
|
|
pass
|
|
# self.table.setCellWidget(row, i, self.widget_dict[str(i)])
|
|
elif type(self.widget_dict[str(i)]) == CentralCheckBox:
|
|
self.table.setCellWidget(row, i, self.widget_dict[str(i)])
|
|
|
|
elif type(self.widget_dict[str(i)]) == QtGui.QComboBox:
|
|
self.table.setCellWidget(row, i, self.widget_dict[str(i)])
|
|
|
|
elif type(self.widget_dict[str(i)]) == QtGui.QLineEdit:
|
|
self.table_widget.setItem(row, i, QtGui.QTableWidgetItem \
|
|
(self.widget_dict[str(i)].text()))
|
|
|
|
elif type(self.widget_dict[str(i)]) == MultipleChoice:
|
|
self.table.setCellWidget(row, i, self.widget_dict[str(i)])
|
|
|
|
# adding in table 'readonly' values
|
|
diff = self.table.columnCount() - len(self.field.tablevalue.values.ChoiceValue)
|
|
for j in range (diff):
|
|
column = i + j + 1
|
|
tablewidgetitem = QtGui.QTableWidgetItem()
|
|
self.table.setItem(row, column, tablewidgetitem)
|
|
|
|
self.table.item(row, column).setFlags(QtCore.Qt.ItemIsEditable)
|
|
font = self.table.item(row, column).font()
|
|
font.setWeight(QtGui.QFont.Black)
|
|
self.table.item(row, column).setFont(font)
|
|
|
|
self.close()
|
|
|
|
def _(s):
|
|
return s
|
|
|
|
def show_msg(text, title = None):
|
|
msgBox = QtGui.QMessageBox()
|
|
if title:
|
|
msgBox.setWindowTitle(_(title))
|
|
if type(text) != str:
|
|
temp = ''
|
|
for i in text:
|
|
temp += str(i).decode('utf-8')
|
|
text = temp
|
|
msgBox.setText(_(text))
|
|
msgBox.setStandardButtons(QtGui.QMessageBox.Ok)
|
|
msgBox.exec_()
|
|
|
|
def show_question(parent, text, informative_text):
|
|
msgBox = QtGui.QMessageBox()
|
|
msgBox.setText(_(text))
|
|
msgBox.setInformativeText(_(informative_text))
|
|
msgBox.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
|
msgBox.setDefaultButton(QtGui.QMessageBox.No)
|
|
msgBox.move(parent.frameGeometry().x() + parent.size().width()/2 - 150,\
|
|
parent.frameGeometry().y() + parent.size().height()/2 - 100)
|
|
|
|
reply = msgBox.exec_()
|
|
return reply
|
|
|
|
def uniq(seq):
|
|
seen = set()
|
|
seen_add = seen.add
|
|
return [ x for x in seq if x not in seen and not seen_add(x)]
|
|
|
|
def client_signal(client):
|
|
Vars = DataVarsApi()
|
|
Vars.importApi()
|
|
Vars.flIniFile()
|
|
try:
|
|
client_active = Vars.Get('cl_api_client_active_period')
|
|
except:
|
|
show_msg('Write cl_api_client_active_period Error!')
|
|
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)
|
|
if reply:
|
|
print "Error 'active client' in server!"
|
|
return
|
|
except:
|
|
show_msg ('no connection to server!')
|
|
sys.exit()
|
|
time.sleep(float(client_active))
|
|
|
|
class VerifyError(Exception):
|
|
def __init__(self, value):
|
|
self.value = value
|
|
def __str__(self):
|
|
return repr(self.value)
|
|
|
|
def client_post_auth(client):
|
|
""" authorization client or post request """
|
|
try:
|
|
if os.path.exists(client.CERT_FILE) :
|
|
pass
|
|
else:
|
|
show_msg ("You do not have a certificate. Use certificates in toolbar "
|
|
"for generate new certificate or for get new certificate "
|
|
"from server.")
|
|
return 1
|
|
except VerifyError, e:
|
|
show_msg (e.value)
|
|
return 1
|
|
return 0
|
|
|
|
def https_server(client, signaling, ClientObj):
|
|
global url
|
|
if client_post_auth(client):
|
|
# Exit with closing session
|
|
client_del_sid(ClientObj.client)
|
|
ClientObj.client = None
|
|
|
|
ClientObj.MainWidget.process_dict = {}
|
|
return 1
|
|
signaling.start()
|
|
|
|
# Add Icons in MainMenu
|
|
icon_visible(ClientObj.MainWidget, '&Disconnect', True)
|
|
icon_visible(ClientObj.MainWidget, '&Processes view', True)
|
|
icon_visible(ClientObj.MainWidget, '&Session view', True)
|
|
icon_visible(ClientObj.MainWidget, '&Certificates', False)
|
|
|
|
ClientObj.methods_list = client_list_methods(client)
|
|
if ClientObj.methods_list == 1:
|
|
show_msg ('No methods available!')
|
|
else:
|
|
RES = 0 # Access to result
|
|
COM = 0 # Getting command line
|
|
METH = 1 # Getting method line
|
|
for num in range (0, len(ClientObj.methods_list)):
|
|
print " %s - %s" % (ClientObj.methods_list[num][RES][COM],\
|
|
ClientObj.methods_list[num][RES][METH])
|
|
ClientObj.MainWidget.display_methods()
|
|
# ClientObj.MainWidget.main_frame.refresh(ClientObj.methods_list)
|
|
|
|
ClientObj.MainWidget.resize \
|
|
(ClientObj.MainWidget.size_x, ClientObj.MainWidget.size_y)
|
|
|
|
# ClientObj.MainWidget.topleft.menu.refresh(ClientObj.methods_list)
|
|
# get_entire_frame(client)
|
|
|
|
def icon_visible (mainwgt, name, action):
|
|
# Add disconnect Icon in MainMenu
|
|
act = mainwgt.toolbar.actions()
|
|
for i in act:
|
|
if i.text() == name:
|
|
i.setVisible(action)
|
|
break
|
|
#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) |