Skip to content

Commit

Permalink
Merge remote-tracking branch 'qubesos/pr/76'
Browse files Browse the repository at this point in the history
* qubesos/pr/76:
  Fixed a bunch of useless asserts
  • Loading branch information
marmarek committed Mar 14, 2018
2 parents b0ebb76 + fcaca57 commit feeedb5
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions qubesmanager/qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,6 @@ def action_startvm_tools_install_triggered(self):
@QtCore.pyqtSlot(name='on_action_pausevm_triggered')
def action_pausevm_triggered(self):
vm = self.get_selected_vm()
assert vm.is_running()
try:
vm.pause()
self.update_single_row(vm)
Expand All @@ -769,7 +768,6 @@ def action_pausevm_triggered(self):
@QtCore.pyqtSlot(name='on_action_shutdownvm_triggered')
def action_shutdownvm_triggered(self):
vm = self.get_selected_vm()
assert vm.is_running()

reply = QtGui.QMessageBox.question(
None, self.tr("Qube Shutdown Confirmation"),
Expand Down Expand Up @@ -807,7 +805,6 @@ def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout,
@QtCore.pyqtSlot(name='on_action_restartvm_triggered')
def action_restartvm_triggered(self):
vm = self.get_selected_vm()
assert vm.is_running()

reply = QtGui.QMessageBox.question(
None, self.tr("Qube Restart Confirmation"),
Expand All @@ -819,22 +816,32 @@ def action_restartvm_triggered(self):
self.qt_app.processEvents()

if reply == QtGui.QMessageBox.Yes:
self.shutdown_vm(vm, and_restart=True)
# in case the user shut down the VM in the meantime
if vm.is_running():
self.shutdown_vm(vm, and_restart=True)
else:
self.start_vm(vm)

self.update_single_row(vm)

# noinspection PyArgumentList
@QtCore.pyqtSlot(name='on_action_killvm_triggered')
def action_killvm_triggered(self):
vm = self.get_selected_vm()
assert vm.is_running() or vm.is_paused()
if not (vm.is_running() or vm.is_paused()):
info = self.tr("Qube <b>'{0}'</b> is not running. Are you "
"absolutely sure you want to try to kill it?<br>"
"<small>This will end <b>(not shutdown!)</b> all "
"the running applications within this "
"Qube.</small>").format(vm.name)
else:
info = self.tr("Are you sure you want to kill the Qube "
"<b>'{0}'</b>?<br><small>This will end <b>(not "
"shutdown!)</b> all the running applications within "
"this Qube.</small>").format(vm.name)

reply = QtGui.QMessageBox.question(
None, self.tr("Qube Kill Confirmation"),
self.tr("Are you sure you want to kill the Qube <b>'{0}'</b>?<br>"
"<small>This will end <b>(not shutdown!)</b> all the "
"running applications within this Qube.</small>").format(
vm.name),
None, self.tr("Qube Kill Confirmation"), info,
QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel,
QtGui.QMessageBox.Cancel)

Expand Down

0 comments on commit feeedb5

Please sign in to comment.