python 2 to 3

Py3
idziubenko 3 years ago
parent b701c235d3
commit 411e283d03

@ -1,15 +1,18 @@
#!/usr/bin/env python2
#!/usr/bin/env python
#-*- coding: utf-8 -*-
from __future__ import print_function
import sys, os, pwd
from calculate.consolegui import qt
from importlib import reload
from calculate.consolegui.application.more import getRunProc, owner, _print
import __builtin__
# import __builtin__
import builtins as __builtin__
import dbus
import dbus.mainloop.glib
reload(sys)
sys.setdefaultencoding("utf-8")
# always utf-8 in py3
# sys.setdefaultencoding("utf-8")
from calculate.lib.cl_lang import setLocalTranslate
setLocalTranslate('console_gui',sys.modules[__name__])
@ -56,12 +59,12 @@ def main():
# Get the session bus
try:
bus = dbus.SessionBus()
except dbus.exceptions.DBusException, e:
except dbus.exceptions.DBusException as e:
bus = None
if not os.getuid():
_print (_('The user must not be root'))
else:
print e
print(e)
sys.exit(1)
iface = None
@ -82,7 +85,7 @@ def main():
if not '--method' in run_commands[0] and pwd.getpwuid(os.getuid())\
.pw_name == owner(run_commands[1]):
if second:
print 'Client already running'
print('Client already running')
if iface:
# Call some methods of the remote interface
iface.show()

@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org

@ -14,25 +14,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
from calculate.consolegui import qt
import urllib2
import urllib.request as urllib2
from DisplayMethod import DisplayMethod, StartWidget, ConnectLostLabel
from mainframe import MainFrame
from mainmenu import MainMenu
from ControlButton import MethodNameWgt, ControlButtonWgt
from helpwidget import HelpWgt, BugWgt
from tools import ToolsWidget
from .DisplayMethod import DisplayMethod, StartWidget, ConnectLostLabel
from .mainframe import MainFrame
from .mainmenu import MainMenu
from .ControlButton import MethodNameWgt, ControlButtonWgt
from .helpwidget import HelpWgt, BugWgt
from .tools import ToolsWidget
from conf_connection import FrameConnection
from LeftMenu import LeftMenu
from MainFrameResult import MainFrameRes
from View_Process import ViewProc
from session_function import ViewSessionInfo
from CertificateClass import CertClass
from .conf_connection import FrameConnection
from .LeftMenu import LeftMenu
from .MainFrameResult import MainFrameRes
from .View_Process import ViewProc
from .session_function import ViewSessionInfo
from .CertificateClass import CertClass
from pid_information import client_list_pid
from more import icon_visible, client_del_sid, show_msg, get_icon
from .pid_information import client_list_pid
from .more import icon_visible, client_del_sid, show_msg, get_icon
DEBUG_LEVEL = 0
@ -40,8 +42,8 @@ DEBUG_LEVEL = 0
def debug(level, *args):
if level <= DEBUG_LEVEL:
for s in args:
print s,
print
print(s, end=' ')
print()
class MainWgt(qt.QMainWindow):
def __init__(self, ClientObj):
@ -315,7 +317,7 @@ class MainWgt(qt.QMainWindow):
TempMainFrameWgt.analysis(meth_result)
except (RuntimeError, ValueError):
pass
except urllib2.URLError, e:
except urllib2.URLError as e:
show_msg(e, 'URLError')
else:
@ -331,7 +333,7 @@ class MainWgt(qt.QMainWindow):
self.MainFrameWgt.analysis(meth_result)
except (RuntimeError, ValueError):
pass
except urllib2.URLError, e:
except urllib2.URLError as e:
show_msg(e, 'URLError')
def main_view_process(self, method_name, meth_result, pid):

@ -14,13 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
import urllib2
import urllib.request as urllib2
import OpenSSL, hashlib
from more import show_msg, LabelWordWrap, show_question, get_ip_mac, get_icon
from create_cert import RequestCreate
from client_class import HTTPSClientCertTransport, Client_suds
from .more import show_msg, LabelWordWrap, show_question, get_ip_mac, get_icon
from .create_cert import RequestCreate
from .client_class import HTTPSClientCertTransport, Client_suds
from calculate.lib.utils.files import readFile
import os
@ -130,13 +131,12 @@ class CertClass (qt.QWidget):
self.client = Client_suds(url, \
transport = HTTPSClientCertTransport(None, None, \
cert_path, parent = self.ClientObj))
except (KeyboardInterrupt, urllib2.URLError), e:
except (KeyboardInterrupt, urllib2.URLError) as e:
try:
show_msg(e.reason.strerror.decode('utf-8') \
, _("Closing. Connection error."), self)
# show_msg(e.reason.strerror.decode('utf-8'), _("Closing. Connection error."), self)
show_msg(e.reason.strerror, _("Closing. Connection error."), self)
except (UnicodeDecodeError, UnicodeEncodeError):
show_msg(e.reason.strerror, \
_("Closing. Connection error."), self)
show_msg(e.reason.strerror, _("Closing. Connection error."), self)
return 1
except (UnicodeDecodeError, UnicodeEncodeError):
show_msg (_('Enter the hostname or the IP address'),
@ -147,7 +147,7 @@ class CertClass (qt.QWidget):
server_host_name = self.client.service.get_server_host_name()
except AttributeError:
return 1
except urllib2.URLError, e:
except urllib2.URLError as e:
_print ('method send in CertificateClass Exception')
show_msg (e, _("Not connected!"), self)
return 1
@ -181,7 +181,7 @@ class CertClass (qt.QWidget):
try:
res = self.client.service.post_client_request(request = data, \
ip = ip, mac = mac, client_type = 'gui')
except urllib2.URLError, e:
except urllib2.URLError as e:
_print ('method end_send in CertificateClass Exception')
show_msg (e, _("Not connected!"), self)
return 1
@ -226,7 +226,7 @@ class CertClass (qt.QWidget):
client = Client_suds(url, \
transport = HTTPSClientCertTransport(None, None, \
cert_path, parent = self.ClientObj))
except (KeyboardInterrupt, urllib2.URLError), e:
except (KeyboardInterrupt, urllib2.URLError) as e:
show_msg(_("Error code: %s") %e, _("Closing. Connection error."),\
self)
return 1
@ -237,7 +237,7 @@ class CertClass (qt.QWidget):
client.wsdl.services[0].setlocation(url)
try:
server_host_name = client.service.get_server_host_name()
except urllib2.URLError, e:
except urllib2.URLError as e:
_print ('method get in CertificateClass Exception')
show_msg (e, _("Not connected!"), self)
return 1
@ -254,7 +254,7 @@ class CertClass (qt.QWidget):
try:
result = client.service.get_client_cert(req_id, md5sum)
except urllib2.URLError, e:
except urllib2.URLError as e:
_print ('get_client_cert in CertificateClass Exception')
show_msg (e, _("Not connected!"))
return 1
@ -262,7 +262,7 @@ class CertClass (qt.QWidget):
cert = result[0][0]
try:
ca_root = result[0][1]
except Exception, e:
except Exception as e:
ca_root = None
# show_msg(e.message)
if cert == '1':

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
import dbus
import dbus.service
import dbus.mainloop.glib
@ -23,19 +25,22 @@ import time, sys
import calculate.contrib
from suds import MethodNotFound
import os, pwd, shutil
import ConfigParser
# import ConfigParser
import calculate.lib.configparser as ConfigParser
from TrayIcon import TrayIcon
from more import get_sid, get_view_params, _print, get_icon, get_system_rgb, \
from .TrayIcon import TrayIcon
from .more import get_sid, get_view_params, _print, get_icon, get_system_rgb, \
dpivalue
from MainClass import ApiClient
from .MainClass import ApiClient
from calculate.consolegui.datavars import DataVarsGui
from pid_information import client_pid_info
from .pid_information import client_pid_info
#from calculate.lib.cl_lang import setLocalTranslate
#setLocalTranslate('console_gui',sys.modules[__name__])
import gettext
_ = gettext.gettext
class SelectedMethodWgt(qt.QWidget):
def __init__(self, app, args):
qt.QWidget.__init__(self)
@ -100,7 +105,7 @@ class SelectedMethodWgt(qt.QWidget):
_print('Method not found: ', self.args.method + '_view')
self.close()
sys.exit(1)
if self.ClientObj.method_names.has_key(self.args.method):
if self.args.method in self.ClientObj.method_names:
view_method = self.ClientObj.method_names[self.args.method]
else:
view_method = self.args.method
@ -119,7 +124,7 @@ class SelectedMethodWgt(qt.QWidget):
pass
def has_update(self, update):
print "Update", update
print("Update", update)
def get_size(self):
self.config = ConfigParser.ConfigParser()
@ -168,7 +173,7 @@ class SelectedMethodWgt(qt.QWidget):
else:
reply = self.show_close_messagebox()
from mainframe import MainFrame
from .mainframe import MainFrame
if reply == qt.QMessageBox.Yes:
if hasattr (self, 'con_lost_lbl'):
self.con_lost_lbl.hide()
@ -186,8 +191,7 @@ class SelectedMethodWgt(qt.QWidget):
self.ClientObj.client.service.pid_kill(pid, self.ClientObj.sid)
while True:
client_pid_info(self.ClientObj, self.ClientObj.client, 0)
if not self.ClientObj.process_dict[str(pid)].has_key \
('status'):
if 'status' not in self.ClientObj.process_dict[str(pid)]:
return 1
if self.ClientObj.process_dict[str(pid)]['status'] != '1':
return 1
@ -200,7 +204,7 @@ class SelectedMethodWgt(qt.QWidget):
def show_close_messagebox(self):
msgBox = qt.QMessageBox(self)
if self.ClientObj.method_names.has_key(self.method):
if self.method in self.ClientObj.method_names:
method_name = self.ClientObj.method_names[self.method]
else:
method_name = self.method
@ -222,16 +226,19 @@ class SelectedMethodWgt(qt.QWidget):
def parse():
import gettext
import locale
try:
set_lang = gettext.locale.getdefaultlocale()[0][:2]
# set_lang = gettext.locale.getdefaultlocale()[0][:2]
set_lang = locale.getdefaultlocale()[0][:2]
lang = gettext.translation('cl_consolegui3', languages=[set_lang],fallback=True)
try:
lang.install(unicode=True)
lang.install()
# lang.install(unicode=True)
except UnboundLocalError:
pass
except (IOError, TypeError):
pass
_ = gettext.gettext
import argparse
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument(
@ -495,7 +502,7 @@ class ToolTabWidget(qt.QTabWidget):
def translate(self, lang = None):
self.new_con_txt = _('New connection')
self.new_con_txt = self.new_con_txt.decode('utf-8')
# self.new_con_txt = self.new_con_txt.decode('utf-8')
current = self.currentIndex()
# not add if exists clean tab
@ -518,7 +525,7 @@ class ToolTabWidget(qt.QTabWidget):
def find_host(self, host_name, port):
ind = self.currentIndex()
for i in xrange (self.count() - 1):
for i in range (self.count() - 1):
self.setCurrentIndex(i)
wgt = self.currentWidget()
if hasattr (wgt, 'ClientObj'):
@ -561,7 +568,7 @@ class ToolTabWidget(qt.QTabWidget):
size = self.config.get('gui', 'size')
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
return False
tup_size = map(lambda x: int(x), size.split(','))
tup_size = list(map(lambda x: int(x), size.split(',')))
self.resize(tup_size[0], tup_size[1])
return True

@ -14,8 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
from calculate.consolegui import qt
from more import LabelWordWrap, _print, get_system_rgb, ParameterWindow, dpivalue
from .more import LabelWordWrap, _print, get_system_rgb, ParameterWindow, dpivalue
DEBUG_LEVEL = 0
@ -23,8 +25,8 @@ DEBUG_LEVEL = 0
def debug(level, *args):
if level <= DEBUG_LEVEL:
for s in args:
print s,
print
print(s, end=' ')
print()
class MethodNameWgt(qt.QWidget):
@ -200,7 +202,8 @@ class ControlButtonWgt(qt.QWidget):
else:
button = qt.QPushButton(self)
self.customs.append(button)
button.setText(field.label.decode('utf-8'))
# button.setText(field.label.decode('utf-8'))
button.setText(field.label)
button.clicked.connect(self.button_disabled)
button.clicked.connect(callback)
button.setMinimumWidth(62)
@ -241,9 +244,11 @@ class ControlButtonWgt(qt.QWidget):
main_frame = self._parent.MainFrameWgt
self.cancel_button = qt.QPushButton(self)
if main_frame.has_errors:
self.cancel_button.setText(_('Close').decode('utf-8'))
# self.cancel_button.setText(_('Close').decode('utf-8'))
self.cancel_button.setText(_('Close'))
else:
self.cancel_button.setText(_('Cancel').decode('utf-8'))
# self.cancel_button.setText(_('Cancel').decode('utf-8'))
self.cancel_button.setText(_('Cancel'))
self.cancel_button.clicked.connect(self.button_disabled)
self.cancel_button.clicked.connect(self.clear_method_cache)
@ -409,7 +414,7 @@ class ControlButtonWgt(qt.QWidget):
while len(lerror) > 0:
lerror.pop()
except Exception as e:
print e
print(e)
from calculate.consolegui.application.ConnectionTabs \
import SelectedMethodWgt

@ -14,9 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
from more import ButtonMenu, FlowLayout, get_sid, ClientServiceThread, \
from .more import ButtonMenu, FlowLayout, get_sid, ClientServiceThread, \
get_view_params, show_msg, client_list_methods, get_system_rgb, \
get_icon, dpivalue
@ -70,21 +71,25 @@ class DisplayMethod(qt.QWidget):
# display all groups and methods
for group in guiMethods:
if len (group.split('.')) > 1:
group_name = group.split('.')[0].encode('utf-8')
sub_group = group.split('.')[1].encode('utf-8')
if not self.groupbox_dict.has_key(group_name):
gb = qt.QGroupBox(group_name.decode('utf-8'), self)
# group_name = group.split('.')[0].encode('utf-8')
# sub_group = group.split('.')[1].encode('utf-8')
group_name = group.split('.')[0]
sub_group = group.split('.')[1]
if group_name not in self.groupbox_dict:
# gb = qt.QGroupBox(group_name.decode('utf-8'), self)
gb = qt.QGroupBox(group_name, self)
gb.setStyleSheet(groupbox_style)
gb.setAlignment(qt.Qt.AlignLeft)
self.groupbox_dict[group_name] = gb
if not self.layout_dict.has_key(group_name):
if group_name not in self.layout_dict:
self.layout_dict[group_name] = \
FlowLayout(self.groupbox_dict[group_name])
attrubute_list = []
sub_group_list = []
if self.button_list.has_key(sub_group):
if sub_group in self.button_list:
attrubute_list = self.button_list[sub_group][0]
sub_group_list = self.button_list[sub_group][1]
self.button_list[sub_group] = []
@ -107,13 +112,13 @@ class DisplayMethod(qt.QWidget):
self.button_list[sub_group].append(Button)
continue
if not self.groupbox_dict.has_key(group):
if group not in self.groupbox_dict:
gb = qt.QGroupBox(group, self)
gb.setStyleSheet(groupbox_style)
self.groupbox_dict[group] = gb
gb.setAlignment(qt.Qt.AlignLeft)
if not self.layout_dict.has_key(group):
if group not in self.layout_dict:
self.layout_dict[group] = FlowLayout(self.groupbox_dict[group])
view_name_sort = filter(lambda x: guiMethods[group].index(x) % 3 \
== 1, guiMethods[group])
@ -135,7 +140,7 @@ class DisplayMethod(qt.QWidget):
# except (UnicodeDecodeError, UnicodeEncodeError):
# Button.setStatusTip(sub_group)
if not self.button_list.has_key(group):
if group not in self.button_list:
self.button_list[group] = []
self.button_list[group].append(Button)
@ -247,7 +252,7 @@ class DisplayMethod(qt.QWidget):
self.ClientObj.sid = get_sid(self.ClientObj.client)
expert = None
if self.ClientObj.param_objects.has_key(method_name):
if method_name in self.ClientObj.param_objects:
self.ClientObj.param_objects[method_name]['step'] = 0
if self.ClientObj.param_objects[method_name]['expert_changed']:
expert = True
@ -284,7 +289,7 @@ class DisplayMethod(qt.QWidget):
self._parent.main_frame.viewport().setStyleSheet('')
# set new Title
if self.ClientObj.method_names.has_key(method_name):
if method_name in self.ClientObj.method_names:
view_method = self.ClientObj.method_names[method_name]
else:
view_method = method_name
@ -317,7 +322,8 @@ class DisplayMethod(qt.QWidget):
self.ClientObj.MainWidget.left_frame.show()
try:
new_title = sub_group[0].split('.')[0].decode('utf-8')
# new_title = sub_group[0].split('.')[0].decode('utf-8')
new_title = sub_group[0].split('.')[0]
except (UnicodeDecodeError, UnicodeEncodeError):
pass
if self.ClientObj.MainWidget.left_frame.old_title:

@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
from more import ButtonMenu, icon_visible, LabelWordWrap, get_sid, show_msg, \
from .more import ButtonMenu, icon_visible, LabelWordWrap, get_sid, show_msg, \
ClientServiceThread, show_question, get_view_params, _print, \
get_system_rgb, dpivalue
@ -125,7 +126,7 @@ class LeftMenu(qt.QScrollArea):
# pass
attrubute_list = []
sub_group_list = []
if self.button_list.has_key(sub_group):
if sub_group in self.button_list:
attrubute_list = self.button_list[sub_group][0]
sub_group_list = self.button_list[sub_group][1]
self.button_list[sub_group] = []
@ -152,7 +153,7 @@ class LeftMenu(qt.QScrollArea):
pass
Button = ButtonMenu(groups[i], groups[i + 1], groups[i + 2], self)
Button.clicked.connect(self.onActivated)
if not self.button_list.has_key(sub_groups[num]):
if sub_groups[num] not in self.button_list:
self.button_list[sub_groups[num]] = []
self.button_list[sub_groups[num]].append(Button)
@ -207,7 +208,8 @@ class LeftMenu(qt.QScrollArea):
# set new Title
new_title = self.sender().text()
try:
new_title = new_title.decode('utf-8')
# new_title = new_title.decode('utf-8')
new_title = new_title
except (UnicodeDecodeError, UnicodeEncodeError):
pass
self._parent.ClientObj._parent.setWindowTitle \
@ -219,7 +221,7 @@ class LeftMenu(qt.QScrollArea):
self._parent.ClientObj.sid = \
get_sid(self._parent.ClientObj.client)
# switch to the desired step
if self._parent.ClientObj.param_objects.has_key(method_name):
if method_name in self._parent.ClientObj.param_objects:
self._parent.ClientObj.param_objects[method_name]['step'] = step
# Call server method

@ -14,13 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from Box import MainWgt
from __future__ import absolute_import
from .Box import MainWgt
from calculate.consolegui import qt
#from mainmenu import MainMenu
import os
import ConfigParser
# import ConfigParser
import calculate.lib.configparser as ConfigParser
import gettext
_ = gettext.gettext
class ApiClient(qt.QWidget):
def __init__(self, app, tabs):
super(ApiClient, self).__init__()
@ -90,11 +93,13 @@ class ApiClient(qt.QWidget):
###################### other ##########################
import gettext
import locale
# get language
try:
self.lang = config.get('other', 'lang')
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
default_locale = gettext.locale.getdefaultlocale()
# default_locale = gettext.locale.getdefaultlocale()
default_locale = locale.getdefaultlocale()
if default_locale[0]:
self.lang = default_locale[0][:2]
else:
@ -110,7 +115,8 @@ class ApiClient(qt.QWidget):
lang = gettext.translation('cl_consolegui3',languages=[],fallback=True)
try:
lang.install(unicode=True)
lang.install()
# lang.install(unicode=True)
except UnboundLocalError:
pass
try:

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
from calculate.consolegui import qt
DEBUG_LEVEL = 0
@ -21,9 +23,9 @@ DEBUG_LEVEL = 0
def debug(level, *args):
if level <= DEBUG_LEVEL:
for s in args:
print s,
print
import urllib2
print(s, end=' ')
print()
import urllib.request as urllib2
import calculate.contrib
from suds import MethodNotFound
import re
@ -32,12 +34,12 @@ from calculate.core.client.function import switch, create_obj
from calculate.lib.utils.colortext.converter import XmlConverter
from calculate.lib.utils.colortext.output import SpanCssOutput
from calculate.lib.utils.tools import imap_regexp
from more import WorkPalette, ParameterWindow, get_system_rgb
from .more import WorkPalette, ParameterWindow, get_system_rgb
from more import get_sid, ClientServiceThread, show_msg, TaskWidget, ErrorWgt,\
from .more import get_sid, ClientServiceThread, show_msg, TaskWidget, ErrorWgt,\
ResultLayout, get_view_params, get_icon, dpivalue
from more import LabelWordWrap as Label
from SelectTable import SelectedTableWidget
from .more import LabelWordWrap as Label
from .SelectTable import SelectedTableWidget
class LabelWordWrap(Label):
def __init__(self, name, parent=None, mono=False, margin_top=0):
@ -76,7 +78,7 @@ class PlusButton(qt.QPushButton):
self.get_Frame_thread.start()
def after_call(self, view):
if self.ClientObj.method_names.has_key(self.method):
if self.method in self.ClientObj.method_names:
view_method = self._parent.ClientObj.method_names[self.method]
else:
view_method = self.method
@ -114,7 +116,7 @@ class MainFrameRes(qt.QWidget):
self._parent.methodname_wgt.show()
self._parent.control_button.show()
self._parent.control_button.del_button()
if self.ClientObj.method_names.has_key(self.method_name):
if self.method_name in self.ClientObj.method_names:
self._parent.methodname_wgt.setMethodName \
(self.ClientObj.method_names[self.method_name])
else:
@ -256,10 +258,10 @@ class MainFrameRes(qt.QWidget):
table.onClick + '_view', step = 0) #int(table.step) if table.step else 0)
view = self.client.service[0][table.onClick + '_view'](
sid, view_params)
except MethodNotFound, e:
except MethodNotFound as e:
_print(e)
return
if self._parent.ClientObj.method_names.has_key(table.onClick):
if table.onClick in self._parent.ClientObj.method_names:
view_method = self._parent.ClientObj.method_names \
[table.onClick]
else:
@ -788,7 +790,7 @@ class MainFrameRes(qt.QWidget):
if not pid:
try:
list_pid = self.ClientObj.client.service.list_pid(sid = sid)
except urllib2.URLError, e:
except urllib2.URLError as e:
_print ('get_entire_frame in MainFrameResult Exception')
show_msg (e, _("Not connected!"))
return 1

@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
from more import get_system_rgb, ParameterWindow
from .more import get_system_rgb, ParameterWindow
class Delegate(qt.QStyledItemDelegate):

@ -14,8 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
import time, urllib2
import time
import urllib.request as urllib2
from calculate.core.client.function import create_obj
try:
@ -24,10 +26,10 @@ except ImportError:
UpdateInfo = None
import dbus
from ReturnMessage import ReturnedMessage
from .ReturnMessage import ReturnedMessage
from calculate.consolegui.application.pid_information import client_pid_info, \
client_list_pid
from more import show_msg, get_sid, _print, get_icon
from .more import show_msg, get_sid, _print, get_icon
# class MySignal(qt.QObject):
# sig = qt.Signal(str, str)
@ -61,7 +63,7 @@ class TrayUpdateSystem(qt.QThread):
meth_result_temp = \
self._parent.localhost_ClientObj.client.service.update(
sid, param_object)
except Exception, e:
except Exception as e:
msg = e.message
if type(e.message) == tuple:
msg = ' '.join(map(lambda x: str(x), list(e.message)))

@ -14,10 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
from pid_information import client_list_pid, client_pid_info
from more import LabelWordWrap, show_msg, get_sid, ClientServiceThread
from .pid_information import client_list_pid, client_pid_info
from .more import LabelWordWrap, show_msg, get_sid, ClientServiceThread
class ViewProc(qt.QWidget):
@ -50,15 +51,14 @@ class ViewProc(qt.QWidget):
#if list_pid[num] == ClientObj._parent.sys_update_pid:
# continue
# add method name
if self.ClientObj.process_dict[str(list_pid[num])].has_key \
('method_name'):
if 'method_name' in self.ClientObj.process_dict[str(list_pid[num])]:
method_name = self.ClientObj.process_dict[str(list_pid[num])] \
['method_name']
else:
method_name = self.ClientObj.process_dict[str(list_pid[num])] \
['name']
if self.ClientObj.method_names.has_key(method_name):
if method_name in self.ClientObj.method_names:
view_method_name = self.ClientObj.method_names[method_name]
# try:
# view_method_name = self.ClientObj.param_objects \
@ -137,7 +137,8 @@ class ViewProc(qt.QWidget):
# set new window title
n = method_name
try:
name = n.decode('utf-8')
# name = n.decode('utf-8')
name = n
except (UnicodeEncodeError, UnicodeDecodeError):
pass
self.ClientObj._parent.setWindowTitle \

@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
import urllib2 as u2
import urllib.request as u2
if hasattr(u2,"ssl"):
u2.ssl._create_default_https_context = u2.ssl._create_unverified_context
import os, re, sys
@ -25,16 +26,16 @@ import calculate.contrib
from suds.transport.http import HttpTransport
try:
from pyopenssl_wrapper import PyOpenSSLSocket
from .pyopenssl_wrapper import PyOpenSSLSocket
except ImportError:
PYOPENSSL_AVAILABLE = False
else:
PYOPENSSL_AVAILABLE = True
import httplib #http.client in python3
import http.client as httplib
from suds.transport import Transport
from suds.properties import Unskin
from cookielib import CookieJar, DefaultCookiePolicy
from http.cookiejar import CookieJar, DefaultCookiePolicy
import socket, ssl
import OpenSSL, hashlib
@ -43,7 +44,7 @@ from logging import getLogger
from calculate.core.client.cert_verify import verify, VerifyError
from calculate.lib.utils.files import readFile
from more import show_msg, show_question, LabelWordWrap
from .more import show_msg, show_question, LabelWordWrap
flag = 0
log = getLogger(__name__)
@ -296,7 +297,7 @@ class AddServerCert (qt.QDialog):
show_msg (_('Server certificate added to trusted') +'\n'+ \
(self.parent.trusted_path + filename),_('Certificate added'))
self.flag = 3
from conf_connection import FrameConnection
from .conf_connection import FrameConnection
self.ConnectWidget = FrameConnection(self, self.ClientObj)
self.ConnectWidget.connect_to_host(host, self.ClientObj.port)
@ -510,7 +511,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
client.wsdl.services[0].setlocation(url)
try:
cert = client.service.get_ca()
except u2.URLError, e:
except u2.URLError as e:
_print ('client.service.get_ca in client_class Exception')
cert = '0'
@ -635,21 +636,22 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection):
self.sock = wrap_class(sock, ca_certs=self.ca_certs, **add)
return 0
except OpenSSL.SSL.Error, e:
if type(e.message) == list:
if type(e.message[0]) == tuple:
for i in e.message[0]:
sys.stdout.write(i+' ')
sys.stdout.flush()
sys.stdout.write('\n')
sys.stdout.flush()
except OpenSSL.SSL.Error as e:
if type(e.message) == list:
if type(e.message[0]) == tuple:
for i in e.message[0]:
sys.stdout.write(i+' ')
sys.stdout.flush()
sys.stdout.write('\n')
sys.stdout.flush()
else:
_print (e.message)
else:
_print (e.message)
_print (e.message)
else:
_print (e.message)
HTTPSClientCertTransport.filename = None
return 1
except Exception, e:
except Exception as e:
_print (e)
HTTPSClientCertTransport.filename = None
return 1
@ -697,20 +699,22 @@ class HTTPSClientCertTransport(HttpTransport):
self.cert = cert
self.cert_path = path_to_cert
if key:
client_certobj = OpenSSL.crypto.load_certificate \
(OpenSSL.SSL.FILETYPE_PEM, file(cert).read())
if password:
client_keyobj = OpenSSL.crypto.load_privatekey \
(OpenSSL.SSL.FILETYPE_PEM, file(key).read(),
str(password))
else:
import M2Crypto
bio = M2Crypto.BIO.openfile(key)
rsa = M2Crypto.m2.rsa_read_key(bio._ptr(),lambda *unused: None)
if not rsa:
raise OpenSSL.crypto.Error
client_keyobj = OpenSSL.crypto.load_privatekey \
(OpenSSL.SSL.FILETYPE_PEM, file(key).read())
with open(cert) as cert_file:
client_certobj = OpenSSL.crypto.load_certificate \
(OpenSSL.SSL.FILETYPE_PEM, cert_file.read())
if password:
with open(key) as key_file:
client_keyobj = OpenSSL.crypto.load_privatekey \
(OpenSSL.SSL.FILETYPE_PEM, key_file.read(),
str(password))
else:
import M2Crypto
bio = M2Crypto.BIO.openfile(key)
rsa = M2Crypto.m2.rsa_read_key(bio._ptr(),lambda *unused: None)
if not rsa:
raise OpenSSL.crypto.Error
client_keyobj = OpenSSL.crypto.load_privatekey \
(OpenSSL.SSL.FILETYPE_PEM, file(key).read())
Unskin(self.options).update(kwargs)
self.cookiejar = CookieJar(DefaultCookiePolicy())
@ -752,8 +756,8 @@ class HTTPSClientCertTransport(HttpTransport):
self.urlopener.add_handler(proxy_handler)
if proxy_auth_handler:
self.urlopener.add_handler(proxy_auth_handler)
self.urlopener.addheaders = [('User-agent', self.user_agent_string)]
#turns out user_agent_string is usualy None. why?
self.urlopener.addheaders = [('User-agent', str(self.user_agent_string))]
###############################################################################
@ -823,7 +827,7 @@ def get_CRL(path_to_cert):
client.set_parameters (path_to_cert, None, None)
new_crl = client.service.get_crl()
except VerifyError, e:
except VerifyError as e:
_print (e.value)
#rm_ca_from_trusted(ca)
sys.exit()

@ -14,19 +14,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
import calculate.contrib
from suds import WebFault
import logging, OpenSSL
import ConfigParser, os, urllib2
import os
import calculate.lib.configparser as ConfigParser
import urllib.request as urllib2
import getpass
from calculate.core.client.function import clear as clear_suds_cache
from session_function import client_post_cert
from .session_function import client_post_cert
from calculate.core.client.cert_verify import VerifyError
from client_class import Client_suds, HTTPSClientCertTransport
from more import post_connect_action, show_msg, uniq, LabelWordWrap, get_icon, dpivalue
from .client_class import Client_suds, HTTPSClientCertTransport
from .more import post_connect_action, show_msg, uniq, LabelWordWrap, get_icon, dpivalue
class LocalhostPasswd(qt.QDialog):
def __init__(self, parent):
@ -275,20 +278,23 @@ class FrameConnection(qt.QWidget):
pass
path_to_cert = self.ClientObj.path_to_cert
try:
client = Client_suds(url, transport = \
HTTPSClientCertTransport(None,None, path_to_cert, \
#note: http.client unlike httplib DOES NOT LIKE None
print("GGG")
print(url)
client = Client_suds(url, transport =
HTTPSClientCertTransport("", "", path_to_cert,
parent = self.ClientObj, timeout = 10))
except AttributeError, e:
except AttributeError as e:
show_msg (_('This server is not trusted'), _('Not connected!'))
return 1
except Exception, e:
except Exception as e:
show_msg (e, _("Not connected!"))
return 1
client.wsdl.services[0].setlocation(url)
try:
server_host_name = client.service.get_server_host_name()
except urllib2.URLError, e:
except urllib2.URLError as e:
show_msg (e, _("Not connected!"))
return 1
except Exception as e:
@ -343,14 +349,14 @@ class FrameConnection(qt.QWidget):
client_post_cert(self.ClientObj.client, \
self.ClientObj.lang)
Connect_Error = 0
except VerifyError, e:
except VerifyError as e:
show_msg (e.value,_("Server certificate verification error"),self)
e.message = 'VerifyError'
Connect_Error = 1
except OpenSSL.crypto.Error, e:
except OpenSSL.crypto.Error as e:
Connect_Error = 1
crypto_Error = 1
except Exception, e:
except Exception as e:
Connect_Error = 1
if Connect_Error == 0:
break
@ -363,7 +369,7 @@ class FrameConnection(qt.QWidget):
_('Connection Error'), self)
return
# self.close()
if not locals().has_key('e'):
if 'e' not in locals():
mess = _('You do not have a certificate. Please generate '
'a new request and get the new certificate from '
'the server.')
@ -413,7 +419,7 @@ class FrameConnection(qt.QWidget):
# self.ClientObj._parent.connect_count_changed(1)
post_connect_action(self.ClientObj.client, self.ClientObj)
#----------------------------------------------------
except WebFault, f:
except WebFault as f:
show_msg ("Exception: %s" %f)
_print (f.fault)
self.close()

@ -14,10 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
import socket
from calculate.consolegui import qt
from more import LabelWordWrap, show_msg, get_icon
from .more import LabelWordWrap, show_msg, get_icon
def passphrase_callback(v):
if type(v) == int or not v:
@ -61,7 +62,8 @@ class RequestCreate (qt.QWidget):
username = ClientObj.VarsApi.Get('ur_fullname')
suffixPort = ":%s"%ClientObj.VarsApi.Get('core.cl_core_port')
username = username.decode('utf-8')
# username = username.decode('utf-8')
username = username
self.mainlayout.addWidget(LabelWordWrap(_('User Name'), self),1,0,
qt.Qt.AlignRight)
self.user_name = qt.QLineEdit(username, self)

@ -14,12 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
from more import LabelWordWrap, show_msg, get_icon
from .more import LabelWordWrap, show_msg, get_icon
import datetime
from calculate.lib.datavars import DataVars
_('The user should not be root')
# _('The user should not be root')
class HelpWgt(qt.QWidget):
def __init__(self, parent):
qt.QWidget.__init__(self)

@ -14,11 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
from calculate.consolegui import qt
from calculate.core.client.function import create_obj, listToArrayArray, \
listToArray
# import analysis
from more import show_msg, LabelWordWrap, MultipleChoice, SelectTable, \
from .more import show_msg, LabelWordWrap, MultipleChoice, SelectTable, \
CentralCheckBox, ErrorLabel, icon_visible, FileOpenWgt, \
ComboFileWgt, PasswordWidget, get_sid, ClientServiceThread, \
ExpertWidget, ButtonsWidget, show_question, PlusRow, \
@ -28,19 +30,19 @@ import calculate.contrib
from suds import WebFault
from calculate.lib.utils.text import _u8
from calculate.lib.utils.tools import Sizes
from SelectTable import SelectedTableWidget
from ReturnMessage import ReturnedMessage
import urllib2, time
from .SelectTable import SelectedTableWidget
from .ReturnMessage import ReturnedMessage
import urllib.request as urllib2, time
from os import path
# DEBUG_LEVEL = 9999
DEBUG_LEVEL = 0
DEBUG_LEVEL = 9999
# DEBUG_LEVEL = 0
def debug(level, *args):
if level <= DEBUG_LEVEL:
for s in args:
print s,
print
print(s, end=' ')
print()
def get_size_by_type(sizetype, size):
@ -237,7 +239,7 @@ class MainFrame(qt.QWidget):
x = 1
y = 0
from ConnectionTabs import SelectedMethodWgt
from .ConnectionTabs import SelectedMethodWgt
self.hidden_fields = {}
@ -520,7 +522,7 @@ class MainFrame(qt.QWidget):
# Show Control Buttons widget
self._parent.methodname_wgt.show()
self._parent.control_button.show()
if self.ClientObj.method_names.has_key(self.method_name):
if self.method_name in self.ClientObj.method_names:
view_method = self.ClientObj.method_names[self.method_name]
else:
view_method = self.method_name
@ -1565,7 +1567,7 @@ class MainFrame(qt.QWidget):
['layout'].setAlignment(qt.Qt.AlignTop)
# set new window title
if self.ClientObj.method_names.has_key(method_name):
if method_name in self.ClientObj.method_names:
view_method = self._parent.ClientObj.method_names[method_name]
else:
view_method = method_name
@ -1596,11 +1598,11 @@ class MainFrame(qt.QWidget):
steps = field.tablevalue.head.string
icons = []
# print("---------------------------------------------------")
# print("DEBUG")
# print(field)
# print(dir(field))
# print(type(field))
print("---------------------------------------------------")
print("DEBUG")
print(field)
print(dir(field))
print(type(field))
if hasattr(field.listvalue, 'string'):
icons = field.listvalue.string
val_steps = field.tablevalue.body.stringArray
@ -2523,7 +2525,8 @@ class MainFrame(qt.QWidget):
def fix_string_value(self, value):
try:
return (str(value.encode('utf-8')).decode('utf-8'))
# return (str(value.encode('utf-8')).decode('utf-8'))
return (str(value))
except (UnicodeDecodeError, UnicodeEncodeError):
return str(value)
@ -2706,7 +2709,8 @@ class MainFrame(qt.QWidget):
self.ClientObj._parent.setWindowTitle(
u"{title} - {action}".format(
title="-".join(temp),
action=_("Running").decode('utf-8')))
# action=_("Running").decode('utf-8')))
action=_("Running")))
self.calling_error = False
# Call method display process results
@ -2714,7 +2718,7 @@ class MainFrame(qt.QWidget):
self.ClientObj.MainWidget.main_frame_res(
method_name, meth_result[0], change_offset=change_offset)
except WebFault, f:
except WebFault as f:
show_msg(f.message, 'Error from Server!')
self.ClientObj.param_objects[method_name]['error'] = \
'transmitted data is incorrect'
@ -2885,7 +2889,7 @@ class MainFrame(qt.QWidget):
return 1
if error.field in self.ClientObj.param_objects[self.method_name] \
['fields'][step_num]:
if self.error_label_dict.has_key(str(error.field)):
if str(error.field) in self.error_label_dict:
try:
self.error_label_dict[error.field].setStyleSheet \
("QLabel { color : red; }")
@ -2975,7 +2979,7 @@ class MainFrame(qt.QWidget):
self.view_dict[field.name].item(row, i).setText \
(q.string[i - 1])
break
except Exception, e:
except Exception as e:
# _print ('EXCEPT', e)
pass
elif type(self.view_dict[field.name].cellWidget(row, i)) == qt.QComboBox:

@ -15,8 +15,9 @@
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
from more import TopMenu, HelpMenu#, FlowLayout
from .more import TopMenu, HelpMenu#, FlowLayout
class MainMenu(qt.QWidget):
def __init__(self, parent):

@ -14,9 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from __future__ import absolute_import
import os
import time
import urllib2
import urllib.request as urllib2
import pwd
import sys
@ -38,7 +40,7 @@ def dpivalue(size):
try:
return size * qt.QApplication.screens()[0].logicalDotsPerInch() / 96.0;
except BaseException as e:
print str(e)
print(str(e))
if isinstance(e, KeyboardInterrupt):
raise
return size
@ -84,7 +86,7 @@ def get_pixmap(*images, **kw):
return None
_('The user must not be root')
# _('The user must not be root')
class TopMenu(qt.QPushButton):
def __init__(self, label, images, parent = None):
qt.QPushButton.__init__(self, parent)
@ -412,7 +414,8 @@ class LabelWordWrap(qt.QLabel):
if not name:
name = ''
try:
name = name.decode('utf-8')
# name = name.decode('utf-8')
name = name
if not mono:
name = name.replace("&nbsp;"," ")
else:
@ -535,7 +538,7 @@ class FileOpenWgt(qt.QWidget):
self.set_label()
def set_label(self):
if type(self.data) in [str, unicode]:
if type(self.data) in [str]:
self.lineEdit.setText(self.data)
elif type(self.data) == list:
lbl = ', '.join(self.data)
@ -636,7 +639,7 @@ class ComboFileWgt(qt.QLabel):
self.set_label()
def set_label(self):
if type(self.data) in [str, unicode]:
if type(self.data) in [str]:
lbl = self.data
self.ComboBox.addItem(lbl)
@ -1898,7 +1901,7 @@ class PlusRow (qt.QWidget):
elif element == 'readonly' and field.type == 'writable':
self.widget_dict[str(i)] = ''
if not self.widget_dict.has_key('0'):
if '0' not in self.widget_dict:
continue
index_widget = self.widget_dict['0']
@ -2002,7 +2005,7 @@ class PlusRow (qt.QWidget):
for i in range (len(self.field.tablevalue.values.ChoiceValue)):
col = i + 1
val = ''
if not self.widget_dict.has_key(str(i)):
if str(i) not in self.widget_dict:
continue
if type(self.widget_dict[str(i)]) == CentralCheckBox:
state = self.widget_dict[str(i)].getState()
@ -2261,7 +2264,7 @@ class LabelTaskWgt(qt.QLabel):
y = (self.sizeHint().height() - self.br_.height()) / 2 + fm.ascent()
dot_w = fm.width('. ')
for x in xrange (0, self.width(), dot_w):
for x in range (0, self.width(), dot_w):
p.drawText(x, y, '. ')
class TaskWidget(qt.QWidget):
@ -2327,7 +2330,8 @@ class ButtonsWidget(qt.QWidget):
self.layout.addWidget(button)
def _print (*args):
print " ".join(map(lambda x:unicode(x).encode('utf-8'),args))
# print(" ".join(map(lambda x:unicode(x).encode('utf-8'),args)))
print(" ".join(map(lambda x:str(x),args)))
def show_msg(text, title = None, parent = None):
msgBox = qt.QMessageBox(parent)
@ -2337,13 +2341,16 @@ def show_msg(text, title = None, parent = None):
msgBox.setWindowTitle("Calculate Console")
if not text:
return 1
if not type(text) in [str,unicode]:
if not type(text) in [str]:
temp = ''
for i in text:
#DEBUG: want traceback? force error there.
# for i in str(text):
try:
temp += str(i).decode('utf-8')+' '
# temp += str(i).decode('utf-8')+' '
temp += str(i) + ' '
except (UnicodeEncodeError, UnicodeDecodeError):
temp += str(i)+' '
temp += str(i) + ' '
text = temp
msgBox.setText(text)
msgBox.setStandardButtons(qt.QMessageBox.Ok)
@ -2397,7 +2404,7 @@ def client_post_auth(client):
show_msg (_('You do not have a certificate. Please generate a '
'new request and get the new certificate from the server.'))
return 1
except VerifyError, e:
except VerifyError as e:
show_msg (e.value)
return 1
return 0
@ -2427,7 +2434,7 @@ class ClientSignal(qt.QThread):
reply = client.service.active_client(sid)
except urllib2.URLError:
reply = 2
except Exception, e:
except Exception as e:
show_msg (e.message, 'no connection to server!')
if reply == 0:
#if not self.ClientObj.has_connect:
@ -2458,7 +2465,7 @@ def post_connect_action(client, ClientObj):
ClientObj.client = None
ClientObj.MainWidget.process_dict = {}
from ConnectionTabs import SelectedMethodWgt
from .ConnectionTabs import SelectedMethodWgt
if type (ClientObj._parent) == SelectedMethodWgt:
sys.exit(1)
return 1
@ -2525,7 +2532,7 @@ def client_del_sid(client):
_print ('Closing process...')
# _print (_("SID deleted!"))
return 0
except Exception, e:
except Exception as e:
_print (_("Error removing the session from the server"), e)
return 1
return 0
@ -2538,7 +2545,7 @@ def client_list_methods(sid, client):
try:
results = client.service.get_methods(sid, 'gui')
except urllib2.URLError, e:
except urllib2.URLError as e:
_print ('client.service.get_methods in client_list_methods Exception')
return 1
if not results:
@ -2599,7 +2606,7 @@ class ClientServiceThread(qt.QThread):
try:
result = client.service[0][self.method_name](*self.args)
except Exception, e:
except Exception as e:
if self.return_except:
_print ("EMIT EXCEPTION!")
if self.close_flag:
@ -2687,7 +2694,7 @@ class ImageLabel(qt.QLabel):
temp_file = os.path.join(save_path, '%s_fix' %filename)
sizes = resize_image(fix_image_path, height_image, temp_file)
if sizes:
os.chmod(temp_file, 0666)
os.chmod(temp_file, 0o666)
fix_image.setFixedWidth(sizes[0])
fix_image.setStyleSheet("background-image: url(%s); " \
%temp_file)
@ -2703,7 +2710,7 @@ class ImageLabel(qt.QLabel):
temp_file = os.path.join(save_path, '%s_temp' %filename)
sizes = resize_image(image, height_image, temp_file)
if sizes:
os.chmod(temp_file, 0666)
os.chmod(temp_file, 0o666)
style += "background-image: url(%s); " %temp_file
style += "background-attachment: fixed; "
style += "background-repeat: %s; " %repeat_dict[repeat.lower()]

@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from more import get_sid, get_icon
from __future__ import absolute_import
from .more import get_sid, get_icon
from calculate.consolegui import qt
from ReturnMessage import ReturnedMessage
from .ReturnMessage import ReturnedMessage
import urllib2
import urllib.request as urllib2
#class ret_mes():
# def __init__ (self, pid):
# self.type = "pid"
@ -34,7 +35,8 @@ def show_msg(text, title = None, parent = None):
temp = ''
for i in text:
try:
temp += str(i).decode('utf-8')+' '
# temp += str(i).decode('utf-8')+' '
temp += str(i) + ' '
except (UnicodeEncodeError, UnicodeDecodeError):
temp += str(i)+' '
text = temp

@ -103,7 +103,7 @@ class PyOpenSSLSocket (socket):
try:
return self._sslobj.read(len)
except SSLError, x:
except SSLError as x:
if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
return ''
else:
@ -141,7 +141,7 @@ class PyOpenSSLSocket (socket):
while True:
try:
v = self._sslobj.write(data)
except SSLError, x:
except SSLError as x:
if x.args[0] == SSL_ERROR_WANT_READ:
return 0
elif x.args[0] == SSL_ERROR_WANT_WRITE:
@ -184,7 +184,7 @@ class PyOpenSSLSocket (socket):
while True:
try:
return self.read(buflen)
except SSLError, x:
except SSLError as x:
if x.args[0] == SSL_ERROR_WANT_READ:
continue
else:
@ -208,7 +208,7 @@ class PyOpenSSLSocket (socket):
v = len(tmp_buffer)
buffer[:v] = tmp_buffer
return v
except SSLError, x:
except SSLError as x:
if x.args[0] == SSL_ERROR_WANT_READ:
continue
else:

@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from calculate.consolegui import qt
import urllib2
import urllib.request as urllib2
from calculate.lib.utils.tools import Locker
from more import show_msg, LabelWordWrap, get_ip_mac, get_sid, get_icon, dpivalue
from .more import show_msg, LabelWordWrap, get_ip_mac, get_sid, get_icon, dpivalue
def client_sid(sid, client, cert_id, lang):
""" get number session from server and write this in file """
@ -145,7 +146,7 @@ class ViewSessionInfo (qt.QWidget):
def wrapper():
try:
res = client.service.clear_session_cache(sid)
except Exception, e:
except Exception as e:
show_msg(e, 'Error')
return 1
if res:

@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
import os
from calculate.consolegui import qt
from more import LabelWordWrap, FileOpenWgt, show_msg, show_question, \
from .more import LabelWordWrap, FileOpenWgt, show_msg, show_question, \
client_list_methods, get_icon, dpivalue
class ToolsWidget (qt.QWidget):
@ -113,7 +114,7 @@ class ToolsWidget (qt.QWidget):
os.remove(ClientObj.user_config)
ClientObj.create_user_config()
ClientObj.read_user_config(ClientObj.user_config)
except Exception, e:
except Exception as e:
show_msg (e, 'Clear Config Error')
finally:
self.create(parent, ClientObj)
@ -486,7 +487,7 @@ class ToolOther(qt.QWidget):
# reset unsaved changes flag
self._parent.changed_flag = False
if ClientObj.client:
from session_function import client_post_cert
from .session_function import client_post_cert
ClientObj.lang = self.lang_ComboBox.itemData \
(self.lang_ComboBox.currentIndex())
if ClientObj.client:
@ -496,7 +497,7 @@ class ToolOther(qt.QWidget):
return
ClientObj.methods_list = client_list_methods \
(ClientObj.sid, ClientObj.client)
from DisplayMethod import DisplayMethod
from .DisplayMethod import DisplayMethod
if type (ClientObj.MainWidget.MainFrameWgt) \
== DisplayMethod:
ClientObj.MainWidget.display_methods()

@ -84,6 +84,6 @@ QUrl = QtCore.QUrl
Signal = QtCore.pyqtSignal
#use that if you need to suppress QT warnings/errors
def handler(msg_type, msg_log_context, msg_string):
pass
QtCore.qInstallMessageHandler(handler)
# def handler(msg_type, msg_log_context, msg_string):
# pass
# QtCore.qInstallMessageHandler(handler)

@ -14,6 +14,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import console
from __future__ import absolute_import
#-*- coding: utf-8 -*-
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from . import console
section = "consolegui"

@ -0,0 +1,19 @@
#-*- coding: utf-8 -*-
# Copyright 2012-2016 Mir Calculate. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import console
section = "consolegui"
Loading…
Cancel
Save