From edb13aec176c2a34817b8ddc487070314ffae35e Mon Sep 17 00:00:00 2001 From: donoban Date: Mon, 22 Oct 2018 20:00:37 +0200 Subject: [PATCH] Thread.error renamed to Thread.msg Since it could be used for both error or sucess messages, I think msg is a better name --- qubesmanager/common_threads.py | 10 +++++----- qubesmanager/create_new_vm.py | 12 ++++++------ qubesmanager/qube_manager.py | 16 ++++++++-------- qubesmanager/restore.py | 9 ++++----- qubesmanager/settings.py | 14 +++++++------- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/qubesmanager/common_threads.py b/qubesmanager/common_threads.py index a5dac25..980c05c 100644 --- a/qubesmanager/common_threads.py +++ b/qubesmanager/common_threads.py @@ -29,13 +29,13 @@ class RemoveVMThread(QtCore.QThread): def __init__(self, vm): QtCore.QThread.__init__(self) self.vm = vm - self.error = None + self.msg = None def run(self): try: del self.vm.app.domains[self.vm.name] except exc.QubesException as ex: - self.error = ("Error removing Qube!", str(ex)) + self.msg = ("Error removing Qube!", str(ex)) # pylint: disable=too-few-public-methods @@ -44,11 +44,11 @@ class CloneVMThread(QtCore.QThread): QtCore.QThread.__init__(self) self.src_vm = src_vm self.dst_name = dst_name - self.error = None + self.msg = None def run(self): try: self.src_vm.app.clone_vm(self.src_vm, self.dst_name) - self.error = ("Sucess", "The qube was cloned sucessfully.") + self.msg = ("Sucess", "The qube was cloned sucessfully.") except exc.QubesException as ex: - self.error = ("Error while cloning Qube!", str(ex)) + self.msg = ("Error while cloning Qube!", str(ex)) diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index e81714b..9c8a2ec 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -44,7 +44,7 @@ class CreateVMThread(QtCore.QThread): self.label = label self.template = template self.properties = properties - self.error = None + self.msg = None def run(self): try: @@ -64,9 +64,9 @@ class CreateVMThread(QtCore.QThread): setattr(vm, k, v) except qubesadmin.exc.QubesException as qex: - self.error = str(qex) + self.msg = str(qex) except Exception as ex: # pylint: disable=broad-except - self.error = repr(ex) + self.msg = repr(ex) class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg): @@ -173,14 +173,14 @@ class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg): def create_finished(self): self.progress.hide() - if self.thread.error: + if self.thread.msg: QtGui.QMessageBox.warning(None, self.tr("Error creating the qube!"), - self.tr("ERROR: {}").format(self.thread.error)) + self.tr("ERROR: {}").format(self.thread.msg)) self.done(0) - if not self.thread.error: + if not self.thread.msg: if self.launch_settings.isChecked(): subprocess.check_call(['qubes-vm-settings', str(self.name)]) if self.install_system.isChecked(): diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index bf7e509..d2522eb 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -248,13 +248,13 @@ class StartVMThread(QtCore.QThread): def __init__(self, vm): QtCore.QThread.__init__(self) self.vm = vm - self.error = None + self.msg = None def run(self): try: self.vm.start() except exc.QubesException as ex: - self.error = ("Error starting Qube!", str(ex)) + self.msg = ("Error starting Qube!", str(ex)) # pylint: disable=too-few-public-methods @@ -262,7 +262,7 @@ class UpdateVMThread(QtCore.QThread): def __init__(self, vm): QtCore.QThread.__init__(self) self.vm = vm - self.error = None + self.msg = None def run(self): try: @@ -275,7 +275,7 @@ class UpdateVMThread(QtCore.QThread): self.vm.run_service("qubes.InstallUpdatesGUI",\ user="root", wait=False) except (ChildProcessError, exc.QubesException) as ex: - self.error = ("Error on Qube update!", str(ex)) + self.msg = ("Error on Qube update!", str(ex)) # pylint: disable=too-few-public-methods @@ -284,13 +284,13 @@ class RunCommandThread(QtCore.QThread): QtCore.QThread.__init__(self) self.vm = vm self.command_to_run = command_to_run - self.error = None + self.msg = None def run(self): try: self.vm.run(self.command_to_run) except (ChildProcessError, exc.QubesException) as ex: - self.error = ("Error while running command!", str(ex)) + self.msg = ("Error while running command!", str(ex)) class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): @@ -486,8 +486,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.progress.hide() self.progress = None - if thread.error: - (title, msg) = thread.error + if thread.msg: + (title, msg) = thread.msg QtGui.QMessageBox.warning( None, self.tr(title), diff --git a/qubesmanager/restore.py b/qubesmanager/restore.py index 8312b08..a060568 100644 --- a/qubesmanager/restore.py +++ b/qubesmanager/restore.py @@ -49,7 +49,6 @@ class RestoreThread(QtCore.QThread): QtCore.QThread.__init__(self) self.backup_restore = backup_restore self.vms_to_restore = vms_to_restore - self.error = None self.msg = None self.canceled = None @@ -67,7 +66,7 @@ class RestoreThread(QtCore.QThread): self.tr("Partially restored files left in /var/tmp/restore_*, " "investigate them and/or clean them up")) if err_msg: - self.error = '\n'.join(err_msg) + self.msg = '\n'.join(err_msg) self.msg = '{0}'.format( self.tr("Finished with errors!")) else: @@ -224,12 +223,12 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard): self.progress_bar.setMaximum(100) self.progress_bar.setValue(100) - if self.thread.error: + if self.thread.msg: QtGui.QMessageBox.warning( None, - self.tr("Backup error!"), + self.tr("Backup msg!"), self.tr("ERROR: {0}").format( - self.thread.error)) + self.thread.msg)) if self.thread.msg: self.append_output(self.thread.msg) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index e065714..952916c 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -53,7 +53,7 @@ class RenameVMThread(QtCore.QThread): self.vm = vm self.new_vm_name = new_vm_name self.dependencies = dependencies - self.error = None + self.msg = None def run(self): try: @@ -87,9 +87,9 @@ class RenameVMThread(QtCore.QThread): + list_text) except qubesadmin.exc.QubesException as ex: - self.error = ("Rename error!", str(ex)) + self.msg = ("Rename error!", str(ex)) except Exception as ex: # pylint: disable=broad-except - self.error = ("Rename error!", repr(ex)) + self.msg = ("Rename error!", repr(ex)) # pylint: disable=too-few-public-methods @@ -97,7 +97,7 @@ class RefreshAppsVMThread(QtCore.QThread): def __init__(self, vm): QtCore.QThread.__init__(self) self.vm = vm - self.error = None + self.msg = None def run(self): try: @@ -118,7 +118,7 @@ class RefreshAppsVMThread(QtCore.QThread): target_vm.shutdown() except Exception as ex: # pylint: disable=broad-except - self.error = ("Refresh failed!", str(ex)) + self.msg = ("Refresh failed!", str(ex)) # pylint: disable=too-many-instance-attributes @@ -232,8 +232,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.progress.hide() self.progress = None - if thread.error: - (title, msg) = thread.error + if thread.msg: + (title, msg) = thread.msg QtGui.QMessageBox.warning( None, self.tr(title),