Merge remote-tracking branch 'origin/pr/166'
* origin/pr/166: Refactored QThread classes for more clarity and less code duplication Fixed inconsisted icon in Qube Manager messages
This commit is contained in:
commit
6585ab4f29
@ -36,12 +36,16 @@ def busy_cursor():
|
|||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class RemoveVMThread(QtCore.QThread):
|
class QubesThread(QtCore.QThread):
|
||||||
def __init__(self, vm):
|
def __init__(self, vm):
|
||||||
QtCore.QThread.__init__(self)
|
QtCore.QThread.__init__(self)
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
self.msg = None
|
self.msg = None
|
||||||
|
self.msg_is_success = False
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=too-few-public-methods
|
||||||
|
class RemoveVMThread(QubesThread):
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
del self.vm.app.domains[self.vm.name]
|
del self.vm.app.domains[self.vm.name]
|
||||||
@ -50,16 +54,15 @@ class RemoveVMThread(QtCore.QThread):
|
|||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class CloneVMThread(QtCore.QThread):
|
class CloneVMThread(QubesThread):
|
||||||
def __init__(self, src_vm, dst_name):
|
def __init__(self, vm, dst_name):
|
||||||
QtCore.QThread.__init__(self)
|
super(CloneVMThread, self).__init__(vm)
|
||||||
self.src_vm = src_vm
|
|
||||||
self.dst_name = dst_name
|
self.dst_name = dst_name
|
||||||
self.msg = None
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
self.src_vm.app.clone_vm(self.src_vm, self.dst_name)
|
self.vm.app.clone_vm(self.vm, self.dst_name)
|
||||||
self.msg = ("Sucess", "The qube was cloned sucessfully.")
|
self.msg = ("Sucess", "The qube was cloned sucessfully.")
|
||||||
|
self.msg_is_success = True
|
||||||
except exc.QubesException as ex:
|
except exc.QubesException as ex:
|
||||||
self.msg = ("Error while cloning qube!", str(ex))
|
self.msg = ("Error while cloning qube!", str(ex))
|
||||||
|
@ -264,12 +264,7 @@ class VmShutdownMonitor(QtCore.QObject):
|
|||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class StartVMThread(QtCore.QThread):
|
class StartVMThread(common_threads.QubesThread):
|
||||||
def __init__(self, vm):
|
|
||||||
QtCore.QThread.__init__(self)
|
|
||||||
self.vm = vm
|
|
||||||
self.msg = None
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
self.vm.start()
|
self.vm.start()
|
||||||
@ -278,12 +273,7 @@ class StartVMThread(QtCore.QThread):
|
|||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class UpdateVMThread(QtCore.QThread):
|
class UpdateVMThread(common_threads.QubesThread):
|
||||||
def __init__(self, vm):
|
|
||||||
QtCore.QThread.__init__(self)
|
|
||||||
self.vm = vm
|
|
||||||
self.msg = None
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
if self.vm.qid == 0:
|
if self.vm.qid == 0:
|
||||||
@ -316,12 +306,10 @@ class UpdateVMThread(QtCore.QThread):
|
|||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
class RunCommandThread(QtCore.QThread):
|
class RunCommandThread(common_threads.QubesThread):
|
||||||
def __init__(self, vm, command_to_run):
|
def __init__(self, vm, command_to_run):
|
||||||
QtCore.QThread.__init__(self)
|
super(RunCommandThread, self).__init__(vm)
|
||||||
self.vm = vm
|
|
||||||
self.command_to_run = command_to_run
|
self.command_to_run = command_to_run
|
||||||
self.msg = None
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
@ -533,10 +521,16 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
|||||||
|
|
||||||
if thread.msg:
|
if thread.msg:
|
||||||
(title, msg) = thread.msg
|
(title, msg) = thread.msg
|
||||||
QtGui.QMessageBox.warning(
|
if thread.msg_is_success:
|
||||||
None,
|
QtGui.QMessageBox.information(
|
||||||
self.tr(title),
|
None,
|
||||||
self.tr(msg))
|
self.tr(title),
|
||||||
|
self.tr(msg))
|
||||||
|
else:
|
||||||
|
QtGui.QMessageBox.warning(
|
||||||
|
None,
|
||||||
|
self.tr(title),
|
||||||
|
self.tr(msg))
|
||||||
|
|
||||||
self.threads_list.remove(thread)
|
self.threads_list.remove(thread)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user