Set GUI exception handler.

This commit is contained in:
Bastian Kleineidam 2011-03-21 11:36:31 +01:00
parent 48c3343e8b
commit 91bfcef252

View file

@ -19,10 +19,19 @@
Check HTML pages for broken links. This is the GUI client.
"""
import sys
from PyQt4.QtGui import QApplication, QStyleFactory
from PyQt4.QtGui import QApplication, QStyleFactory, QErrorMessage
from linkcheck.gui import LinkCheckerMain
from linkcheck import configuration, drop_privileges
def excepthook (etype, evalue, tb):
"""Catch unhandled exceptions."""
from cStringIO import StringIO
from PyQt4.QtCore import qWarning
from linkcheck.director.console import internal_error
out = StringIO()
internal_error(out=out, etype=etype, evalue=evalue, tb=tb)
qWarning(out.getvalue())
## Look and feel with stylesheets
# In Cleanlooks the progress bar text is outside the bar.
# Use Plastique instead.
@ -32,6 +41,7 @@ Style = "Plastique"
def main (argv=None):
if argv is None:
argv = sys.argv
sys.excepthook = excepthook
app = QApplication(argv)
app.setApplicationName(configuration.AppName)
app.setApplicationVersion(configuration.Version)
@ -45,6 +55,8 @@ def main (argv=None):
window = LinkCheckerMain(url=url)
window.show()
drop_privileges()
handler = QErrorMessage.qtHandler()
handler.setMinimumSize(600, 400)
sys.exit(app.exec_())