mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-23 09:20:30 +00:00
Display log messages in progress dialog.
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3977 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
9adaadde4b
commit
ab5c841c9b
3 changed files with 38 additions and 19 deletions
1
TODO.txt
1
TODO.txt
|
|
@ -2,4 +2,3 @@
|
|||
columns result (as icon), URL, name; doubleclick opens property popup
|
||||
http://doc.trolltech.com/4.4/qtreewidget.html
|
||||
http://doc.trolltech.com/4.4/qtreewidgetitem.html
|
||||
- [GUI] Display log messages in text box.
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ class Configuration (dict):
|
|||
self["scanvirus"] = False
|
||||
self["clamavconf"] = clamav.canonical_clamav_conf()
|
||||
|
||||
def init_logging (self, status_logger, debug=None):
|
||||
def init_logging (self, status_logger, debug=None, handler=None):
|
||||
"""
|
||||
Load logging.conf file settings to set up the
|
||||
application logging (not to be confused with check loggers).
|
||||
|
|
@ -164,7 +164,8 @@ class Configuration (dict):
|
|||
filename = normpath(os.path.join(get_config_dir(), "logging.conf"))
|
||||
if os.path.isfile(filename):
|
||||
logging.config.fileConfig(filename)
|
||||
handler = ansicolor.ColoredStreamHandler(strm=sys.stderr)
|
||||
if handler is None:
|
||||
handler = ansicolor.ColoredStreamHandler(strm=sys.stderr)
|
||||
handler.setFormatter(logging.Formatter("%(levelname)s %(message)s"))
|
||||
logging.getLogger(LOG).addHandler(handler)
|
||||
self.set_debug(debug)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ class LinkCheckerMain (QtGui.QMainWindow, Ui_MainWindow):
|
|||
self.init_treewidget()
|
||||
self.read_settings()
|
||||
self.connect_widgets()
|
||||
self.init_config()
|
||||
self.status = Status.idle
|
||||
|
||||
def read_settings (self):
|
||||
|
|
@ -151,8 +152,8 @@ Version 2 or later.</p>
|
|||
self.controlButton.setEnabled(False)
|
||||
self.optionsButton.setEnabled(False)
|
||||
self.treeWidget.clear()
|
||||
config = self.get_config()
|
||||
aggregate = director.get_aggregate(config)
|
||||
self.set_config()
|
||||
aggregate = director.get_aggregate(self.config)
|
||||
url = unicode(self.urlinput.text()).strip()
|
||||
if not url:
|
||||
self.set_statusbar(_("Error, empty URL"))
|
||||
|
|
@ -165,7 +166,7 @@ Version 2 or later.</p>
|
|||
self.set_statusbar(_("Checking '%s'.") % strformat.limit(url, 40))
|
||||
url_data = checker.get_url_from(url, 0, aggregate)
|
||||
try:
|
||||
add_intern_pattern(url_data, config)
|
||||
add_intern_pattern(url_data, self.config)
|
||||
except UnicodeError:
|
||||
self.set_statusbar(_("Error, invalid URL '%s'.") %
|
||||
strformat.limit(url, 40))
|
||||
|
|
@ -178,18 +179,20 @@ Version 2 or later.</p>
|
|||
self.checker.check(self.aggregate, self.progress)
|
||||
self.status = Status.checking
|
||||
|
||||
def get_config (self):
|
||||
"""Return check configuration."""
|
||||
config = configuration.Configuration()
|
||||
config["recursionlevel"] = self.options.recursionlevel.value()
|
||||
config.logger_add("gui", GuiLogger)
|
||||
config["logger"] = config.logger_new('gui', widget=self.checker)
|
||||
config["verbose"] = self.options.verbose.isChecked()
|
||||
config["timeout"] = self.options.timeout.value()
|
||||
config["threads"] = self.options.threads.value()
|
||||
config.init_logging(StatusLogger(self.checker))
|
||||
config["status"] = True
|
||||
return config
|
||||
def init_config (self):
|
||||
self.config = configuration.Configuration()
|
||||
self.config.logger_add("gui", GuiLogger)
|
||||
self.config["logger"] = self.config.logger_new('gui', widget=self.checker)
|
||||
self.config["status"] = True
|
||||
handler = GuiLogHandler(self.checker)
|
||||
self.config.init_logging(StatusLogger(self.checker), handler=handler)
|
||||
|
||||
def set_config (self):
|
||||
"""Set configuration."""
|
||||
self.config["recursionlevel"] = self.options.recursionlevel.value()
|
||||
self.config["verbose"] = self.options.verbose.isChecked()
|
||||
self.config["timeout"] = self.options.timeout.value()
|
||||
self.config["threads"] = self.options.threads.value()
|
||||
|
||||
def log_url (self, url_data):
|
||||
"""Add URL data to tree widget."""
|
||||
|
|
@ -209,6 +212,23 @@ Version 2 or later.</p>
|
|||
self.statusBar.showMessage(msg)
|
||||
|
||||
|
||||
from logging import Handler
|
||||
|
||||
class GuiLogHandler (Handler, object):
|
||||
|
||||
def __init__ (self, widget):
|
||||
"""Log to given stream (a file-like object) or to stderr if
|
||||
strm is None.
|
||||
"""
|
||||
super(GuiLogHandler, self).__init__()
|
||||
self.widget = widget
|
||||
|
||||
def emit (self, record):
|
||||
"""Emit a record."""
|
||||
msg = self.format(record)
|
||||
self.widget.emit(QtCore.SIGNAL("status(QString)"), msg)
|
||||
|
||||
|
||||
class HelpWindow (QtGui.QDialog):
|
||||
"""A custom help display dialog."""
|
||||
|
||||
|
|
@ -344,7 +364,6 @@ class GuiLogger (Logger):
|
|||
def __init__ (self, **args):
|
||||
super(GuiLogger, self).__init__(**args)
|
||||
self.widget = args["widget"]
|
||||
self.end_output_called = False
|
||||
|
||||
def start_fileoutput (self):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue