2013-01-23 15:55:14 +01:00
|
|
|
#!/usr/bin/python2
|
2012-01-31 11:17:09 +01:00
|
|
|
#
|
|
|
|
# The Qubes OS Project, http://www.qubes-os.org
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012 Agnieszka Kostrzewa <agnieszka.kostrzewa@gmail.com>
|
|
|
|
# Copyright (C) 2012 Marek Marczykowski <marmarek@mimuw.edu.pl>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
2017-11-06 21:06:30 +01:00
|
|
|
# You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
2012-01-31 11:17:09 +01:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
2014-03-08 03:58:59 +01:00
|
|
|
import shutil
|
2017-12-10 22:11:07 +01:00
|
|
|
from PyQt4 import QtCore
|
|
|
|
from PyQt4 import QtGui
|
|
|
|
import threading
|
2017-12-10 21:14:14 +01:00
|
|
|
import time
|
2017-12-11 00:50:40 +01:00
|
|
|
import os
|
2017-12-10 21:14:14 +01:00
|
|
|
import os.path
|
|
|
|
import traceback
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2014-01-10 03:38:38 +01:00
|
|
|
import signal
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2013-11-28 03:50:17 +01:00
|
|
|
from qubes import backup
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
from . import ui_restoredlg
|
|
|
|
from . import multiselectwidget
|
|
|
|
from . import backup_utils
|
2017-12-11 00:50:40 +01:00
|
|
|
from . import thread_monitor
|
|
|
|
|
2014-09-17 23:07:32 +02:00
|
|
|
from multiprocessing import Queue, Event
|
2013-11-29 03:26:51 +01:00
|
|
|
from multiprocessing.queues import Empty
|
2017-12-10 22:11:07 +01:00
|
|
|
from qubesadmin import Qubes, exc
|
2017-12-10 21:14:14 +01:00
|
|
|
from qubesadmin.backup import restore
|
|
|
|
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
__pyqtSignals__ = ("restore_progress(int)", "backup_progress(int)")
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
def __init__(self, app, qvm_collection, parent=None):
|
2012-01-31 11:17:09 +01:00
|
|
|
super(RestoreVMsWindow, self).__init__(parent)
|
|
|
|
|
2012-02-22 06:09:25 +01:00
|
|
|
self.app = app
|
|
|
|
self.qvm_collection = qvm_collection
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2014-01-13 05:22:52 +01:00
|
|
|
self.vms_to_restore = None
|
2012-02-22 06:09:25 +01:00
|
|
|
self.func_output = []
|
2013-11-29 03:26:51 +01:00
|
|
|
self.feedback_queue = Queue()
|
2014-03-08 03:58:59 +01:00
|
|
|
self.canceled = False
|
|
|
|
self.tmpdir_to_remove = None
|
2014-09-17 23:07:32 +02:00
|
|
|
self.error_detected = Event()
|
2017-12-11 00:50:40 +01:00
|
|
|
self.thread_monitor = None
|
|
|
|
self.backup_restore = None
|
|
|
|
self.target_appvm = None
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2012-02-22 06:09:25 +01:00
|
|
|
self.setupUi(self)
|
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
self.select_vms_widget = multiselectwidget.MultiSelectWidget(self)
|
2012-02-22 06:09:25 +01:00
|
|
|
self.select_vms_layout.insertWidget(1, self.select_vms_widget)
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
self.connect(self,
|
2017-12-11 00:50:40 +01:00
|
|
|
QtCore.SIGNAL("currentIdChanged(int)"),
|
|
|
|
self.current_page_changed)
|
2017-12-10 21:14:14 +01:00
|
|
|
self.connect(self,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("restore_progress(QString)"),
|
2017-12-10 21:14:14 +01:00
|
|
|
self.commit_text_edit.append)
|
|
|
|
self.connect(self,
|
2017-12-11 00:50:40 +01:00
|
|
|
QtCore.SIGNAL("backup_progress(int)"),
|
|
|
|
self.progress_bar.setValue)
|
2017-12-10 21:14:14 +01:00
|
|
|
self.dir_line_edit.connect(self.dir_line_edit,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("textChanged(QString)"),
|
2017-12-10 21:14:14 +01:00
|
|
|
self.backup_location_changed)
|
2017-12-10 22:11:07 +01:00
|
|
|
self.connect(self.verify_only, QtCore.SIGNAL("stateChanged(int)"),
|
2014-09-17 23:07:32 +02:00
|
|
|
self.on_verify_only_toogled)
|
2012-02-22 06:09:25 +01:00
|
|
|
|
|
|
|
self.select_dir_page.isComplete = self.has_selected_dir
|
|
|
|
self.select_vms_page.isComplete = self.has_selected_vms
|
2013-11-28 03:52:02 +01:00
|
|
|
self.confirm_page.isComplete = self.all_vms_good
|
2017-12-10 21:14:14 +01:00
|
|
|
# FIXME
|
|
|
|
# this causes to run isComplete() twice, I don't know why
|
|
|
|
self.select_vms_page.connect(
|
|
|
|
self.select_vms_widget,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("selected_changed()"),
|
|
|
|
QtCore.SIGNAL("completeChanged()"))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
backup_utils.fill_appvms_list(self)
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
@QtCore.pyqtSlot(name='on_select_path_button_clicked')
|
2012-02-22 06:09:25 +01:00
|
|
|
def select_path_button_clicked(self):
|
2017-12-10 22:11:07 +01:00
|
|
|
backup_utils.select_path_button_clicked(self, True)
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
def cleanupPage(self, p_int): # pylint: disable=invalid-name
|
2014-01-13 05:22:52 +01:00
|
|
|
if self.page(p_int) is self.select_vms_page:
|
|
|
|
self.vms_to_restore = None
|
|
|
|
else:
|
|
|
|
super(RestoreVMsWindow, self).cleanupPage(p_int)
|
2012-02-22 06:09:25 +01:00
|
|
|
|
|
|
|
def __fill_vms_list__(self):
|
2014-01-13 05:22:52 +01:00
|
|
|
if self.vms_to_restore is not None:
|
2012-02-22 06:09:25 +01:00
|
|
|
return
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2012-02-22 06:09:25 +01:00
|
|
|
self.select_vms_widget.selected_list.clear()
|
|
|
|
self.select_vms_widget.available_list.clear()
|
2013-09-27 09:19:38 +02:00
|
|
|
|
2017-12-11 00:13:15 +01:00
|
|
|
self.target_appvm = None
|
2017-12-10 21:14:14 +01:00
|
|
|
if self.appvm_combobox.currentIndex() != 0: # An existing appvm chosen
|
|
|
|
self.target_appvm = self.qvm_collection.domains[
|
|
|
|
str(self.appvm_combobox.currentText())]
|
2013-11-28 03:50:17 +01:00
|
|
|
|
2013-11-29 03:33:17 +01:00
|
|
|
try:
|
2017-12-10 21:14:14 +01:00
|
|
|
self.backup_restore = restore.BackupRestore(
|
|
|
|
self.qvm_collection,
|
|
|
|
self.dir_line_edit.text(),
|
|
|
|
self.target_appvm,
|
|
|
|
self.passphrase_line_edit.text()
|
|
|
|
)
|
|
|
|
|
|
|
|
if self.ignore_missing.isChecked():
|
|
|
|
self.backup_restore.options.use_default_template = True
|
|
|
|
self.backup_restore.options.use_default_netvm = True
|
|
|
|
|
|
|
|
if self.ignore_uname_mismatch.isChecked():
|
|
|
|
self.backup_restore.options.ignore_username_mismatch = True
|
|
|
|
|
|
|
|
if self.verify_only.isChecked():
|
|
|
|
self.backup_restore.options.verify_only = True
|
|
|
|
|
|
|
|
self.vms_to_restore = self.backup_restore.get_restore_info()
|
2013-11-29 03:33:17 +01:00
|
|
|
|
|
|
|
for vmname in self.vms_to_restore:
|
2014-01-13 05:18:03 +01:00
|
|
|
if vmname.startswith('$'):
|
|
|
|
# Internal info
|
|
|
|
continue
|
2013-11-29 03:33:17 +01:00
|
|
|
self.select_vms_widget.available_list.addItem(vmname)
|
2017-12-10 21:14:14 +01:00
|
|
|
except exc.QubesException as ex:
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.warning(None, self.tr("Restore error!"), str(ex))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
def restore_error_output(self, text):
|
2014-09-17 23:07:32 +02:00
|
|
|
self.error_detected.set()
|
2017-12-10 22:11:07 +01:00
|
|
|
self.feedback_queue.put((QtCore.SIGNAL("restore_progress(QString)"),
|
2017-12-11 00:50:40 +01:00
|
|
|
u'<font color="red">{0}</font>'.format(text)))
|
2013-11-28 03:45:22 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
def restore_output(self, text):
|
|
|
|
self.feedback_queue.put((
|
|
|
|
QtCore.SIGNAL("restore_progress(QString)"),
|
|
|
|
u'<font color="black">{0}</font>'.format(text)))
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2013-09-27 09:19:38 +02:00
|
|
|
def update_progress_bar(self, value):
|
2017-12-10 22:11:07 +01:00
|
|
|
self.feedback_queue.put((QtCore.SIGNAL("backup_progress(int)"), value))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
def __do_restore__(self, t_monitor):
|
2012-02-22 06:09:25 +01:00
|
|
|
err_msg = []
|
|
|
|
try:
|
2017-12-10 21:14:14 +01:00
|
|
|
self.backup_restore.progress_callback = self.update_progress_bar
|
|
|
|
self.backup_restore.restore_do(self.vms_to_restore)
|
|
|
|
|
2014-03-08 03:58:59 +01:00
|
|
|
except backup.BackupCanceledError as ex:
|
|
|
|
self.canceled = True
|
|
|
|
self.tmpdir_to_remove = ex.tmpdir
|
2017-06-28 12:25:28 +02:00
|
|
|
err_msg.append(str(ex))
|
2017-12-11 00:50:40 +01:00
|
|
|
except Exception as ex: # pylint: disable=broad-except
|
2017-06-28 12:25:28 +02:00
|
|
|
err_msg.append(str(ex))
|
2017-01-22 05:42:38 +01:00
|
|
|
err_msg.append(
|
2017-12-10 21:14:14 +01:00
|
|
|
self.tr("Partially restored files left in /var/tmp/restore_*, "
|
|
|
|
"investigate them and/or clean them up"))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2014-03-08 03:58:59 +01:00
|
|
|
if self.canceled:
|
2017-12-10 22:11:07 +01:00
|
|
|
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
2014-09-17 23:06:41 +02:00
|
|
|
'<b><font color="red">{0}</font></b>'
|
2017-01-22 05:42:38 +01:00
|
|
|
.format(self.tr("Restore aborted!")))
|
2014-09-17 23:07:32 +02:00
|
|
|
elif len(err_msg) > 0 or self.error_detected.is_set():
|
|
|
|
if len(err_msg) > 0:
|
2017-12-11 00:50:40 +01:00
|
|
|
t_monitor.set_error_msg('\n'.join(err_msg))
|
2017-12-10 22:11:07 +01:00
|
|
|
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
2014-09-17 23:06:41 +02:00
|
|
|
'<b><font color="red">{0}</font></b>'
|
2017-01-22 05:42:38 +01:00
|
|
|
.format(self.tr("Finished with errors!")))
|
2012-02-22 06:09:25 +01:00
|
|
|
else:
|
2017-12-10 22:11:07 +01:00
|
|
|
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
2014-09-17 23:06:41 +02:00
|
|
|
'<font color="green">{0}</font>'
|
2017-01-22 05:42:38 +01:00
|
|
|
.format(self.tr("Finished successfully!")))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
t_monitor.set_finished()
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
def current_page_changed(self, page_id): # pylint: disable=unused-argument
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2014-01-10 03:38:38 +01:00
|
|
|
old_sigchld_handler = signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
2012-02-22 06:09:25 +01:00
|
|
|
if self.currentPage() is self.select_vms_page:
|
|
|
|
self.__fill_vms_list__()
|
|
|
|
|
|
|
|
elif self.currentPage() is self.confirm_page:
|
2017-12-10 23:56:22 +01:00
|
|
|
|
|
|
|
self.vms_to_restore = self.backup_restore.get_restore_info()
|
|
|
|
|
2012-02-22 06:09:25 +01:00
|
|
|
for i in range(self.select_vms_widget.available_list.count()):
|
2017-12-10 23:56:22 +01:00
|
|
|
vmname = self.select_vms_widget.available_list.item(i).text()
|
2012-02-22 06:09:25 +01:00
|
|
|
del self.vms_to_restore[str(vmname)]
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
self.vms_to_restore = self.backup_restore.restore_info_verify(
|
2017-12-10 23:56:22 +01:00
|
|
|
self.vms_to_restore)
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
self.func_output = self.backup_restore.get_restore_summary(
|
2017-12-10 23:56:22 +01:00
|
|
|
self.vms_to_restore
|
2017-12-10 21:14:14 +01:00
|
|
|
)
|
2017-12-10 23:56:22 +01:00
|
|
|
|
2012-02-22 06:09:25 +01:00
|
|
|
self.confirm_text_edit.setReadOnly(True)
|
|
|
|
self.confirm_text_edit.setFontFamily("Monospace")
|
2017-12-10 21:14:14 +01:00
|
|
|
self.confirm_text_edit.setText(self.func_output)
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
self.confirm_page.emit(QtCore.SIGNAL("completeChanged()"))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
|
|
|
elif self.currentPage() is self.commit_page:
|
|
|
|
self.button(self.FinishButton).setDisabled(True)
|
2014-09-26 15:01:37 +02:00
|
|
|
self.showFileDialog.setEnabled(True)
|
2014-05-15 03:06:51 +02:00
|
|
|
self.showFileDialog.setChecked(self.showFileDialog.isEnabled()
|
|
|
|
and str(self.dir_line_edit.text())
|
|
|
|
.count("media/") > 0)
|
2013-11-28 03:45:22 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
self.thread_monitor = thread_monitor.ThreadMonitor()
|
2017-12-11 00:50:40 +01:00
|
|
|
thread = threading.Thread(target=self.__do_restore__,
|
|
|
|
args=(self.thread_monitor,))
|
2012-02-22 06:09:25 +01:00
|
|
|
thread.daemon = True
|
|
|
|
thread.start()
|
|
|
|
|
|
|
|
while not self.thread_monitor.is_finished():
|
|
|
|
self.app.processEvents()
|
2017-12-11 00:50:40 +01:00
|
|
|
time.sleep(0.1)
|
2013-11-29 03:26:51 +01:00
|
|
|
try:
|
2017-12-11 00:50:40 +01:00
|
|
|
for (signal_to_emit, data) in iter(
|
|
|
|
self.feedback_queue.get_nowait, None):
|
|
|
|
self.emit(signal_to_emit, data)
|
2013-11-29 03:26:51 +01:00
|
|
|
except Empty:
|
|
|
|
pass
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2014-01-10 03:40:11 +01:00
|
|
|
if not self.thread_monitor.success:
|
2014-03-08 03:58:59 +01:00
|
|
|
if self.canceled:
|
|
|
|
if self.tmpdir_to_remove and \
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.warning(
|
|
|
|
None,
|
|
|
|
self.tr("Restore aborted"),
|
2017-06-28 12:25:28 +02:00
|
|
|
self.tr("Do you want to remove temporary files "
|
|
|
|
"from %s?") % self.tmpdir_to_remove,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.Yes,
|
|
|
|
QtGui.QMessageBox.No) == QtGui.QMessageBox.Yes:
|
2014-03-08 03:58:59 +01:00
|
|
|
shutil.rmtree(self.tmpdir_to_remove)
|
|
|
|
else:
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.warning(
|
|
|
|
None,
|
|
|
|
self.tr("Backup error!"),
|
|
|
|
self.tr("ERROR: {0}").format(
|
|
|
|
self.thread_monitor.error_msg))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
if self.showFileDialog.isChecked(): # TODO: this is not working
|
2017-12-10 22:11:07 +01:00
|
|
|
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
2014-05-15 03:06:51 +02:00
|
|
|
'<b><font color="black">{0}</font></b>'.format(
|
2017-01-22 05:42:38 +01:00
|
|
|
self.tr(
|
|
|
|
"Please unmount your backup volume and cancel"
|
|
|
|
" the file selection dialog.")))
|
2017-12-10 21:14:14 +01:00
|
|
|
if self.target_appvm: # TODO does this work at all?
|
2017-01-22 05:42:38 +01:00
|
|
|
self.target_appvm.run("QUBESRPC %s dom0" %
|
|
|
|
"qubes.SelectDirectory")
|
2014-09-26 15:01:37 +02:00
|
|
|
else:
|
2017-12-10 22:11:07 +01:00
|
|
|
file_dialog = QtGui.QFileDialog()
|
2014-09-26 15:01:37 +02:00
|
|
|
file_dialog.setReadOnly(True)
|
2015-03-31 05:40:53 +02:00
|
|
|
file_dialog.getExistingDirectory(
|
2017-01-22 05:42:38 +01:00
|
|
|
self, self.tr("Detach backup device"),
|
2017-06-28 12:25:28 +02:00
|
|
|
os.path.dirname(self.dir_line_edit.text()))
|
2013-11-29 03:26:51 +01:00
|
|
|
self.progress_bar.setValue(100)
|
2012-02-22 06:09:25 +01:00
|
|
|
self.button(self.FinishButton).setEnabled(True)
|
2014-03-08 03:58:59 +01:00
|
|
|
self.button(self.CancelButton).setEnabled(False)
|
2014-05-15 03:06:51 +02:00
|
|
|
self.showFileDialog.setEnabled(False)
|
2012-03-02 02:50:12 +01:00
|
|
|
|
2014-01-10 03:38:38 +01:00
|
|
|
signal.signal(signal.SIGCHLD, old_sigchld_handler)
|
|
|
|
|
2013-11-28 03:52:02 +01:00
|
|
|
def all_vms_good(self):
|
2017-12-10 21:14:14 +01:00
|
|
|
for vm_info in self.vms_to_restore.values():
|
|
|
|
if not vm_info.vm:
|
2014-01-13 05:18:03 +01:00
|
|
|
continue
|
2017-12-10 21:14:14 +01:00
|
|
|
if not vm_info.good_to_go:
|
2013-11-28 03:52:02 +01:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
def reject(self): # TODO: probably not working too
|
2014-03-08 03:58:59 +01:00
|
|
|
if self.currentPage() is self.commit_page:
|
2017-12-10 21:14:14 +01:00
|
|
|
if self.backup_restore.canceled:
|
2017-12-10 22:11:07 +01:00
|
|
|
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
|
2014-09-17 23:06:41 +02:00
|
|
|
'<font color="red">{0}</font>'
|
2017-01-22 05:42:38 +01:00
|
|
|
.format(self.tr("Aborting the operation...")))
|
2014-03-08 03:58:59 +01:00
|
|
|
self.button(self.CancelButton).setDisabled(True)
|
|
|
|
else:
|
|
|
|
self.done(0)
|
2012-02-22 06:09:25 +01:00
|
|
|
|
|
|
|
def has_selected_dir(self):
|
2017-06-28 12:25:28 +02:00
|
|
|
backup_location = self.dir_line_edit.text()
|
2014-01-13 05:19:43 +01:00
|
|
|
if not backup_location:
|
|
|
|
return False
|
|
|
|
if self.appvm_combobox.currentIndex() == 0:
|
2014-01-11 22:57:34 +01:00
|
|
|
if os.path.isfile(backup_location) or \
|
|
|
|
os.path.isfile(os.path.join(backup_location, 'qubes.xml')):
|
|
|
|
return True
|
2014-01-13 05:19:43 +01:00
|
|
|
else:
|
2014-01-11 22:57:34 +01:00
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
2013-11-28 03:50:17 +01:00
|
|
|
|
2012-02-22 06:09:25 +01:00
|
|
|
def has_selected_vms(self):
|
|
|
|
return self.select_vms_widget.selected_list.count() > 0
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
def backup_location_changed(self, new_dir=None):
|
2017-12-11 00:50:40 +01:00
|
|
|
# pylint: disable=unused-argument
|
2017-12-10 22:11:07 +01:00
|
|
|
self.select_dir_page.emit(QtCore.SIGNAL("completeChanged()"))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2012-01-31 11:17:09 +01:00
|
|
|
|
|
|
|
# Bases on the original code by:
|
|
|
|
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
def handle_exception(exc_type, exc_value, exc_traceback):
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
|
|
|
|
filename = os.path.basename(filename)
|
|
|
|
error = "%s: %s" % (exc_type.__name__, exc_value)
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.critical(None, "Houston, we have a problem...",
|
2017-12-10 21:14:14 +01:00
|
|
|
"Whoops. A critical error has occured. "
|
|
|
|
"This is most likely a bug "
|
2012-01-31 11:17:09 +01:00
|
|
|
"in Qubes Restore VMs application.<br><br>"
|
|
|
|
"<b><i>%s</i></b>" % error +
|
|
|
|
"at <b>line %d</b> of file <b>%s</b>.<br/><br/>"
|
2017-12-10 22:11:07 +01:00
|
|
|
% (line, filename))
|
2012-01-31 11:17:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
qtapp = QtGui.QApplication(sys.argv)
|
2017-12-10 21:14:14 +01:00
|
|
|
qtapp.setOrganizationName("The Qubes Project")
|
|
|
|
qtapp.setOrganizationDomain("http://qubes-os.org")
|
|
|
|
qtapp.setApplicationName("Qubes Restore VMs")
|
2012-01-31 11:17:09 +01:00
|
|
|
|
|
|
|
sys.excepthook = handle_exception
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
app = Qubes()
|
2012-01-31 11:17:09 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
restore_window = RestoreVMsWindow(qtapp, app)
|
2012-01-31 11:17:09 +01:00
|
|
|
|
|
|
|
restore_window.show()
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
qtapp.exec_()
|
|
|
|
qtapp.exit()
|
2012-01-31 11:17:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|