Fixed opening file dialog at the end

Now, when "open file dialog to unmount" option is enabled, a fie dialog
actually opens.
This commit is contained in:
Marta Marczykowska-Górecka 2017-12-11 02:04:06 +01:00
parent a4a58cc527
commit 14ebf9dc6d
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
3 changed files with 35 additions and 48 deletions

View File

@ -25,7 +25,7 @@ import traceback
import signal
import shutil
from qubesadmin import Qubes, events, exc
from qubesadmin import Qubes, exc
from qubesadmin import utils as admin_utils
from qubes.storage.file import get_disk_usage
@ -326,16 +326,14 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
orig_text + self.tr(
" Please unmount your backup volume and cancel "
"the file selection dialog."))
if self.target_appvm: # FIXME I'm not sure if this works
self.target_appvm.run(
"QUBESRPC %s dom0" % "qubes.SelectDirectory")
backup_utils.select_path_button_clicked(self, False, True)
self.button(self.CancelButton).setEnabled(False)
self.button(self.FinishButton).setEnabled(True)
self.showFileDialog.setEnabled(False)
signal.signal(signal.SIGCHLD, old_sigchld_handler)
def reject(self):
# cancell clicked while the backup is in progress.
# cancel clicked while the backup is in progress.
# calling kill on tar.
if self.currentPage() is self.commit_page:
pass # TODO: this does nothing

View File

@ -51,7 +51,7 @@ def enable_dir_line_edit(dialog, boolean):
dialog.select_path_button.setEnabled(boolean)
def select_path_button_clicked(dialog, select_file=False):
def select_path_button_clicked(dialog, select_file=False, read_only=False):
backup_location = str(dialog.dir_line_edit.text())
file_dialog = QtGui.QFileDialog()
file_dialog.setReadOnly(True)
@ -66,15 +66,18 @@ def select_path_button_clicked(dialog, select_file=False):
"qubes.SelectFile" if select_file
else "qubes.SelectDirectory")
except subprocess.CalledProcessError:
QtGui.QMessageBox.warning(
None,
dialog.tr("Nothing selected!"),
dialog.tr("No file or directory selected."))
if not read_only:
QtGui.QMessageBox.warning(
None,
dialog.tr("Nothing selected!"),
dialog.tr("No file or directory selected."))
else:
return
if new_path:
if new_path and not read_only:
dialog.dir_line_edit.setText(new_path)
if new_path and backup_location:
if new_path and backup_location and not read_only:
dialog.select_dir_page.emit(QtCore.SIGNAL("completeChanged()"))

View File

@ -71,9 +71,6 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
self.connect(self,
QtCore.SIGNAL("currentIdChanged(int)"),
self.current_page_changed)
self.connect(self,
QtCore.SIGNAL("restore_progress(QString)"),
self.commit_text_edit.append)
self.dir_line_edit.connect(self.dir_line_edit,
QtCore.SIGNAL("textChanged(QString)"),
self.backup_location_changed)
@ -140,15 +137,15 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
except exc.QubesException as ex:
QtGui.QMessageBox.warning(None, self.tr("Restore error!"), str(ex))
def append_output(self, text):
self.commit_text_edit.append(text)
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(text)))
self.append_output(u'<font color="red">{0}</font>'.format(text))
def restore_output(self, text):
self.feedback_queue.put((
QtCore.SIGNAL("restore_progress(QString)"),
u'<font color="black">{0}</font>'.format(text)))
self.append_output(u'<font color="black">{0}</font>'.format(text))
def __do_restore__(self, t_monitor):
err_msg = []
@ -166,19 +163,16 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
"investigate them and/or clean them up"))
if self.canceled:
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
'<b><font color="red">{0}</font></b>'
.format(self.tr("Restore aborted!")))
self.append_output('<b><font color="red">{0}</font></b>'.format(
self.tr("Restore aborted!")))
elif err_msg or self.error_detected.is_set():
if 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!")))
self.append_output('<b><font color="red">{0}</font></b>'.format(
self.tr("Finished with errors!")))
else:
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
'<font color="green">{0}</font>'
.format(self.tr("Finished successfully!")))
self.append_output('<font color="green">{0}</font>'.format(
self.tr("Finished successfully!")))
t_monitor.set_finished()
@ -249,24 +243,17 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
self.tr("Backup error!"),
self.tr("ERROR: {0}").format(
self.thread_monitor.error_msg))
if self.showFileDialog.isChecked(): # TODO: this is not working
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
'<b><font color="black">{0}</font></b>'.format(
self.tr(
"Please unmount your backup volume and cancel"
" the file selection dialog.")))
if self.target_appvm: # TODO does this work at all?
self.target_appvm.run("QUBESRPC %s dom0" %
"qubes.SelectDirectory")
else:
file_dialog = QtGui.QFileDialog()
file_dialog.setReadOnly(True)
file_dialog.getExistingDirectory(
self, self.tr("Detach backup device"),
os.path.dirname(self.dir_line_edit.text()))
self.progress_bar.setMaximum(100)
self.progress_bar.setValue(100)
if self.showFileDialog.isChecked():
self.append_output(
'<b><font color="black">{0}</font></b>'.format(
self.tr("Please unmount your backup volume and cancel "
"the file selection dialog.")))
self.app.processEvents()
backup_utils.select_path_button_clicked(self, False, True)
self.button(self.FinishButton).setEnabled(True)
self.button(self.CancelButton).setEnabled(False)
self.showFileDialog.setEnabled(False)
@ -284,9 +271,8 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtGui.QWizard):
def reject(self): # TODO: probably not working too
if self.currentPage() is self.commit_page:
if self.backup_restore.canceled:
self.emit(QtCore.SIGNAL("restore_progress(QString)"),
'<font color="red">{0}</font>'
.format(self.tr("Aborting the operation...")))
self.append_output('<font color="red">{0}</font>'.format(
self.tr("Aborting the operation...")))
self.button(self.CancelButton).setDisabled(True)
else:
self.done(0)