From 831769d2dd3a149ad09ed2daeb04baa8b8df7ba6 Mon Sep 17 00:00:00 2001 From: donoban Date: Sat, 20 Oct 2018 23:01:35 +0200 Subject: [PATCH] Fix travis build --- qubesmanager.pro | 2 +- qubesmanager/backup.py | 2 +- qubesmanager/common_threads.py | 3 ++- qubesmanager/create_new_vm.py | 9 +++++---- qubesmanager/qube_manager.py | 11 ++++++----- qubesmanager/restore.py | 13 ++++++++----- qubesmanager/settings.py | 18 ++++++++---------- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/qubesmanager.pro b/qubesmanager.pro index 51f4d1c..f186c52 100644 --- a/qubesmanager.pro +++ b/qubesmanager.pro @@ -17,6 +17,7 @@ SOURCES = \ qubesmanager/block.py \ qubesmanager/clipboard.py \ qubesmanager/create_new_vm.py \ + qubesmanager/common_threads.py \ qubesmanager/firewall.py \ qubesmanager/global_settings.py \ qubesmanager/log_dialog.py \ @@ -27,7 +28,6 @@ SOURCES = \ qubesmanager/restore.py \ qubesmanager/settings.py \ qubesmanager/table_widgets.py \ - qubesmanager/thread_monitor.py \ qubesmanager/ui_about.py \ qubesmanager/ui_backupdlg.py \ qubesmanager/ui_globalsettingsdlg.py \ diff --git a/qubesmanager/backup.py b/qubesmanager/backup.py index 9847c9c..542df22 100644 --- a/qubesmanager/backup.py +++ b/qubesmanager/backup.py @@ -44,7 +44,6 @@ import sys import os import asyncio from contextlib import suppress -import time class BackupThread(QtCore.QThread): def __init__(self, vm): @@ -76,6 +75,7 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard): self.backup_settings = QtCore.QSettings() self.selected_vms = [] + self.thread = None self.setupUi(self) diff --git a/qubesmanager/common_threads.py b/qubesmanager/common_threads.py index c7fd1ff..746f9ea 100644 --- a/qubesmanager/common_threads.py +++ b/qubesmanager/common_threads.py @@ -42,10 +42,11 @@ class CloneVMThread(QtCore.QThread): QtCore.QThread.__init__(self) self.src_vm = src_vm self.dst_name = dst_name + self.error = None def run(self): try: - dst_vm = self.src_vm.app.clone_vm(self.src_vm, self.dst_name) + self.src_vm.app.clone_vm(self.src_vm, self.dst_name) self.error = ("Sucess", "The qube was cloned sucessfully.") except exc.QubesException as ex: self.error = ("Error while cloning Qube!", str(ex)) diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index 73959ad..88122c3 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -22,8 +22,6 @@ # import sys -import threading -import time import subprocess from PyQt4 import QtCore, QtGui # pylint: disable=import-error @@ -78,6 +76,9 @@ class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg): self.qtapp = qtapp self.app = app + self.thread = None + self.progress = None + # Theoretically we should be locking for writing here and unlock # only after the VM creation finished. But the code would be # more messy... @@ -174,7 +175,7 @@ class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg): if self.thread.error: QtGui.QMessageBox.warning(None, self.tr("Error creating the qube!"), - self.tr("ERROR: {}").format(thread.error)) + self.tr("ERROR: {}").format(self.thread.error)) self.done(0) @@ -183,7 +184,7 @@ class NewVmDlg(QtGui.QDialog, Ui_NewVMDlg): subprocess.check_call(['qubes-vm-settings', str(self.name)]) if self.install_system.isChecked(): subprocess.check_call( - ['qubes-vm-boot-from-device', srt(self.name)]) + ['qubes-vm-boot-from-device', str(self.name)]) def type_change(self): diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index ef9e495..25ea5d3 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -28,7 +28,6 @@ import subprocess from datetime import datetime, timedelta import traceback from contextlib import suppress -import time import quamash import asyncio @@ -282,6 +281,7 @@ class RunCommandThread(QtCore.QThread): QtCore.QThread.__init__(self) self.vm = vm self.command_to_run = command_to_run + self.error = None def run(self): try: @@ -450,7 +450,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): dispatcher.add_handler('domain-start-failed', self.on_domain_status_changed) dispatcher.add_handler('domain-stopped', self.on_domain_status_changed) - dispatcher.add_handler('domain-pre-shutdown', self.on_domain_status_changed) + dispatcher.add_handler('domain-pre-shutdown', + self.on_domain_status_changed) dispatcher.add_handler('domain-shutdown', self.on_domain_status_changed) dispatcher.add_handler('domain-paused', self.on_domain_status_changed) dispatcher.add_handler('domain-unpaused', self.on_domain_status_changed) @@ -777,7 +778,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): # remove the VM thread = common_threads.RemoveVMThread(vm) self.threads_list.append(thread) - self.connect(thread, QtCore.SIGNAL("show_error(QString, QString)"), self.show_error) + self.connect(thread, QtCore.SIGNAL("show_error(QString, QString)"), + self.show_error) thread.finished.connect(self.clear_threads) thread.start() @@ -803,7 +805,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): "Cloning Qube..."), "", 0, 0) self.progress.setCancelButton(None) self.progress.setModal(True) - self.thread_closes = True self.progress.show() thread = common_threads.CloneVMThread(vm, clone_name) @@ -871,7 +872,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.tr("Are you sure you want to power down the Qube" " '{0}'?
This will shutdown all the " "running applications within this Qube.").format( - vm.name), QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel) + vm.name), QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel) self.qt_app.processEvents() diff --git a/qubesmanager/restore.py b/qubesmanager/restore.py index 985e346..6cb46c7 100644 --- a/qubesmanager/restore.py +++ b/qubesmanager/restore.py @@ -23,8 +23,6 @@ import sys from PyQt4 import QtCore # pylint: disable=import-error from PyQt4 import QtGui # pylint: disable=import-error -import threading -import time import os import os.path import traceback @@ -39,7 +37,7 @@ from . import ui_restoredlg # pylint: disable=no-name-in-module from . import multiselectwidget from . import backup_utils -from multiprocessing import Queue, Event +from multiprocessing import Queue from multiprocessing.queues import Empty from qubesadmin import Qubes, exc from qubesadmin.backup import restore @@ -52,6 +50,7 @@ class RestoreThread(QtCore.QThread): self.vms_to_restore = vms_to_restore self.error = None self.msg = None + self.canceled = None def run(self): err_msg = [] @@ -85,6 +84,9 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard): self.vms_to_restore = None self.func_output = [] + self.thread = None + self.old_sigchld_handler = None + # Set up logging self.feedback_queue = Queue() handler = logging.handlers.QueueHandler(self.feedback_queue) @@ -206,13 +208,14 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard): and str(self.dir_line_edit.text()) .count("media/") > 0) - self.thread = RestoreThread(self.backup_restore, self.vms_to_restore) + self.thread = RestoreThread(self.backup_restore, + self.vms_to_restore) self.thread.finished.connect(self.thread_finished) # Start log timer timer = QtCore.QTimer(self) timer.timeout.connect(self.update_log) - timer.start(1000) + timer.start(1000) self.thread.start() diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 51b697d..742cc8e 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -28,8 +28,6 @@ import os.path import os import re import subprocess -import threading -import time import traceback import sys from qubesadmin.tools import QubesArgumentParser @@ -85,9 +83,9 @@ class RenameVMThread(QtCore.QThread): "To resolve this, please check and change the " "following properties and remove the qube {} " "manually.
").format( - self.vm.name, name, self.vm.name) + list_text) + self.vm.name, self.vm.name, self.vm.name) + list_text) - except exc.QubesException as qex: + except exc.QubesException as ex: self.error = ("Rename error!", str(ex)) except Exception as ex: # pylint: disable=broad-except self.error = ("Rename error!", repr(ex)) @@ -117,7 +115,7 @@ class RefreshAppsVMThread(QtCore.QThread): if not_running: target_vm.shutdown() - except Exception as ex: + except Exception as ex: # pylint: disable=broad-except self.error = ("Refresh failed!", str(ex)) @@ -265,7 +263,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self, self.tr("Error while changing settings for {0}!" ).format(self.vm.name), - self.tr("ERROR: {0}").format('\n'.join(ret))) + self.tr("ERROR: {0}").format('\n'.join(error))) def apply(self): self.save_changes() @@ -564,7 +562,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if ok: thread = RenameVMThread(self.vm, new_vm_name, dependencies) self.threads_list.append(thread) - thread.finished.connect(self.clear_threads) + thread.finished.connect(self.clear_threads) self.progress = QtGui.QProgressDialog( self.tr( @@ -621,7 +619,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if ok: thread = common_threads.CloneVMThread(self.vm, cloned_vm_name) - thread.finished.connect(self.clear_threads) + thread.finished.connect(self.clear_threads) self.threads_list.append(thread) self.progress = QtGui.QProgressDialog( @@ -966,8 +964,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.refresh_apps_button.setText(self.tr('Refresh in progress...')) thread = RefreshAppsVMThread(self.vm) - thread.finished.connect(self.clear_threads) - thread.finished.connect(self.refresh_finished) + thread.finished.connect(self.clear_threads) + thread.finished.connect(self.refresh_finished) self.threads_list.append(thread) thread.start()