Changeset 779:98a7abceb685 in hatta-dev


Ignore:
Timestamp:
07/16/10 19:44:20 (19 months ago)
Author:
Cezary Krzyżanowski <cezary.krzyzanowski@…>
Branch:
default
Message:

Added exception catching and reporting via e-mail. New ErrorDialog to display details and send updates. hatta.py errors go to Radomir, GUI related go to me.

Files:
4 added
1 edited

Legend:

Unmodified
Added
Removed
  • hatta_qticon.py

    r776 r779  
    1515from thread import start_new_thread 
    1616from time import sleep 
    17 from urllib import urlopen, unquote 
     17from traceback import format_exc 
     18from urllib import urlopen, quote 
    1819from wsgiref import simple_server 
    1920import gettext 
     
    3031    QMessageBox, QAction, QKeySequence, QWidget, QVBoxLayout, QGridLayout, 
    3132    QLabel, QSpinBox, QToolTip, QLineEdit, QHBoxLayout, QPushButton, 
    32     QFileDialog, QPixmap, QCheckBox, QDesktopServices) 
     33    QFileDialog, QPixmap, QCheckBox, QDesktopServices, QDialog) 
    3334from PyQt4.QtCore import (QString, QThread, pyqtSignal, pyqtSlot, Qt, 
    3435    QPoint, QLocale) 
    3536 
    3637from hatta import WikiConfig, Wiki, WikiRequest, project_name, project_url 
     38 
     39from error_dialog import ErrorDialog 
    3740 
    3841def we_are_frozen(): 
     
    8588        except Exception as e: 
    8689            self.exception_signal.emit(unicode(e)) 
     90            # It's very important to shut down the thread, so that the threaded  
     91            # werkzeug won't continue to run and send other exceptions. 
     92            self.quit() 
    8793 
    8894    def quit(self): 
     
    384390    pyqtSlot(str) 
    385391    def on_error(self, strerror): 
    386         """Displays errors from exceptions.""" 
    387         QMessageBox.critical(None, 'Exception', 
    388             _(u'Error: %(error_string)s') % 
    389                 dict(error_string=strerror), 1, 2) 
     392        """Displays error and send bug request.""" 
     393        report_bug('bugs@hatta-wiki.org', strerror) 
    390394 
    391395    def _make_discovery_action(self, name, host, port): 
     
    580584            bool(self.should_announce)) 
    581585 
     586 
     587error_dialog = None 
     588def report_bug(email, caption): 
     589    error_dialog.prepare_error(unicode(caption), format_exc()) 
     590    if error_dialog.exec_() == QDialog.Accepted: 
     591        link = 'mailto:%s?subject=%s&body=%s' % ( 
     592            email, 
     593            quote(u'[Bug] ' + unicode(caption)), 
     594            quote(error_dialog.get_bug_dump())) 
     595        webbrowser.open(link) 
     596    QApplication.exit() 
     597 
    582598if __name__ == '__main__': 
    583599    try: 
     
    594610        translation.install(unicode=1) 
    595611 
    596         app = QApplication(sys.argv) 
    597         QApplication.setQuitOnLastWindowClosed(False) 
    598         status_icon = HattaTrayIcon() 
    599         app.exec_() 
     612        try: 
     613            app = QApplication(sys.argv) 
     614            QApplication.setQuitOnLastWindowClosed(False) 
     615            error_dialog = ErrorDialog() 
     616            status_icon = HattaTrayIcon() 
     617            app.exec_() 
     618        except Exception as e: 
     619            report_bug('dhubleizh@o2.pl', unicode(e)) 
    600620    except KeyboardInterrupt: 
    601621        pass 
Note: See TracChangeset for help on using the changeset viewer.