First pylint pass
Fixed errors pointed out by pylint.
This commit is contained in:
parent
4e2835531e
commit
a1c6e72569
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
# pylint: skip-file
|
||||
#
|
||||
# The Qubes OS Project, http://www.qubes-os.org
|
||||
#
|
||||
@ -57,12 +56,10 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
self.qvm_collection = qvm_collection
|
||||
self.backup_settings = QtCore.QSettings()
|
||||
|
||||
self.func_output = []
|
||||
self.selected_vms = []
|
||||
self.tmpdir_to_remove = None
|
||||
self.canceled = False
|
||||
|
||||
self.files_to_backup = None
|
||||
self.thread_monitor = None
|
||||
|
||||
self.setupUi(self)
|
||||
|
||||
@ -122,7 +119,12 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
def load_settings(self):
|
||||
try:
|
||||
profile_data = backup_utils.load_backup_profile()
|
||||
except Exception as ex: # TODO: fix just for file not found
|
||||
except FileNotFoundError as ex: # pylint: disable=unused-variable
|
||||
return
|
||||
except exc.QubesException as qex: # pylint: disable=unused-variable
|
||||
QtGui.QMessageBox.information(
|
||||
None, self.tr("Error loading backup profile"),
|
||||
self.tr("Unable to load saved backup profile."))
|
||||
return
|
||||
if not profile_data:
|
||||
return
|
||||
@ -157,6 +159,7 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
backup_utils.write_backup_profile(settings, use_temp)
|
||||
|
||||
class VmListItem(QtGui.QListWidgetItem):
|
||||
# pylint: disable=too-few-public-methods
|
||||
def __init__(self, vm):
|
||||
self.vm = vm
|
||||
if vm.qid == 0:
|
||||
@ -207,6 +210,7 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
backup_utils.select_path_button_clicked(self)
|
||||
|
||||
def validateCurrentPage(self):
|
||||
# pylint: disable=invalid-name
|
||||
if self.currentPage() is self.select_vms_page:
|
||||
|
||||
self.selected_vms = []
|
||||
@ -243,13 +247,10 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
|
||||
return True
|
||||
|
||||
# def gather_output(self, s):
|
||||
# self.func_output.append(s)
|
||||
|
||||
def update_progress_bar(self, value):
|
||||
self.emit(QtCore.SIGNAL("backup_progress(int)"), value)
|
||||
|
||||
def __do_backup__(self, thread_monitor):
|
||||
def __do_backup__(self, t_monitor):
|
||||
msg = []
|
||||
|
||||
try:
|
||||
@ -257,7 +258,6 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
events_dispatcher = events.EventsDispatcher(self.app)
|
||||
events_dispatcher.add_handler('backup-progress',
|
||||
self.update_progress_bar)
|
||||
try:
|
||||
vm = self.qvm_collection.domains[
|
||||
self.appvm_combobox.currentText()]
|
||||
if not vm.is_running():
|
||||
@ -265,21 +265,16 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
self.qvm_collection.qubesd_call(
|
||||
'dom0', 'admin.backup.Execute',
|
||||
backup_utils.get_profile_name(True))
|
||||
except exc.QubesException as err:
|
||||
# TODO fixme
|
||||
print('\nBackup error: {}'.format(err), file=sys.stderr)
|
||||
return 1
|
||||
except Exception as ex: # TODO: fixme
|
||||
print("Exception:", ex)
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
msg.append(str(ex))
|
||||
|
||||
if len(msg) > 0:
|
||||
thread_monitor.set_error_msg('\n'.join(msg))
|
||||
t_monitor.set_error_msg('\n'.join(msg))
|
||||
|
||||
thread_monitor.set_finished()
|
||||
t_monitor.set_finished()
|
||||
|
||||
|
||||
def current_page_changed(self, id):
|
||||
def current_page_changed(self, page_id): # pylint: disable=unused-argument
|
||||
old_sigchld_handler = signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
||||
if self.currentPage() is self.confirm_page:
|
||||
|
||||
@ -371,6 +366,7 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
||||
return len(self.dir_line_edit.text()) > 0
|
||||
|
||||
def backup_location_changed(self, new_dir=None):
|
||||
# pylint: disable=unused-argument
|
||||
self.select_dir_page.emit(QtCore.SIGNAL("completeChanged()"))
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/python2
|
||||
# pylint: skip-file
|
||||
#
|
||||
# The Qubes OS Project, http://www.qubes-os.org
|
||||
#
|
||||
@ -67,6 +66,7 @@ def select_path_button_clicked(dialog, select_file=False):
|
||||
"qubes.SelectFile" if select_file
|
||||
else "qubes.SelectDirectory")
|
||||
except subprocess.CalledProcessError as ex:
|
||||
# pylint: disable=unused-variable
|
||||
QtGui.QMessageBox.warning(
|
||||
None,
|
||||
dialog.tr("Nothing selected!"),
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/python2
|
||||
# pylint: skip-file
|
||||
#
|
||||
# The Qubes OS Project, http://www.qubes-os.org
|
||||
#
|
||||
@ -22,13 +21,12 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
from PyQt4 import QtCore
|
||||
from PyQt4 import QtGui
|
||||
from . import thread_monitor
|
||||
import threading
|
||||
import time
|
||||
import os
|
||||
import os.path
|
||||
import traceback
|
||||
|
||||
@ -38,8 +36,9 @@ from qubes import backup
|
||||
|
||||
from . import ui_restoredlg
|
||||
from . import multiselectwidget
|
||||
|
||||
from . import backup_utils
|
||||
from . import thread_monitor
|
||||
|
||||
from multiprocessing import Queue, Event
|
||||
from multiprocessing.queues import Empty
|
||||
from qubesadmin import Qubes, exc
|
||||
@ -56,13 +55,15 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
self.app = app
|
||||
self.qvm_collection = qvm_collection
|
||||
|
||||
self.restore_options = None
|
||||
self.vms_to_restore = None
|
||||
self.func_output = []
|
||||
self.feedback_queue = Queue()
|
||||
self.canceled = False
|
||||
self.tmpdir_to_remove = None
|
||||
self.error_detected = Event()
|
||||
self.thread_monitor = None
|
||||
self.backup_restore = None
|
||||
self.target_appvm = None
|
||||
|
||||
self.setupUi(self)
|
||||
|
||||
@ -70,12 +71,14 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
self.select_vms_layout.insertWidget(1, self.select_vms_widget)
|
||||
|
||||
self.connect(self,
|
||||
QtCore.SIGNAL("currentIdChanged(int)"), self.current_page_changed)
|
||||
QtCore.SIGNAL("currentIdChanged(int)"),
|
||||
self.current_page_changed)
|
||||
self.connect(self,
|
||||
QtCore.SIGNAL("restore_progress(QString)"),
|
||||
self.commit_text_edit.append)
|
||||
self.connect(self,
|
||||
QtCore.SIGNAL("backup_progress(int)"), self.progress_bar.setValue)
|
||||
QtCore.SIGNAL("backup_progress(int)"),
|
||||
self.progress_bar.setValue)
|
||||
self.dir_line_edit.connect(self.dir_line_edit,
|
||||
QtCore.SIGNAL("textChanged(QString)"),
|
||||
self.backup_location_changed)
|
||||
@ -98,17 +101,7 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
def select_path_button_clicked(self):
|
||||
backup_utils.select_path_button_clicked(self, True)
|
||||
|
||||
def on_ignore_missing_toggled(self, checked):
|
||||
self.restore_options['use-default-template'] = checked
|
||||
self.restore_options['use-default-netvm'] = checked
|
||||
|
||||
def on_ignore_uname_mismatch_toggled(self, checked):
|
||||
self.restore_options['ignore-username-mismatch'] = checked
|
||||
|
||||
def on_verify_only_toogled(self, checked):
|
||||
self.restore_options['verify-only'] = bool(checked)
|
||||
|
||||
def cleanupPage(self, p_int):
|
||||
def cleanupPage(self, p_int): # pylint: disable=invalid-name
|
||||
if self.page(p_int) is self.select_vms_page:
|
||||
self.vms_to_restore = None
|
||||
else:
|
||||
@ -154,22 +147,20 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
except exc.QubesException as ex:
|
||||
QtGui.QMessageBox.warning(None, self.tr("Restore error!"), str(ex))
|
||||
|
||||
def gather_output(self, s):
|
||||
self.func_output.append(s)
|
||||
|
||||
def restore_error_output(self, s):
|
||||
def restore_error_output(self, text):
|
||||
self.error_detected.set()
|
||||
self.feedback_queue.put((QtCore.SIGNAL("restore_progress(QString)"),
|
||||
u'<font color="red">{0}</font>'.format(s)))
|
||||
u'<font color="red">{0}</font>'.format(text)))
|
||||
|
||||
def restore_output(self, s):
|
||||
self.feedback_queue.put((QtCore.SIGNAL("restore_progress(QString)"),
|
||||
u'<font color="black">{0}</font>'.format(s)))
|
||||
def restore_output(self, text):
|
||||
self.feedback_queue.put((
|
||||
QtCore.SIGNAL("restore_progress(QString)"),
|
||||
u'<font color="black">{0}</font>'.format(text)))
|
||||
|
||||
def update_progress_bar(self, value):
|
||||
self.feedback_queue.put((QtCore.SIGNAL("backup_progress(int)"), value))
|
||||
|
||||
def __do_restore__(self, thread_monitor):
|
||||
def __do_restore__(self, t_monitor):
|
||||
err_msg = []
|
||||
try:
|
||||
self.backup_restore.progress_callback = self.update_progress_bar
|
||||
@ -179,7 +170,7 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
self.canceled = True
|
||||
self.tmpdir_to_remove = ex.tmpdir
|
||||
err_msg.append(str(ex))
|
||||
except Exception as ex:
|
||||
except Exception as ex: # pylint: disable=broad-except
|
||||
err_msg.append(str(ex))
|
||||
err_msg.append(
|
||||
self.tr("Partially restored files left in /var/tmp/restore_*, "
|
||||
@ -191,7 +182,7 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
.format(self.tr("Restore aborted!")))
|
||||
elif len(err_msg) > 0 or self.error_detected.is_set():
|
||||
if len(err_msg) > 0:
|
||||
thread_monitor.set_error_msg('\n'.join(err_msg))
|
||||
t_monitor.set_error_msg('\n'.join(err_msg))
|
||||
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
||||
'<b><font color="red">{0}</font></b>'
|
||||
.format(self.tr("Finished with errors!")))
|
||||
@ -200,9 +191,9 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
'<font color="green">{0}</font>'
|
||||
.format(self.tr("Finished successfully!")))
|
||||
|
||||
thread_monitor.set_finished()
|
||||
t_monitor.set_finished()
|
||||
|
||||
def current_page_changed(self, id):
|
||||
def current_page_changed(self, page_id): # pylint: disable=unused-argument
|
||||
|
||||
old_sigchld_handler = signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
||||
if self.currentPage() is self.select_vms_page:
|
||||
@ -237,7 +228,8 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
.count("media/") > 0)
|
||||
|
||||
self.thread_monitor = thread_monitor.ThreadMonitor()
|
||||
thread = threading.Thread (target=self.__do_restore__, args=(self.thread_monitor,))
|
||||
thread = threading.Thread(target=self.__do_restore__,
|
||||
args=(self.thread_monitor,))
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
@ -245,7 +237,8 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
self.app.processEvents()
|
||||
time.sleep(0.1)
|
||||
try:
|
||||
for (signal_to_emit,data) in iter(self.feedback_queue.get_nowait,None):
|
||||
for (signal_to_emit, data) in iter(
|
||||
self.feedback_queue.get_nowait, None):
|
||||
self.emit(signal_to_emit, data)
|
||||
except Empty:
|
||||
pass
|
||||
@ -325,6 +318,7 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
||||
return self.select_vms_widget.selected_list.count() > 0
|
||||
|
||||
def backup_location_changed(self, new_dir=None):
|
||||
# pylint: disable=unused-argument
|
||||
self.select_dir_page.emit(QtCore.SIGNAL("completeChanged()"))
|
||||
|
||||
|
||||
|
1
test-packages/qubes/storage/__init__.py
Normal file
1
test-packages/qubes/storage/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
pass
|
2
test-packages/qubes/storage/file.py
Normal file
2
test-packages/qubes/storage/file.py
Normal file
@ -0,0 +1,2 @@
|
||||
def get_disk_usage(*args):
|
||||
return None
|
Loading…
Reference in New Issue
Block a user