forked from openlp/openlp
Bug report features for exception dialog
This commit is contained in:
parent
20b1c33a4b
commit
88ba36c9dd
@ -54,6 +54,13 @@ class AboutForm(QtGui.QDialog, Ui_AboutDialog):
|
|||||||
QtCore.QObject.connect(self.contributeButton,
|
QtCore.QObject.connect(self.contributeButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onContributeButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onContributeButtonClicked)
|
||||||
|
|
||||||
|
def reject(self):
|
||||||
|
"""
|
||||||
|
Raise a exception to test the exception handler.
|
||||||
|
"""
|
||||||
|
self.done(QtGui.QDialog.Rejected)
|
||||||
|
str(u'unvern\u00FCnftig')
|
||||||
|
|
||||||
def onContributeButtonClicked(self):
|
def onContributeButtonClicked(self):
|
||||||
"""
|
"""
|
||||||
Launch a web browser and go to the contribute page on the site.
|
Launch a web browser and go to the contribute page on the site.
|
||||||
|
@ -24,7 +24,12 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
import os
|
||||||
|
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
from openlp.core.lib import translate, build_icon, SettingsManager
|
||||||
|
from openlp.core.ui.mailto import mailto
|
||||||
|
|
||||||
from exceptiondialog import Ui_ExceptionDialog
|
from exceptiondialog import Ui_ExceptionDialog
|
||||||
|
|
||||||
@ -35,3 +40,82 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
self.settingsSection = u'crashreport'
|
||||||
|
#TODO: Icons
|
||||||
|
self.saveReportButton = QtGui.QPushButton(self)
|
||||||
|
self.saveReportButton.setIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||||
|
self.saveReportButton.setText(translate('OpenLP.ExceptionForm', 'Save Report to File'))
|
||||||
|
self.saveReportButton.setObjectName(u'saveReportButton')
|
||||||
|
self.sendReportButton = QtGui.QPushButton(self)
|
||||||
|
self.sendReportButton.setIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||||
|
self.sendReportButton.setText(translate('OpenLP.ExceptionForm', 'Send Report Mail'))
|
||||||
|
self.sendReportButton.setObjectName(u'sendReportButton')
|
||||||
|
self.exceptionButtonBox.addButton(self.saveReportButton,
|
||||||
|
QtGui.QDialogButtonBox.ActionRole)
|
||||||
|
self.exceptionButtonBox.addButton(self.sendReportButton,
|
||||||
|
QtGui.QDialogButtonBox.ActionRole)
|
||||||
|
QtCore.QObject.connect(self.saveReportButton,
|
||||||
|
QtCore.SIGNAL(u'pressed()'), self.onSaveReportButtonPressed)
|
||||||
|
QtCore.QObject.connect(self.sendReportButton,
|
||||||
|
QtCore.SIGNAL(u'pressed()'), self.onSendReportButtonPressed)
|
||||||
|
|
||||||
|
def _createReport(self):
|
||||||
|
system = unicode(translate('OpenLP.ExceptionForm',
|
||||||
|
'Operating System: %s\n'
|
||||||
|
'Desktop Envoirnment: %s'))
|
||||||
|
libraries = unicode(translate('OpenLP.ExceptionForm',
|
||||||
|
'Python: %s\n'
|
||||||
|
'PyQt: %s\n'
|
||||||
|
'SQLAlchemy: %s\n'
|
||||||
|
'lxml: %s\n'
|
||||||
|
'BeautifulSoup: %s\n'
|
||||||
|
'PyEnchant: %s\n'
|
||||||
|
'Chardet: %s\n'
|
||||||
|
'pysqlite: %s'))
|
||||||
|
#TODO: collect the informations
|
||||||
|
version = self.parent().applicationVersion[u'full']
|
||||||
|
return (version, system, libraries)
|
||||||
|
|
||||||
|
def onSaveReportButtonPressed(self):
|
||||||
|
"""
|
||||||
|
Saving exception log and system informations to a file.
|
||||||
|
"""
|
||||||
|
report = unicode(translate('OpenLP.ExceptionForm',
|
||||||
|
'*OpenLP Bug Report*\n'
|
||||||
|
'Version: %s\n'
|
||||||
|
'--- System information. ---\n%s\n'
|
||||||
|
'--- Library Versions ---\n%s\n'))
|
||||||
|
filename = QtGui.QFileDialog.getSaveFileName(self,
|
||||||
|
translate('OpenLP.ExceptionForm', 'Save Crash Report'),
|
||||||
|
SettingsManager.get_last_dir(self.settingsSection),
|
||||||
|
translate('OpenLP.ExceptionForm', 'Text files (*.log *.text *.txt)'))
|
||||||
|
if filename:
|
||||||
|
filename = unicode(QtCore.QDir.toNativeSeparators(filename))
|
||||||
|
SettingsManager.set_last_dir(self.settingsSection, os.path.dirname(
|
||||||
|
filename))
|
||||||
|
report = report % self._createReport()
|
||||||
|
try:
|
||||||
|
file = open(filename, u'w')
|
||||||
|
try:
|
||||||
|
file.write(report)
|
||||||
|
except UnicodeError:
|
||||||
|
file.close()
|
||||||
|
file = open(filename, u'wb')
|
||||||
|
file.write(report.encode(u'utf-8'))
|
||||||
|
file.close()
|
||||||
|
except IOError:
|
||||||
|
log.exception(u'Failed to write crash report')
|
||||||
|
|
||||||
|
def onSendReportButtonPressed(self):
|
||||||
|
"""
|
||||||
|
Opening systems default email client and inserting exception log and
|
||||||
|
system informations.
|
||||||
|
"""
|
||||||
|
email_body = unicode(translate('OpenLP.ExceptionForm',
|
||||||
|
'*OpenLP Bug Report*\n'
|
||||||
|
'Version: %s\n'
|
||||||
|
'--- Please enter the report below this line. ---\n\n\n'
|
||||||
|
'--- System information. ---\n%s\n'
|
||||||
|
'--- Library Versions ---\n%s\n'))
|
||||||
|
mailto(address=u'bugs@openlp.org', subject=u'OpenLP Bug Report',
|
||||||
|
body=email_body % self._createReport())
|
||||||
|
Loading…
Reference in New Issue
Block a user