|
|
|
@ -20,7 +20,8 @@ from calculate.core.client.function import create_obj
|
|
|
|
|
import dbus
|
|
|
|
|
|
|
|
|
|
from ReturnMessage import ReturnedMessage
|
|
|
|
|
from calculate.consolegui.application.pid_information import client_pid_info
|
|
|
|
|
from calculate.consolegui.application.pid_information import client_pid_info, \
|
|
|
|
|
client_list_pid
|
|
|
|
|
from more import show_msg, get_sid, _print
|
|
|
|
|
|
|
|
|
|
#class MySignal(QtCore.QObject):
|
|
|
|
@ -28,6 +29,7 @@ from more import show_msg, get_sid, _print
|
|
|
|
|
|
|
|
|
|
class TrayUpdateSystem(QtCore.QThread):
|
|
|
|
|
mes_sig = QtCore.Signal(str, str)
|
|
|
|
|
started_sig = QtCore.Signal(str)
|
|
|
|
|
def __init__(self, target, parent = None):
|
|
|
|
|
QtCore.QThread.__init__(self, parent)
|
|
|
|
|
self._parent = target
|
|
|
|
@ -85,13 +87,14 @@ class TrayUpdateSystem(QtCore.QThread):
|
|
|
|
|
else:
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
self.mes_sig.emit('', _('Update running'))
|
|
|
|
|
#self.mes_sig.emit('', _('Update running'))
|
|
|
|
|
|
|
|
|
|
mess = meth_result[0]
|
|
|
|
|
pid = mess.message
|
|
|
|
|
self._parent.sys_update_pid = int(pid)
|
|
|
|
|
self.started_sig.emit(pid)
|
|
|
|
|
|
|
|
|
|
self.get_update_status(sid, pid)
|
|
|
|
|
#self.get_update_status(sid, pid)
|
|
|
|
|
|
|
|
|
|
def get_update_status(self, sid, pid):
|
|
|
|
|
end_frame = True
|
|
|
|
@ -104,10 +107,10 @@ class TrayUpdateSystem(QtCore.QThread):
|
|
|
|
|
current_frame = None
|
|
|
|
|
while end_frame:
|
|
|
|
|
while current_frame in [None, [], ""]:
|
|
|
|
|
for i in range (5):
|
|
|
|
|
for i in range(5):
|
|
|
|
|
time.sleep(0.1)
|
|
|
|
|
if self.close_flag:
|
|
|
|
|
self.mes_sig.emit('', _('Update aborted'))
|
|
|
|
|
#self.mes_sig.emit('', _('Update aborted'))
|
|
|
|
|
return 0
|
|
|
|
|
try:
|
|
|
|
|
client = self._parent.localhost_ClientObj.client
|
|
|
|
@ -118,16 +121,17 @@ class TrayUpdateSystem(QtCore.QThread):
|
|
|
|
|
current_frame = None
|
|
|
|
|
for item in range(len(current_frame[0])):
|
|
|
|
|
if current_frame[0][item].type == 'error':
|
|
|
|
|
self.mes_sig.emit(_("Failed to update!"), \
|
|
|
|
|
current_frame[0][item].message)
|
|
|
|
|
#self.mes_sig.emit(_("Failed to update!"), \
|
|
|
|
|
# current_frame[0][item].message)
|
|
|
|
|
end_frame = False
|
|
|
|
|
return 1
|
|
|
|
|
elif current_frame[0][item].type == 'endFrame':
|
|
|
|
|
if current_frame[0][item].message:
|
|
|
|
|
message = current_frame[0][item].message
|
|
|
|
|
else: message = ''
|
|
|
|
|
self.mes_sig.emit(_('Update successfully completed'), \
|
|
|
|
|
message)
|
|
|
|
|
else:
|
|
|
|
|
message = ''
|
|
|
|
|
#self.mes_sig.emit(_('Update successfully completed'), \
|
|
|
|
|
# message)
|
|
|
|
|
end_frame = False
|
|
|
|
|
current_frame = None
|
|
|
|
|
|
|
|
|
@ -158,6 +162,7 @@ class TrayIcon (QtGui.QSystemTrayIcon):
|
|
|
|
|
|
|
|
|
|
self.update_thread = TrayUpdateSystem(parent)
|
|
|
|
|
self.update_thread.mes_sig.connect(self.showMessage)
|
|
|
|
|
self.update_thread.started_sig.connect(self.showUpdate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def select_icon(self, icons):
|
|
|
|
@ -237,22 +242,45 @@ class TrayIcon (QtGui.QSystemTrayIcon):
|
|
|
|
|
def tools(self):
|
|
|
|
|
self._parent.currentWidget().tools()
|
|
|
|
|
|
|
|
|
|
def show_update(self):
|
|
|
|
|
def get_update_pid(self):
|
|
|
|
|
"""
|
|
|
|
|
Получить pid процесса выполняющего update для этой сессии
|
|
|
|
|
"""
|
|
|
|
|
pid = str(self._parent.sys_update_pid)
|
|
|
|
|
client_obj = self._parent.localhost_ClientObj
|
|
|
|
|
pids = map(str, client_list_pid(client_obj.client))
|
|
|
|
|
client_pid_info(client_obj, client_obj.client, 0)
|
|
|
|
|
if self._parent.localhost_ClientObj:
|
|
|
|
|
if pid and pid in client_obj.process_dict:
|
|
|
|
|
client_pid_info(client_obj, client_obj.client, 0)
|
|
|
|
|
|
|
|
|
|
client_obj._parent.setWindowTitle \
|
|
|
|
|
("Calculate console" + ' - ' + _('System Update'))
|
|
|
|
|
result = client_obj.process_dict[pid]['result']
|
|
|
|
|
client_obj.MainWidget.main_view_process('update', result, pid)
|
|
|
|
|
client_obj.app.processEvents()
|
|
|
|
|
client_obj.MainWidget.main_frame.verticalScrollBar() \
|
|
|
|
|
.setValue(client_obj.MainWidget. \
|
|
|
|
|
main_frame.verticalScrollBar().maximum())
|
|
|
|
|
self._parent.show()
|
|
|
|
|
if pid and pid in client_obj.process_dict and pid in pids:
|
|
|
|
|
return pid
|
|
|
|
|
else:
|
|
|
|
|
for pid in pids:
|
|
|
|
|
d = client_obj.process_dict[pid]
|
|
|
|
|
if (d['method_name'] == 'update'
|
|
|
|
|
and d.get('status', '0') == '1'):
|
|
|
|
|
return pid
|
|
|
|
|
|
|
|
|
|
def show_update(self):
|
|
|
|
|
pid = self.get_update_pid()
|
|
|
|
|
if pid:
|
|
|
|
|
client_obj = self._parent.localhost_ClientObj
|
|
|
|
|
client_pid_info(client_obj, client_obj.client, 0)
|
|
|
|
|
|
|
|
|
|
client_obj._parent.setWindowTitle \
|
|
|
|
|
("Calculate console" + ' - ' + _('System Update'))
|
|
|
|
|
result = client_obj.process_dict[pid]['result']
|
|
|
|
|
client_obj.MainWidget.main_view_process('update', result, pid)
|
|
|
|
|
client_obj.app.processEvents()
|
|
|
|
|
vsb = client_obj.MainWidget.main_frame.verticalScrollBar()
|
|
|
|
|
vsb.setValue(vsb.maximum())
|
|
|
|
|
self._parent.hide()
|
|
|
|
|
self._parent.show()
|
|
|
|
|
self._parent.showNormal()
|
|
|
|
|
else:
|
|
|
|
|
self._parent.show()
|
|
|
|
|
self._parent.move(self._parent.cur_pos)
|
|
|
|
|
self._parent.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def exit(self):
|
|
|
|
|
#if self.update_thread.isRunning():
|
|
|
|
@ -310,11 +338,11 @@ class TrayIcon (QtGui.QSystemTrayIcon):
|
|
|
|
|
self._parent.move(self._parent.cur_pos)
|
|
|
|
|
|
|
|
|
|
def start_update_system(self):
|
|
|
|
|
print "DEBUG",self._parent.sys_update_pid
|
|
|
|
|
if self._parent.sys_update_pid:
|
|
|
|
|
if self.get_update_pid():
|
|
|
|
|
self.show_update()
|
|
|
|
|
else:
|
|
|
|
|
if not self.update_thread.isRunning():
|
|
|
|
|
self.update_thread.start()
|
|
|
|
|
else:
|
|
|
|
|
show_msg(_('An update is already running'))
|
|
|
|
|
self.update_thread.start()
|
|
|
|
|
#if not self.update_thread.isRunning():
|
|
|
|
|
|
|
|
|
|
def showUpdate(self, message):
|
|
|
|
|
self.show_update()
|
|
|
|
|