Using new datavars

Disable select method if method already selected and wait server response
Change SelectTable style and autoresizing
master3.3
parent ce678fb31a
commit a30754ae23

@ -285,13 +285,13 @@ class CertClass (QtGui.QWidget):
show_msg (_('Certificate saved. Your certificate ID = %s') %req_id) show_msg (_('Certificate saved. Your certificate ID = %s') %req_id)
if ca_root: if ca_root:
system_ca_db = self.ClientObj.VarsApi.Get('cl_glob_root_cert') system_ca_db = self.ClientObj.VarsApi.Get('core.cl_glob_root_cert')
if os.path.exists(system_ca_db): if os.path.exists(system_ca_db):
if ca_root in open(system_ca_db, 'r').read(): if ca_root in open(system_ca_db, 'r').read():
return 0 return 0
cl_client_cert_dir = self.ClientObj.VarsApi.Get \ cl_client_cert_dir = self.ClientObj.VarsApi.Get \
('cl_client_cert_dir') ('core.cl_client_cert_dir')
homePath = self.ClientObj.VarsApi.Get('ur_home_path') homePath = self.ClientObj.VarsApi.Get('ur_home_path')
cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath) cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath)
@ -340,8 +340,8 @@ class CertClass (QtGui.QWidget):
fd.write(ca_root) fd.write(ca_root)
fd.close() fd.close()
user_root_cert = self.ClientObj.VarsApi.Get \ user_root_cert = \
('cl_user_root_cert') self.ClientObj.VarsApi.Get('core.cl_user_root_cert')
user_root_cert = user_root_cert.replace("~",homePath) user_root_cert = user_root_cert.replace("~",homePath)
fa = open(user_root_cert, 'a') fa = open(user_root_cert, 'a')
fa.write(ca_root) fa.write(ca_root)

@ -272,6 +272,9 @@ class ControlButtonWgt(QtGui.QWidget):
try: try:
res = self.ClientObj.client.service.clear_method_cache \ res = self.ClientObj.client.service.clear_method_cache \
(sid, method) (sid, method)
lerror = self.ClientObj.param_objects[method]['error']
while len(lerror)>0:
lerror.pop()
except Exception as e: except Exception as e:
_print (e) _print (e)
from calculate.consolegui.application.ConnectionTabs \ from calculate.consolegui.application.ConnectionTabs \

@ -212,6 +212,11 @@ class DisplayMethod(QtGui.QWidget):
self._parent.main_frame.viewport().palette() self._parent.main_frame.viewport().palette()
def onActivated(self): def onActivated(self):
# Call server method
if hasattr (self, 'onActivated_thread'):
if self.onActivated_thread.isRunning():
return 1
self.setDisabled(True)
method_name = self.sender().objectName() method_name = self.sender().objectName()
# view_method_name = self.sender().text() # view_method_name = self.sender().text()
step = 0 step = 0
@ -222,10 +227,6 @@ class DisplayMethod(QtGui.QWidget):
if self.ClientObj.param_objects.has_key(method_name): if self.ClientObj.param_objects.has_key(method_name):
self.ClientObj.param_objects[method_name]['step'] = 0 self.ClientObj.param_objects[method_name]['step'] = 0
# Call server method
if hasattr (self, 'onActivated_thread'):
if self.onActivated_thread.isRunning():
return 1
view_params = get_view_params(self.ClientObj.client, \ view_params = get_view_params(self.ClientObj.client, \
str(method_name + '_view'), step = step, brief = brief) str(method_name + '_view'), step = step, brief = brief)
self.onActivated_thread = ClientServiceThread(self.ClientObj, \ self.onActivated_thread = ClientServiceThread(self.ClientObj, \
@ -235,6 +236,8 @@ class DisplayMethod(QtGui.QWidget):
self.onActivated_thread.start() self.onActivated_thread.start()
def onActivated_after(self, view): def onActivated_after(self, view):
self.setDisabled(False)
#self.con_lost_lbl.hide()
if type(view) == Exception: if type(view) == Exception:
if hasattr (view.message, 'message'): if hasattr (view.message, 'message'):
view = view.message view = view.message
@ -370,4 +373,4 @@ class ConnectLostLabel (QtGui.QWidget):
self.reconnect_button.move(cur_size.width()/2 - \ self.reconnect_button.move(cur_size.width()/2 - \
self.reconnect_button.sizeHint().width()/2,\ self.reconnect_button.sizeHint().width()/2,\
cur_size.height()/2 + \ cur_size.height()/2 + \
self.reconnect_button.sizeHint().height()) self.reconnect_button.sizeHint().height())

@ -44,7 +44,7 @@ class ApiClient(QtGui.QWidget):
# Initialization other variables # Initialization other variables
self.homePath = self.VarsGui.Get('ur_home_path') self.homePath = self.VarsGui.Get('ur_home_path')
path_to_cert = self.VarsGui.Get('cl_client_cert_dir') path_to_cert = self.VarsGui.Get('core.cl_client_cert_dir')
self.path_to_cert = path_to_cert.replace("~",self.homePath) self.path_to_cert = path_to_cert.replace("~",self.homePath)
# other variable # other variable
@ -132,7 +132,7 @@ class ApiClient(QtGui.QWidget):
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
pass pass
if self.path_to_cert.lower() == 'no': if self.path_to_cert.lower() == 'no':
path_to_cert = self.VarsGui.Get('cl_client_cert_dir') path_to_cert = self.VarsGui.Get('core.cl_client_cert_dir')
self.path_to_cert = path_to_cert.replace("~",self.homePath) self.path_to_cert = path_to_cert.replace("~",self.homePath)
try: try:

@ -38,6 +38,7 @@ class SelectedTableWidget(QtGui.QTableWidget):
QtGui.QTableWidget.__init__(self, rows, columns, parent) QtGui.QTableWidget.__init__(self, rows, columns, parent)
self.currHovered = -1 self.currHovered = -1
self.brief = brief self.brief = brief
self.bFixedHeight = True
delegate = Delegate() delegate = Delegate()
delegate.setView(self) delegate.setView(self)
@ -130,4 +131,4 @@ class SelectedTableWidget(QtGui.QTableWidget):
"background-color: #E4E1E0;}" "background-color: #E4E1E0;}"
"QTableWidget::item {padding: 0px;" "QTableWidget::item {padding: 0px;"
"border-left: 1px solid #B3ABA7;" "border-left: 1px solid #B3ABA7;"
"background-color: rgba(255,255,255,255);}") "background-color: rgba(255,255,255,255);}")

@ -174,7 +174,8 @@ class AddServerCert (QtGui.QDialog):
self.ConnectWidget.connect_to_host(host, self.ClientObj.port) self.ConnectWidget.connect_to_host(host, self.ClientObj.port)
def add_ca(self): def add_ca(self):
cl_client_cert_dir = self.ClientObj.VarsApi.Get('cl_client_cert_dir') cl_client_cert_dir = \
self.ClientObj.VarsApi.Get('core.cl_client_cert_dir')
homePath = self.ClientObj.VarsApi.Get('ur_home_path') homePath = self.ClientObj.VarsApi.Get('ur_home_path')
cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath) cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath)
root_cert_dir = cl_client_cert_dir + "/ca" root_cert_dir = cl_client_cert_dir + "/ca"
@ -227,7 +228,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
self.sock = sock self.sock = sock
self._tunnel() self._tunnel()
user_root_cert = self.ClientObj.VarsApi.Get('cl_user_root_cert') user_root_cert = self.ClientObj.VarsApi.Get('core.cl_user_root_cert')
homePath = self.ClientObj.VarsApi.Get('ur_home_path') homePath = self.ClientObj.VarsApi.Get('ur_home_path')
user_root_cert = user_root_cert.replace("~",homePath) user_root_cert = user_root_cert.replace("~",homePath)
result_user_root = 1 result_user_root = 1
@ -238,7 +239,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
user_root_cert, self.CRL_PATH) user_root_cert, self.CRL_PATH)
if result_user_root == 1: if result_user_root == 1:
glob_root_cert = self.ClientObj.VarsApi.Get \ glob_root_cert = self.ClientObj.VarsApi.Get \
('cl_glob_root_cert') ('core.cl_glob_root_cert')
result_root_con = 1 result_root_con = 1
if os.path.exists(glob_root_cert): if os.path.exists(glob_root_cert):
sock = socket.create_connection((self.host, self.port), sock = socket.create_connection((self.host, self.port),
@ -314,19 +315,22 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
def add_all_ca_cert(self, list_ca_certs): def add_all_ca_cert(self, list_ca_certs):
# so root cert be first, ca after # so root cert be first, ca after
homePath = self.ClientObj.VarsApi.Get('ur_home_path') homePath = self.ClientObj.VarsApi.Get('ur_home_path')
cl_client_cert_dir = self.ClientObj.VarsApi.Get('cl_client_cert_dir') cl_client_cert_dir = \
self.ClientObj.VarsApi.Get('core.cl_client_cert_dir')
cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath) cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath)
root_cert_md5 = cl_client_cert_dir + "/ca/cert_list" root_cert_md5 = cl_client_cert_dir + "/ca/cert_list"
list_ca_certs.reverse() list_ca_certs.reverse()
for cert in list_ca_certs: for cert in list_ca_certs:
system_ca_db = self.ClientObj.VarsApi.Get('cl_glob_root_cert') system_ca_db = \
self.ClientObj.VarsApi.Get('core.cl_glob_root_cert')
if os.path.exists(system_ca_db): if os.path.exists(system_ca_db):
if cert in open(system_ca_db, 'r').read(): if cert in open(system_ca_db, 'r').read():
continue continue
user_root_cert = self.ClientObj.VarsApi.Get('cl_user_root_cert') user_root_cert = \
self.ClientObj.VarsApi.Get('core.cl_user_root_cert')
user_root_cert = user_root_cert.replace("~",homePath) user_root_cert = user_root_cert.replace("~",homePath)
if os.path.exists(user_root_cert): if os.path.exists(user_root_cert):
if cert in open(user_root_cert, 'r').read(): if cert in open(user_root_cert, 'r').read():
@ -643,11 +647,11 @@ def get_CRL(path_to_cert):
clVars.importCore() clVars.importCore()
clVars.flIniFile() clVars.flIniFile()
# user and system ca and root certificates # user and system ca and root certificates
user_root_cert = clVars.Get('cl_user_root_cert') user_root_cert = clVars.Get('core.cl_user_root_cert')
homePath = clVars.Get('ur_home_path') homePath = clVars.Get('ur_home_path')
user_root_cert = user_root_cert.replace("~",homePath) user_root_cert = user_root_cert.replace("~",homePath)
glob_root_cert = clVars.Get('cl_glob_root_cert') glob_root_cert = clVars.Get('core.cl_glob_root_cert')
if os.path.exists(user_root_cert): if os.path.exists(user_root_cert):
user_ca_certs = open(user_root_cert, 'r').read() user_ca_certs = open(user_root_cert, 'r').read()
@ -748,12 +752,12 @@ def rm_ca_from_trusted(ca_cert):
clVars.importCore() clVars.importCore()
clVars.flIniFile() clVars.flIniFile()
user_ca_dir = clVars.Get('cl_client_cert_dir') user_ca_dir = clVars.Get('core.cl_client_cert_dir')
homePath = clVars.Get('ur_home_path') homePath = clVars.Get('ur_home_path')
user_ca_dir = user_ca_dir.replace("~",homePath) user_ca_dir = user_ca_dir.replace("~",homePath)
user_ca_dir = os.path.join(user_ca_dir, 'ca') user_ca_dir = os.path.join(user_ca_dir, 'ca')
user_ca_list = os.path.join(user_ca_dir, 'cert_list') user_ca_list = os.path.join(user_ca_dir, 'cert_list')
user_ca_db = clVars.Get('cl_user_root_cert') user_ca_db = clVars.Get('core.cl_user_root_cert')
homePath = clVars.Get('ur_home_path') homePath = clVars.Get('ur_home_path')
user_ca_db = user_ca_db.replace("~",homePath) user_ca_db = user_ca_db.replace("~",homePath)

@ -384,7 +384,7 @@ class FrameConnection(QtGui.QWidget):
try: try:
self.ClientObj.client.frame_period = \ self.ClientObj.client.frame_period = \
int(self.ClientObj.VarsApi.Get \ int(self.ClientObj.VarsApi.Get \
('cl_core_get_frame_period')) ('core.cl_core_get_frame_period'))
except: except:
self.ClientObj.client.frame_period = 2 self.ClientObj.client.frame_period = 2
self.ClientObj.host_name = host_name self.ClientObj.host_name = host_name

@ -162,6 +162,7 @@ class MainFrame(QtGui.QWidget):
if self.isBrief(): if self.isBrief():
self.print_brief(self.view.groups.GroupField, x) self.print_brief(self.view.groups.GroupField, x)
return return
lastTable = None
for Group in self.view.groups.GroupField: for Group in self.view.groups.GroupField:
if Group.name: if Group.name:
self.group_name_label = LabelWordWrap(Group.name, self) self.group_name_label = LabelWordWrap(Group.name, self)
@ -173,6 +174,9 @@ class MainFrame(QtGui.QWidget):
x += 1 x += 1
for field in Group.fields.Field: for field in Group.fields.Field:
if lastTable:
self.resize_table(lastTable)
lastTable = None
# add element in frame # add element in frame
if field.element == 'label': if field.element == 'label':
self.add_element_label (field, x, y) self.add_element_label (field, x, y)
@ -247,6 +251,7 @@ class MainFrame(QtGui.QWidget):
elif field.element == 'table' and field.type != 'steps': elif field.element == 'table' and field.type != 'steps':
self.add_element_table (field, x, y) self.add_element_table (field, x, y)
lastTable = self.view_dict[field.name]
x += 3 x += 3
if field.type == 'writable': if field.type == 'writable':
x += 1 x += 1
@ -258,6 +263,9 @@ class MainFrame(QtGui.QWidget):
c = 1 if hasattr(self, 'group_name_label') else 0 c = 1 if hasattr(self, 'group_name_label') else 0
if lastTable:
lastTable.bFixedHeight = False
self.resize_table(lastTable)
# When used page_offset and page_count # When used page_offset and page_count
if self.grid.count() <= c: if self.grid.count() <= c:
# call_button = QtGui.QPushButton(self) # call_button = QtGui.QPushButton(self)
@ -302,13 +310,14 @@ class MainFrame(QtGui.QWidget):
[self.method_name] ['steps_field']) [self.method_name] ['steps_field'])
self.ClientObj.MainWidget.left_frame.changed_step \ self.ClientObj.MainWidget.left_frame.changed_step \
(self.ClientObj.param_objects[self.method_name]['step']) (self.ClientObj.param_objects[self.method_name]['step'])
self.grid.addItem(QtGui.QSpacerItem( 0, 0, QtGui.QSizePolicy.\ if not lastTable:
Expanding, QtGui.QSizePolicy.Expanding), x+1, y, 1, 2) self.grid.addItem(QtGui.QSpacerItem( 0, 0, QtGui.QSizePolicy.\
Expanding, QtGui.QSizePolicy.Expanding), x+1, y, 1, 2)
self.common_layout.addLayout(self.grid) self.common_layout.addLayout(self.grid)
# add spacer # add spacer
self.common_layout.addItem(QtGui.QSpacerItem( 0, 0, \ #self.common_layout.addItem(QtGui.QSpacerItem( 0, 0, \
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) # QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding))
self.update() self.update()
self.ClientObj.app.processEvents() self.ClientObj.app.processEvents()
self.updateGeometry() self.updateGeometry()
@ -1307,7 +1316,8 @@ class MainFrame(QtGui.QWidget):
brief) brief)
minimum = QtGui.QSizePolicy.Minimum minimum = QtGui.QSizePolicy.Minimum
self.table_widget.setSizePolicy(minimum, minimum) expanding = QtGui.QSizePolicy.Expanding
self.table_widget.setSizePolicy(minimum, expanding)
self.view_dict[field.name] = self.table_widget self.view_dict[field.name] = self.table_widget
self.label_dict[field.name] = LabelWordWrap(field.label, self) self.label_dict[field.name] = LabelWordWrap(field.label, self)
@ -1420,8 +1430,8 @@ class MainFrame(QtGui.QWidget):
self.view_dict[field.name].hideColumn(0) self.view_dict[field.name].hideColumn(0)
# set width column # set width column
self.view_dict[field.name].horizontalHeader().resizeSections\ #self.view_dict[field.name].horizontalHeader().resizeSections\
(QtGui.QHeaderView.ResizeMode.ResizeToContents) # (QtGui.QHeaderView.ResizeMode.ResizeToContents)
# No Selection # No Selection
self.view_dict[field.name].setSelectionMode \ self.view_dict[field.name].setSelectionMode \
@ -1437,8 +1447,6 @@ class MainFrame(QtGui.QWidget):
unit_widget.setToolTip(field.uncompatible) unit_widget.setToolTip(field.uncompatible)
unit_widget.setDisabled(True) unit_widget.setDisabled(True)
# Resize table
self.resize_table(self.table_widget)
self.table_widget.setColor() self.table_widget.setColor()
wfg_layout.addWidget(self.view_dict[field.name]) wfg_layout.addWidget(self.view_dict[field.name])
@ -1674,12 +1682,13 @@ class MainFrame(QtGui.QWidget):
def resize_table(self, table): def resize_table(self, table):
# Resize table # Resize table
h = table.horizontalHeader().height() + \ if table.bFixedHeight:
2 * table.frameWidth() h = table.horizontalHeader().height() + \
h += table.horizontalScrollBar().height() 2 * table.frameWidth()
for row_in_table in range (table.rowCount()): h += table.horizontalScrollBar().height()
h += table.rowHeight(row_in_table) for row_in_table in range (table.rowCount()):
table.setFixedHeight(h) h += table.rowHeight(row_in_table)
table.setFixedHeight(h)
table.horizontalHeader().resizeSections\ table.horizontalHeader().resizeSections\
(QtGui.QHeaderView.ResizeMode.ResizeToContents) (QtGui.QHeaderView.ResizeMode.ResizeToContents)
table.setColumnWidth(0, 40) table.setColumnWidth(0, 40)
@ -1917,6 +1926,7 @@ class MainFrame(QtGui.QWidget):
field.default = False field.default = False
self.add_element_table (field, x, y, brief = True, self.add_element_table (field, x, y, brief = True,
gb_layout = gb_layout) gb_layout = gb_layout)
self.resize_table(self.view_dict[field.name])
x += 3 x += 3
if field.type == 'writable': if field.type == 'writable':
x += 1 x += 1

@ -2058,12 +2058,13 @@ class PlusRow (QtGui.QWidget):
self._parent.add_select_check(self.table) self._parent.add_select_check(self.table)
# Resize table # Resize table
h = self.table.horizontalHeader().height() + \ if self.table.bFixedHeight:
2 * self.table.frameWidth() h = self.table.horizontalHeader().height() + \
h += self.table.horizontalScrollBar().height() 2 * self.table.frameWidth()
for row_in_table in range (self.table.rowCount()): h += self.table.horizontalScrollBar().height()
h += self.table.rowHeight(row_in_table) for row_in_table in range (self.table.rowCount()):
self.table.setFixedHeight(h) h += self.table.rowHeight(row_in_table)
self.table.setFixedHeight(h)
if self.table.rowCount() == 1: if self.table.rowCount() == 1:
self.table.horizontalHeader().resizeSections\ self.table.horizontalHeader().resizeSections\
@ -2399,7 +2400,7 @@ class ClientSignal(QtCore.QThread):
self.ClientObj.has_connect = None self.ClientObj.has_connect = None
try: try:
client_active = self.ClientObj.VarsApi.Get \ client_active = self.ClientObj.VarsApi.Get \
('cl_core_client_active_period') ('core.cl_core_client_active_period')
except: except:
show_msg('Write cl_core_client_active_period Error!') show_msg('Write cl_core_client_active_period Error!')
client_active = 15 client_active = 15
@ -2708,4 +2709,4 @@ def getRunProc():
return [] return []
return map(getCmd, return map(getCmd,
filter(lambda x:x.isdigit(), filter(lambda x:x.isdigit(),
listDirectory('/proc'))) listDirectory('/proc')))

@ -23,7 +23,6 @@ class DataVarsGui(DataVars):
"""Variable class for installation""" """Variable class for installation"""
def importGui(self, **args): def importGui(self, **args):
'''Заполнить конфигурацию переменных, для десктопа'''
self.importData() self.importData()
self.importData('calculate.core.variables')
self.importData('calculate.consolegui.variables') self.importData('calculate.consolegui.variables')
self.defaultModule = "consolegui"

@ -14,21 +14,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from calculate.lib.datavars import ReadonlyVariable
from calculate.consolegui.datavars import __version__,__app__
import console import console
section = "gui" section = "consolegui"
class VariableClName(ReadonlyVariable):
"""
Package name
"""
value = __app__
class VariableClVer(ReadonlyVariable):
"""
Package version
"""
value = __version__

Loading…
Cancel
Save