2013-01-23 15:55:14 +01:00
|
|
|
#!/usr/bin/python2
|
2017-11-06 20:36:09 +01:00
|
|
|
# pylint: skip-file
|
2012-05-10 13:17:24 +02: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-05-10 13:17:24 +02:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
from PyQt4.QtCore import *
|
|
|
|
from PyQt4.QtGui import *
|
|
|
|
|
|
|
|
from qubes.qubes import QubesException
|
|
|
|
|
|
|
|
import qubesmanager.resources_rc
|
|
|
|
|
2017-06-28 12:25:28 +02:00
|
|
|
from .ui_logdlg import *
|
|
|
|
from .clipboard import *
|
2012-05-10 13:17:24 +02:00
|
|
|
|
2014-05-05 02:15:01 +02:00
|
|
|
# Display only this size of log
|
|
|
|
LOG_DISPLAY_SIZE = 1024*1024
|
2012-05-10 13:17:24 +02:00
|
|
|
|
|
|
|
class LogDialog(Ui_LogDialog, QDialog):
|
|
|
|
|
|
|
|
def __init__(self, app, log_path, parent=None):
|
|
|
|
super(LogDialog, self).__init__(parent)
|
|
|
|
|
|
|
|
self.app = app
|
|
|
|
self.log_path = log_path
|
|
|
|
|
|
|
|
self.setupUi(self)
|
|
|
|
self.setWindowTitle(log_path)
|
|
|
|
|
|
|
|
self.connect(self.copy_to_qubes_clipboard, SIGNAL("clicked()"), self.copy_to_qubes_clipboard_triggered)
|
|
|
|
|
|
|
|
self.__init_log_text__()
|
|
|
|
|
|
|
|
def __init_log_text__(self):
|
2014-05-05 02:15:01 +02:00
|
|
|
self.displayed_text = ""
|
2012-05-10 13:17:24 +02:00
|
|
|
log = open(self.log_path)
|
2014-05-05 02:15:01 +02:00
|
|
|
log.seek(0, os.SEEK_END)
|
|
|
|
if log.tell() > LOG_DISPLAY_SIZE:
|
2017-06-28 12:25:28 +02:00
|
|
|
self.displayed_text = self.tr("(Showing only last %d bytes of file)\n") % LOG_DISPLAY_SIZE
|
2014-05-05 02:15:01 +02:00
|
|
|
log.seek(-LOG_DISPLAY_SIZE, os.SEEK_END)
|
|
|
|
else:
|
|
|
|
log.seek(0, os.SEEK_SET)
|
|
|
|
self.displayed_text += log.read()
|
2012-05-10 13:17:24 +02:00
|
|
|
log.close()
|
2014-05-05 02:15:01 +02:00
|
|
|
self.log_text.setPlainText(self.displayed_text)
|
2012-05-10 13:17:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
def copy_to_qubes_clipboard_triggered(self):
|
2012-05-10 13:40:27 +02:00
|
|
|
copy_text_to_qubes_clipboard(self.displayed_text)
|