diff --git a/qubesmanager/log_dialog.py b/qubesmanager/log_dialog.py
index a5f07b9..979b069 100644
--- a/qubesmanager/log_dialog.py
+++ b/qubesmanager/log_dialog.py
@@ -20,13 +20,12 @@
#
#
import sys
+import os
+from functools import partial
from PyQt5 import QtWidgets # pylint: disable=import-error
-
+from qubesadmin import Qubes
from . import ui_logdlg # pylint: disable=no-name-in-module
from . import clipboard
-import os
-
-from qubesadmin import Qubes
# Display only this size of log
LOG_DISPLAY_SIZE = 1024*1024
@@ -35,14 +34,14 @@ LOG_DISPLAY_SIZE = 1024*1024
class LogDialog(ui_logdlg.Ui_LogDialog, QtWidgets.QDialog):
# pylint: disable=too-few-public-methods
- def __init__(self, app, log_path, parent=None):
+ def __init__(self, app, logfiles, parent=None):
super().__init__(parent)
self.app = app
- self.log_path = log_path
+ self.logfiles = logfiles
+ self.displayed_text = ""
self.setupUi(self)
- self.setWindowTitle(log_path)
self.copy_to_qubes_clipboard.clicked.connect(
self.copy_to_clipboard_triggered)
@@ -52,8 +51,24 @@ class LogDialog(ui_logdlg.Ui_LogDialog, QtWidgets.QDialog):
self.__init_log_text__()
def __init_log_text__(self):
+ btns_in_row = 3
+ count = 0
+ for log_path in self.logfiles:
+ button = QtWidgets.QPushButton(log_path)
+ button.clicked.connect(partial(self.set_current_log, log_path))
+ self.buttonsLayout.addWidget(button,
+ count / btns_in_row, count % btns_in_row)
+ count += 1
+
+ self.buttonsLayout.itemAt(0).widget().click()
+
+ def copy_to_clipboard_triggered(self):
+ clipboard.copy_text_to_qubes_clipboard(self.displayed_text)
+
+ def set_current_log(self, log_path):
self.displayed_text = ""
- log = open(self.log_path)
+ self.setWindowTitle(log_path)
+ log = open(log_path)
log.seek(0, os.SEEK_END)
if log.tell() > LOG_DISPLAY_SIZE:
self.displayed_text = self.tr(
@@ -64,11 +79,6 @@ class LogDialog(ui_logdlg.Ui_LogDialog, QtWidgets.QDialog):
self.displayed_text += log.read()
log.close()
self.log_text.setPlainText(self.displayed_text)
- self.log_text.show()
-
- def copy_to_clipboard_triggered(self):
- clipboard.copy_text_to_qubes_clipboard(self.displayed_text)
-
def main():
qubes_app = Qubes()
diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py
index cdf37fd..4b023d2 100644
--- a/qubesmanager/qube_manager.py
+++ b/qubesmanager/qube_manager.py
@@ -21,11 +21,10 @@
# with this program; if not, see .
#
#
-import os
-import os.path
import subprocess
from datetime import datetime, timedelta
from functools import partial
+from os import path
from qubesadmin import exc
from qubesadmin import utils
@@ -708,8 +707,8 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
lambda pos: self.open_tools_context_menu(self.toolbar, pos))
self.action_menubar.toggled.connect(self.showhide_menubar)
self.action_toolbar.toggled.connect(self.showhide_toolbar)
+ self.action_show_logs.triggered.connect(self.show_log)
self.action_compact_view.toggled.connect(self.set_compactview)
- self.logs_menu.triggered.connect(self.show_log)
self.table.resizeColumnsToContents()
@@ -895,8 +894,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
self.context_menu.addAction(self.action_clonevm)
self.context_menu.addAction(self.action_removevm)
self.context_menu.addSeparator()
- self.context_menu.addMenu(self.logs_menu)
- self.context_menu.addSeparator()
+ self.context_menu.addAction(self.action_show_logs)
def save_showing(self):
self.manager_settings.setValue('show/running',
@@ -1199,7 +1197,6 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
if not vm.updateable and vm.klass != 'AdminVM':
self.action_updatevm.setEnabled(False)
- self.update_logs_menu()
self.update_template_menu()
self.update_network_menu()
@@ -1650,48 +1647,42 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
def open_tools_context_menu(self, widget, point):
self.tools_context_menu.exec_(widget.mapToGlobal(point))
- def update_logs_menu(self):
- self.logs_menu.clear()
- menu_empty = True
-
- try:
- vm_info = self.get_selected_vms()
-
- if len(vm_info) == 1:
- vm = vm_info[0].vm
-
- if vm.klass == 'AdminVM':
- logfiles = ["/var/log/xen/console/hypervisor.log"]
- else:
- logfiles = [
- "/var/log/xen/console/guest-" + vm.name + ".log",
- "/var/log/xen/console/guest-" + vm.name + "-dm.log",
- "/var/log/qubes/guid." + vm.name + ".log",
- "/var/log/qubes/qrexec." + vm.name + ".log",
- ]
-
- for logfile in logfiles:
- if os.path.exists(logfile):
- action = self.logs_menu.addAction(QIcon(":/log.png"),
- logfile)
- action.setData(logfile)
- menu_empty = False
-
- self.logs_menu.setEnabled(not menu_empty)
- except exc.QubesDaemonAccessError:
- pass
-
@pyqtSlot('const QPoint&')
def open_context_menu(self, point):
self.context_menu.exec_(self.table.mapToGlobal(
point + QPoint(10, 0)))
- @pyqtSlot('QAction *')
- def show_log(self, action):
- log = str(action.data())
- log_dlg = log_dialog.LogDialog(self.qt_app, log)
- log_dlg.exec_()
+ def show_log(self):
+ logfiles = []
+ try:
+ for vm_info in self.get_selected_vms():
+ vm = vm_info.vm
+
+ if vm.klass == 'AdminVM':
+ logfiles.append("/var/log/xen/console/hypervisor.log")
+ else:
+ logfiles.extend([
+ "/var/log/xen/console/guest-" + vm.name + ".log",
+ "/var/log/xen/console/guest-" + vm.name + "-dm.log",
+ "/var/log/qubes/guid." + vm.name + ".log",
+ "/var/log/qubes/qrexec." + vm.name + ".log",
+ ])
+
+ logfiles = [x for x in logfiles if path.exists(x)]
+
+ if len(logfiles) > 0:
+ log_dlg = log_dialog.LogDialog(self.qt_app, logfiles)
+ log_dlg.exec_()
+ else:
+ QMessageBox.warning(
+ self,
+ self.tr("Error"),
+ self.tr(
+ "No log files where found for the current selection."))
+
+ except exc.QubesDaemonAccessError:
+ pass
def main():
manager_utils.run_asynchronous(VmManagerWindow)
diff --git a/ui/logdlg.ui b/ui/logdlg.ui
index 06976f5..b1e69cd 100644
--- a/ui/logdlg.ui
+++ b/ui/logdlg.ui
@@ -14,6 +14,9 @@
Dialog
+ -
+
+
-
diff --git a/ui/qubemanager.ui b/ui/qubemanager.ui
index 4162ee4..26cd341 100644
--- a/ui/qubemanager.ui
+++ b/ui/qubemanager.ui
@@ -350,15 +350,6 @@ Template
&Qube
-