2017-12-10 21:14:14 +01:00
|
|
|
#!/usr/bin/python3
|
2012-01-31 14:29:13 +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 14:29:13 +01:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
import traceback
|
|
|
|
|
2012-04-11 18:47:43 +02:00
|
|
|
import signal
|
2014-03-08 03:58:59 +01:00
|
|
|
import shutil
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-11 02:04:06 +01:00
|
|
|
from qubesadmin import Qubes, exc
|
2017-12-10 21:14:14 +01:00
|
|
|
from qubesadmin import utils as admin_utils
|
|
|
|
from qubes.storage.file import get_disk_usage
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
from PyQt4 import QtCore # pylint: disable=import-error
|
2017-12-10 22:11:07 +01:00
|
|
|
from PyQt4 import QtGui # pylint: disable=import-error
|
2017-12-11 01:09:29 +01:00
|
|
|
from . import ui_backupdlg # pylint: disable=no-name-in-module
|
2017-12-10 22:11:07 +01:00
|
|
|
from . import multiselectwidget
|
2012-02-20 07:56:38 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
from . import backup_utils
|
2017-12-10 21:14:14 +01:00
|
|
|
from . import utils
|
|
|
|
import grp
|
|
|
|
import pwd
|
|
|
|
import sys
|
|
|
|
import os
|
2017-12-10 22:11:07 +01:00
|
|
|
from . import thread_monitor
|
|
|
|
import threading
|
2017-12-10 21:14:14 +01:00
|
|
|
import time
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
|
|
|
|
class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
def __init__(self, app, qvm_collection, parent=None):
|
2012-01-31 14:29:13 +01:00
|
|
|
super(BackupVMsWindow, self).__init__(parent)
|
|
|
|
|
2012-02-20 07:56:38 +01:00
|
|
|
self.app = app
|
|
|
|
self.qvm_collection = qvm_collection
|
2017-12-10 21:14:14 +01:00
|
|
|
self.backup_settings = QtCore.QSettings()
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2013-11-28 03:50:17 +01:00
|
|
|
self.selected_vms = []
|
2014-03-08 03:58:59 +01:00
|
|
|
self.tmpdir_to_remove = None
|
|
|
|
self.canceled = False
|
2017-12-11 00:50:40 +01:00
|
|
|
self.thread_monitor = None
|
2013-11-28 03:45:22 +01:00
|
|
|
|
2012-02-20 07:56:38 +01:00
|
|
|
self.setupUi(self)
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-01-22 05:42:38 +01:00
|
|
|
self.progress_status.text = self.tr("Backup in progress...")
|
2013-09-28 12:33:56 +02:00
|
|
|
self.dir_line_edit.setReadOnly(False)
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
self.select_vms_widget = multiselectwidget.MultiSelectWidget(self)
|
2012-02-20 07:56:38 +01:00
|
|
|
self.verticalLayout.insertWidget(1, self.select_vms_widget)
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
self.connect(self, QtCore.SIGNAL("currentIdChanged(int)"),
|
2017-12-10 21:14:14 +01:00
|
|
|
self.current_page_changed)
|
|
|
|
self.connect(self.select_vms_widget,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("items_removed(PyQt_PyObject)"),
|
2017-12-10 21:14:14 +01:00
|
|
|
self.vms_removed)
|
|
|
|
self.connect(self.select_vms_widget,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("items_added(PyQt_PyObject)"),
|
2017-12-10 21:14:14 +01:00
|
|
|
self.vms_added)
|
|
|
|
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)
|
2012-02-20 07:56:38 +01:00
|
|
|
|
|
|
|
self.select_vms_page.isComplete = self.has_selected_vms
|
2013-11-28 03:52:02 +01:00
|
|
|
self.select_dir_page.isComplete = self.has_selected_dir_and_pass
|
2017-12-10 21:14:14 +01:00
|
|
|
# FIXME
|
|
|
|
# this causes to run isComplete() twice, I don't know why
|
2013-11-28 03:52:02 +01:00
|
|
|
self.select_vms_page.connect(
|
|
|
|
self.select_vms_widget,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("selected_changed()"),
|
|
|
|
QtCore.SIGNAL("completeChanged()"))
|
2013-11-28 03:52:02 +01:00
|
|
|
self.passphrase_line_edit.connect(
|
|
|
|
self.passphrase_line_edit,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("textChanged(QString)"),
|
2013-11-28 03:52:02 +01:00
|
|
|
self.backup_location_changed)
|
|
|
|
self.passphrase_line_edit_verify.connect(
|
|
|
|
self.passphrase_line_edit_verify,
|
2017-12-10 22:11:07 +01:00
|
|
|
QtCore.SIGNAL("textChanged(QString)"),
|
2013-11-28 03:52:02 +01:00
|
|
|
self.backup_location_changed)
|
|
|
|
|
2012-04-04 01:40:13 +02:00
|
|
|
self.total_size = 0
|
2012-02-20 07:56:38 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
self.target_vm_list, self.target_vm_idx = utils.prepare_vm_choice(
|
|
|
|
self.appvm_combobox,
|
|
|
|
self.qvm_collection,
|
|
|
|
None,
|
|
|
|
self.qvm_collection.domains['dom0'],
|
|
|
|
(lambda vm: vm.klass != 'TemplateVM' and vm.is_running()),
|
|
|
|
allow_internal=False,
|
|
|
|
allow_default=False,
|
|
|
|
allow_none=False
|
|
|
|
)
|
|
|
|
|
|
|
|
selected = self.load_settings()
|
|
|
|
self.__fill_vms_list__(selected)
|
2014-03-31 05:23:07 +02:00
|
|
|
|
|
|
|
def load_settings(self):
|
2017-12-10 21:14:14 +01:00
|
|
|
try:
|
2017-12-10 22:11:07 +01:00
|
|
|
profile_data = backup_utils.load_backup_profile()
|
2017-12-11 01:09:29 +01:00
|
|
|
except FileNotFoundError:
|
2017-12-11 00:50:40 +01:00
|
|
|
return
|
2017-12-11 01:09:29 +01:00
|
|
|
except exc.QubesException:
|
2017-12-11 00:50:40 +01:00
|
|
|
QtGui.QMessageBox.information(
|
|
|
|
None, self.tr("Error loading backup profile"),
|
|
|
|
self.tr("Unable to load saved backup profile."))
|
2017-12-10 21:14:14 +01:00
|
|
|
return
|
|
|
|
if not profile_data:
|
|
|
|
return
|
|
|
|
|
|
|
|
if 'destination_vm' in profile_data:
|
|
|
|
dest_vm_name = profile_data['destination_vm']
|
|
|
|
dest_vm_idx = self.appvm_combobox.findText(dest_vm_name)
|
|
|
|
if dest_vm_idx > -1:
|
|
|
|
self.appvm_combobox.setCurrentIndex(dest_vm_idx)
|
|
|
|
|
|
|
|
if 'destination_path' in profile_data:
|
|
|
|
dest_path = profile_data['destination_path']
|
|
|
|
self.dir_line_edit.setText(dest_path)
|
|
|
|
|
|
|
|
if 'passphrase_text' in profile_data:
|
|
|
|
self.passphrase_line_edit.setText(profile_data['passphrase_text'])
|
|
|
|
self.passphrase_line_edit_verify.setText(
|
|
|
|
profile_data['passphrase_text'])
|
|
|
|
|
|
|
|
if 'include' in profile_data:
|
|
|
|
return profile_data['include']
|
|
|
|
|
|
|
|
return None
|
2014-03-31 05:23:07 +02:00
|
|
|
|
2017-12-10 23:17:39 +01:00
|
|
|
def save_settings(self, use_temp):
|
2017-12-10 21:14:14 +01:00
|
|
|
settings = {'destination_vm': self.appvm_combobox.currentText(),
|
|
|
|
'destination_path': self.dir_line_edit.text(),
|
|
|
|
'include': [vm.name for vm in self.selected_vms],
|
|
|
|
'passphrase_text': self.passphrase_line_edit.text()}
|
|
|
|
# TODO: add compression when it is added
|
2017-12-10 23:17:39 +01:00
|
|
|
|
|
|
|
backup_utils.write_backup_profile(settings, use_temp)
|
2012-03-29 23:26:16 +02:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
class VmListItem(QtGui.QListWidgetItem):
|
2017-12-11 00:50:40 +01:00
|
|
|
# pylint: disable=too-few-public-methods
|
2012-03-29 23:26:16 +02:00
|
|
|
def __init__(self, vm):
|
|
|
|
self.vm = vm
|
2012-04-04 01:40:13 +02:00
|
|
|
if vm.qid == 0:
|
|
|
|
local_user = grp.getgrnam('qubes').gr_mem[0]
|
|
|
|
home_dir = pwd.getpwnam(local_user).pw_dir
|
2017-12-10 21:14:14 +01:00
|
|
|
self.size = get_disk_usage(home_dir)
|
2012-04-04 01:40:13 +02:00
|
|
|
else:
|
2017-12-10 21:14:14 +01:00
|
|
|
self.size = vm.get_disk_utilization()
|
|
|
|
super(BackupVMsWindow.VmListItem, self).__init__(
|
|
|
|
vm.name + " (" + admin_utils.size_to_human(self.size) + ")")
|
2012-04-04 01:40:13 +02:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
def __fill_vms_list__(self, selected=None):
|
|
|
|
for vm in self.qvm_collection.domains:
|
|
|
|
if vm.features.get('internal', False):
|
2012-02-20 07:56:38 +01:00
|
|
|
continue
|
|
|
|
|
2012-03-29 23:26:16 +02:00
|
|
|
item = BackupVMsWindow.VmListItem(vm)
|
2017-12-10 21:14:14 +01:00
|
|
|
if (selected is None and
|
|
|
|
getattr(vm, 'include_in_backups', True)) \
|
|
|
|
or (selected and vm.name in selected):
|
2012-03-29 23:26:16 +02:00
|
|
|
self.select_vms_widget.selected_list.addItem(item)
|
2012-04-04 01:40:13 +02:00
|
|
|
self.total_size += item.size
|
2012-03-29 23:26:16 +02:00
|
|
|
else:
|
|
|
|
self.select_vms_widget.available_list.addItem(item)
|
2017-01-05 03:58:03 +01:00
|
|
|
self.select_vms_widget.available_list.sortItems()
|
|
|
|
self.select_vms_widget.selected_list.sortItems()
|
2017-12-10 21:14:14 +01:00
|
|
|
|
|
|
|
self.unrecognized_config_label.setVisible(
|
|
|
|
selected is not None and
|
|
|
|
len(selected) != len(self.select_vms_widget.selected_list))
|
|
|
|
self.total_size_label.setText(
|
|
|
|
admin_utils.size_to_human(self.total_size))
|
2012-04-04 01:40:13 +02:00
|
|
|
|
|
|
|
def vms_added(self, items):
|
|
|
|
for i in items:
|
|
|
|
self.total_size += i.size
|
2017-12-10 21:14:14 +01:00
|
|
|
self.total_size_label.setText(
|
|
|
|
admin_utils.size_to_human(self.total_size))
|
2012-04-04 01:40:13 +02:00
|
|
|
|
|
|
|
def vms_removed(self, items):
|
|
|
|
for i in items:
|
|
|
|
self.total_size -= i.size
|
2017-12-10 21:14:14 +01:00
|
|
|
self.total_size_label.setText(
|
|
|
|
admin_utils.size_to_human(self.total_size))
|
2012-05-13 16:56:27 +02:00
|
|
|
|
2017-12-10 22:11:07 +01:00
|
|
|
@QtCore.pyqtSlot(name='on_select_path_button_clicked')
|
2012-02-20 07:56:38 +01:00
|
|
|
def select_path_button_clicked(self):
|
2017-12-10 22:11:07 +01:00
|
|
|
backup_utils.select_path_button_clicked(self)
|
2012-02-20 07:56:38 +01:00
|
|
|
|
|
|
|
def validateCurrentPage(self):
|
2017-12-11 00:50:40 +01:00
|
|
|
# pylint: disable=invalid-name
|
2012-02-20 07:56:38 +01:00
|
|
|
if self.currentPage() is self.select_vms_page:
|
2013-11-28 03:50:17 +01:00
|
|
|
|
|
|
|
self.selected_vms = []
|
2012-03-29 23:26:16 +02:00
|
|
|
for i in range(self.select_vms_widget.selected_list.count()):
|
2017-12-10 21:14:14 +01:00
|
|
|
self.selected_vms.append(
|
|
|
|
self.select_vms_widget.selected_list.item(i).vm)
|
2013-11-28 03:50:17 +01:00
|
|
|
|
2013-11-28 04:07:39 +01:00
|
|
|
elif self.currentPage() is self.select_dir_page:
|
2014-01-11 22:57:34 +01:00
|
|
|
backup_location = str(self.dir_line_edit.text())
|
|
|
|
if not backup_location:
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.information(
|
2017-12-10 21:14:14 +01:00
|
|
|
None, self.tr("Wait!"),
|
2017-01-22 05:42:38 +01:00
|
|
|
self.tr("Enter backup target location first."))
|
2013-11-28 04:07:39 +01:00
|
|
|
return False
|
2017-12-10 21:14:14 +01:00
|
|
|
if self.appvm_combobox.currentIndex() == 0 \
|
|
|
|
and not os.path.isdir(backup_location):
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.information(
|
2017-12-10 21:14:14 +01:00
|
|
|
None, self.tr("Wait!"),
|
2017-06-28 12:25:28 +02:00
|
|
|
self.tr("Selected directory do not exists or "
|
|
|
|
"not a directory (%s).") % backup_location)
|
2013-11-28 04:07:39 +01:00
|
|
|
return False
|
2017-12-11 01:09:29 +01:00
|
|
|
if not self.passphrase_line_edit.text():
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.information(
|
2017-12-10 21:14:14 +01:00
|
|
|
None, self.tr("Wait!"),
|
|
|
|
self.tr("Enter passphrase for backup "
|
|
|
|
"encryption/verification first."))
|
2013-11-28 04:07:39 +01:00
|
|
|
return False
|
2017-12-10 21:14:14 +01:00
|
|
|
if self.passphrase_line_edit.text() !=\
|
|
|
|
self.passphrase_line_edit_verify.text():
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.information(
|
2017-12-10 21:14:14 +01:00
|
|
|
None, self.tr("Wait!"),
|
2017-01-22 05:42:38 +01:00
|
|
|
self.tr("Enter the same passphrase in both fields."))
|
2013-11-28 04:07:39 +01:00
|
|
|
return False
|
|
|
|
|
2012-02-20 07:56:38 +01:00
|
|
|
return True
|
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
def __do_backup__(self, t_monitor):
|
2012-02-20 07:56:38 +01:00
|
|
|
msg = []
|
2013-09-28 12:33:56 +02:00
|
|
|
|
2012-02-20 07:56:38 +01:00
|
|
|
try:
|
2017-12-11 00:50:40 +01:00
|
|
|
vm = self.qvm_collection.domains[
|
|
|
|
self.appvm_combobox.currentText()]
|
|
|
|
if not vm.is_running():
|
|
|
|
vm.start()
|
|
|
|
self.qvm_collection.qubesd_call(
|
|
|
|
'dom0', 'admin.backup.Execute',
|
|
|
|
backup_utils.get_profile_name(True))
|
|
|
|
except Exception as ex: # pylint: disable=broad-except
|
2012-02-20 07:56:38 +01:00
|
|
|
msg.append(str(ex))
|
|
|
|
|
2017-12-11 01:09:29 +01:00
|
|
|
if msg:
|
2017-12-11 00:50:40 +01:00
|
|
|
t_monitor.set_error_msg('\n'.join(msg))
|
2012-02-20 07:56:38 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
t_monitor.set_finished()
|
2012-02-20 07:56:38 +01:00
|
|
|
|
2013-11-28 03:45:22 +01:00
|
|
|
|
2017-12-11 00:50:40 +01:00
|
|
|
def current_page_changed(self, page_id): # pylint: disable=unused-argument
|
2014-01-15 06:00:02 +01:00
|
|
|
old_sigchld_handler = signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
2012-02-20 07:56:38 +01:00
|
|
|
if self.currentPage() is self.confirm_page:
|
2013-09-28 12:33:56 +02:00
|
|
|
|
2017-12-10 23:17:39 +01:00
|
|
|
self.save_settings(True)
|
2017-12-10 21:14:14 +01:00
|
|
|
backup_summary = self.qvm_collection.qubesd_call(
|
2017-12-10 23:17:39 +01:00
|
|
|
'dom0', 'admin.backup.Info',
|
|
|
|
backup_utils.get_profile_name(True))
|
2012-02-22 06:09:25 +01:00
|
|
|
|
2012-02-20 07:56:38 +01:00
|
|
|
self.textEdit.setReadOnly(True)
|
|
|
|
self.textEdit.setFontFamily("Monospace")
|
2017-12-10 21:14:14 +01:00
|
|
|
self.textEdit.setText(backup_summary.decode())
|
2012-02-20 07:56:38 +01:00
|
|
|
|
|
|
|
elif self.currentPage() is self.commit_page:
|
2017-12-10 23:17:39 +01:00
|
|
|
|
|
|
|
if self.save_profile_checkbox.isChecked():
|
|
|
|
self.save_settings(False)
|
|
|
|
|
2012-02-20 07:56:38 +01:00
|
|
|
self.button(self.FinishButton).setDisabled(True)
|
2014-05-15 03:06:51 +02:00
|
|
|
self.showFileDialog.setEnabled(
|
|
|
|
self.appvm_combobox.currentIndex() != 0)
|
|
|
|
self.showFileDialog.setChecked(self.showFileDialog.isEnabled()
|
|
|
|
and str(self.dir_line_edit.text())
|
|
|
|
.count("media/") > 0)
|
2017-12-10 22:11:07 +01:00
|
|
|
self.thread_monitor = thread_monitor.ThreadMonitor()
|
|
|
|
thread = threading.Thread(
|
|
|
|
target=self.__do_backup__,
|
|
|
|
args=(self.thread_monitor,))
|
2012-02-20 07:56:38 +01:00
|
|
|
thread.daemon = True
|
|
|
|
thread.start()
|
|
|
|
|
|
|
|
while not self.thread_monitor.is_finished():
|
|
|
|
self.app.processEvents()
|
2017-12-10 21:14:14 +01:00
|
|
|
time.sleep(0.1)
|
2012-02-20 07:56:38 +01:00
|
|
|
|
|
|
|
if not self.thread_monitor.success:
|
2014-03-08 03:58:59 +01:00
|
|
|
if self.canceled:
|
2017-01-22 05:42:38 +01:00
|
|
|
self.progress_status.setText(self.tr("Backup aborted."))
|
2014-03-08 03:58:59 +01:00
|
|
|
if self.tmpdir_to_remove:
|
2017-12-10 22:11:07 +01:00
|
|
|
if QtGui.QMessageBox.warning(
|
2017-12-10 21:14:14 +01:00
|
|
|
None, self.tr("Backup aborted"),
|
|
|
|
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-01-22 05:42:38 +01:00
|
|
|
self.progress_status.setText(self.tr("Backup error."))
|
2017-12-10 22:11:07 +01:00
|
|
|
QtGui.QMessageBox.warning(
|
2017-12-10 21:14:14 +01:00
|
|
|
self, self.tr("Backup error!"),
|
2017-06-28 12:25:28 +02:00
|
|
|
self.tr("ERROR: {}").format(
|
2017-12-10 21:14:14 +01:00
|
|
|
self.thread_monitor.error_msg))
|
2013-11-28 04:07:39 +01:00
|
|
|
else:
|
2017-12-11 01:32:26 +01:00
|
|
|
self.progress_bar.setMaximum(100)
|
2013-11-28 04:07:39 +01:00
|
|
|
self.progress_bar.setValue(100)
|
2017-01-22 05:42:38 +01:00
|
|
|
self.progress_status.setText(self.tr("Backup finished."))
|
2015-03-31 05:40:53 +02:00
|
|
|
if self.showFileDialog.isChecked():
|
2014-05-15 03:06:51 +02:00
|
|
|
orig_text = self.progress_status.text
|
|
|
|
self.progress_status.setText(
|
2017-01-22 05:42:38 +01:00
|
|
|
orig_text + self.tr(
|
|
|
|
" Please unmount your backup volume and cancel "
|
|
|
|
"the file selection dialog."))
|
2017-12-11 02:04:06 +01:00
|
|
|
backup_utils.select_path_button_clicked(self, False, True)
|
2014-03-08 03:58:59 +01:00
|
|
|
self.button(self.CancelButton).setEnabled(False)
|
2012-02-20 07:56:38 +01:00
|
|
|
self.button(self.FinishButton).setEnabled(True)
|
2014-05-15 03:06:51 +02:00
|
|
|
self.showFileDialog.setEnabled(False)
|
2014-01-15 06:00:02 +01:00
|
|
|
signal.signal(signal.SIGCHLD, old_sigchld_handler)
|
2012-03-02 02:50:12 +01:00
|
|
|
|
|
|
|
def reject(self):
|
2017-12-11 02:04:06 +01:00
|
|
|
# cancel clicked while the backup is in progress.
|
2017-12-10 21:14:14 +01:00
|
|
|
# calling kill on tar.
|
2012-04-11 18:47:43 +02:00
|
|
|
if self.currentPage() is self.commit_page:
|
2017-12-10 21:14:14 +01:00
|
|
|
pass # TODO: this does nothing
|
|
|
|
# if backup.backup_cancel():
|
|
|
|
# self.button(self.CancelButton).setDisabled(True)
|
2014-03-08 03:58:59 +01:00
|
|
|
else:
|
|
|
|
self.done(0)
|
2012-03-02 02:50:12 +01:00
|
|
|
|
2012-02-20 07:56:38 +01:00
|
|
|
def has_selected_vms(self):
|
|
|
|
return self.select_vms_widget.selected_list.count() > 0
|
|
|
|
|
2013-11-28 03:52:02 +01:00
|
|
|
def has_selected_dir_and_pass(self):
|
2017-12-11 01:09:29 +01:00
|
|
|
if not self.passphrase_line_edit.text():
|
2013-11-28 03:52:02 +01:00
|
|
|
return False
|
2017-12-10 21:14:14 +01:00
|
|
|
if self.passphrase_line_edit.text() != \
|
|
|
|
self.passphrase_line_edit_verify.text():
|
2013-11-28 03:52:02 +01:00
|
|
|
return False
|
2014-01-11 22:57:34 +01:00
|
|
|
return len(self.dir_line_edit.text()) > 0
|
2012-01-31 14:29:13 +01:00
|
|
|
|
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-20 07:56:38 +01:00
|
|
|
|
|
|
|
|
2012-01-31 14:29:13 +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):
|
|
|
|
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 14:29:13 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
QtGui.QMessageBox.critical(
|
|
|
|
None,
|
|
|
|
"Houston, we have a problem...",
|
|
|
|
"Whoops. A critical error has occured. This is most likely a bug "
|
|
|
|
"in Qubes Global Settings application.<br><br><b><i>%s</i></b>" %
|
|
|
|
error + "at <b>line %d</b> of file <b>%s</b>.<br/><br/>"
|
|
|
|
% (line, filename))
|
2012-01-31 14:29:13 +01:00
|
|
|
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
def main():
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
qtapp = QtGui.QApplication(sys.argv)
|
|
|
|
qtapp.setOrganizationName("The Qubes Project")
|
|
|
|
qtapp.setOrganizationDomain("http://qubes-os.org")
|
|
|
|
qtapp.setApplicationName("Qubes Backup VMs")
|
2012-01-31 14:29:13 +01:00
|
|
|
|
|
|
|
sys.excepthook = handle_exception
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
app = Qubes()
|
2012-01-31 14:29:13 +01:00
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
backup_window = BackupVMsWindow(qtapp, app)
|
2012-01-31 14:29:13 +01:00
|
|
|
|
|
|
|
backup_window.show()
|
|
|
|
|
2017-12-10 21:14:14 +01:00
|
|
|
qtapp.exec_()
|
|
|
|
qtapp.exit()
|
2012-01-31 14:29:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2017-12-10 21:14:14 +01:00
|
|
|
main()
|