|
|
|
@ -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(" "," ")
|
|
|
|
|
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()]
|
|
|
|
|