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)
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 ca_root in open(system_ca_db, 'r').read():
return 0
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')
cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath)
@ -340,8 +340,8 @@ class CertClass (QtGui.QWidget):
fd.write(ca_root)
fd.close()
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)
fa = open(user_root_cert, 'a')
fa.write(ca_root)

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

@ -212,6 +212,11 @@ class DisplayMethod(QtGui.QWidget):
self._parent.main_frame.viewport().palette()
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()
# view_method_name = self.sender().text()
step = 0
@ -222,10 +227,6 @@ class DisplayMethod(QtGui.QWidget):
if self.ClientObj.param_objects.has_key(method_name):
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, \
str(method_name + '_view'), step = step, brief = brief)
self.onActivated_thread = ClientServiceThread(self.ClientObj, \
@ -235,6 +236,8 @@ class DisplayMethod(QtGui.QWidget):
self.onActivated_thread.start()
def onActivated_after(self, view):
self.setDisabled(False)
#self.con_lost_lbl.hide()
if type(view) == Exception:
if hasattr (view.message, 'message'):
view = view.message
@ -370,4 +373,4 @@ class ConnectLostLabel (QtGui.QWidget):
self.reconnect_button.move(cur_size.width()/2 - \
self.reconnect_button.sizeHint().width()/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
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)
# other variable
@ -132,7 +132,7 @@ class ApiClient(QtGui.QWidget):
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
pass
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)
try:

@ -38,6 +38,7 @@ class SelectedTableWidget(QtGui.QTableWidget):
QtGui.QTableWidget.__init__(self, rows, columns, parent)
self.currHovered = -1
self.brief = brief
self.bFixedHeight = True
delegate = Delegate()
delegate.setView(self)
@ -130,4 +131,4 @@ class SelectedTableWidget(QtGui.QTableWidget):
"background-color: #E4E1E0;}"
"QTableWidget::item {padding: 0px;"
"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)
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')
cl_client_cert_dir = cl_client_cert_dir.replace("~",homePath)
root_cert_dir = cl_client_cert_dir + "/ca"
@ -227,7 +228,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
self.sock = sock
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')
user_root_cert = user_root_cert.replace("~",homePath)
result_user_root = 1
@ -238,7 +239,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
user_root_cert, self.CRL_PATH)
if result_user_root == 1:
glob_root_cert = self.ClientObj.VarsApi.Get \
('cl_glob_root_cert')
('core.cl_glob_root_cert')
result_root_con = 1
if os.path.exists(glob_root_cert):
sock = socket.create_connection((self.host, self.port),
@ -314,19 +315,22 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
def add_all_ca_cert(self, list_ca_certs):
# so root cert be first, ca after
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)
root_cert_md5 = cl_client_cert_dir + "/ca/cert_list"
list_ca_certs.reverse()
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 cert in open(system_ca_db, 'r').read():
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)
if os.path.exists(user_root_cert):
if cert in open(user_root_cert, 'r').read():
@ -643,11 +647,11 @@ def get_CRL(path_to_cert):
clVars.importCore()
clVars.flIniFile()
# 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')
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):
user_ca_certs = open(user_root_cert, 'r').read()
@ -748,12 +752,12 @@ def rm_ca_from_trusted(ca_cert):
clVars.importCore()
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')
user_ca_dir = user_ca_dir.replace("~",homePath)
user_ca_dir = os.path.join(user_ca_dir, 'ca')
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')
user_ca_db = user_ca_db.replace("~",homePath)

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

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

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

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

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

Loading…
Cancel
Save