Error reporting dialog can (finally) upload error reports to Pastebin.
This commit is contained in:
parent
e11787a4fa
commit
39a113dab9
@ -8,3 +8,4 @@ pygments
|
||||
pyzmq
|
||||
numpy>=1.9.0, <1.10.0
|
||||
arrow
|
||||
pastebin
|
||||
|
@ -7,26 +7,31 @@ import traceback
|
||||
import sys
|
||||
import platform
|
||||
|
||||
from PySide import QtGui
|
||||
from PySide import QtGui, QtCore
|
||||
from mcedit2.util import qglcontext
|
||||
|
||||
from mcedit2.util.load_ui import load_ui
|
||||
from mcedit2.util.screen import centerWidgetInScreen
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def showErrorDialog(text, tb, fatal):
|
||||
dialog = ErrorDialog(text, tb, fatal)
|
||||
dialog.exec_()
|
||||
|
||||
|
||||
class ErrorDialog(QtGui.QDialog):
|
||||
"""
|
||||
A dialog for displaying an error traceback when something goes wrong.
|
||||
|
||||
Used to report compile and run errors for plugin modules and classes, and might be
|
||||
used to report errors in MCEdit itself during signal or event handlers.
|
||||
Used to report compile and run errors for plugin modules and classes, and
|
||||
to report errors in MCEdit itself during signal or event handlers.
|
||||
"""
|
||||
def __init__(self, text, exc_info, fatal):
|
||||
super(ErrorDialog, self).__init__()
|
||||
self.setModal(True)
|
||||
|
||||
load_ui("error_dialog.ui", baseinstance=self)
|
||||
|
||||
exc_type, exc_value, exc_tb = exc_info
|
||||
@ -49,7 +54,52 @@ class ErrorDialog(QtGui.QDialog):
|
||||
"%s" % (__version__, sys.version, sys.platform,
|
||||
platform.platform(), platform.processor(),
|
||||
contextInfo, text, tbText)
|
||||
self.errorText = tbText
|
||||
|
||||
self.tracebackView.setText(tbText)
|
||||
|
||||
self.restartMCEditLabel.setVisible(fatal)
|
||||
self.restartMCEditButton.setVisible(False)
|
||||
self.restartMCEditButton.setEnabled(False) # xxxx connect me
|
||||
try:
|
||||
import Pastebin
|
||||
except ImportError:
|
||||
self.copyToPastebinButton.setVisible(False)
|
||||
else:
|
||||
self.copyToPastebinButton.setVisible(True)
|
||||
self.copyToPastebinButton.clicked.connect(self.copyToPastebin)
|
||||
|
||||
self.pastebinURLBox.setVisible(False)
|
||||
|
||||
def show(self, *args, **kwargs):
|
||||
super(ErrorDialog, self).show(*args, **kwargs)
|
||||
centerWidgetInScreen(self)
|
||||
|
||||
def copyToPastebin(self):
|
||||
import Pastebin
|
||||
api_dev_key = '0a9ae46e71b44c10184212e4674912c5'
|
||||
url = None
|
||||
|
||||
progressText = self.tr("Uploading to pastebin...")
|
||||
dialog = QtGui.QProgressDialog(progressText,
|
||||
None, 0, 0, self)
|
||||
dialog.setLabelText(progressText)
|
||||
dialog.setWindowTitle(progressText)
|
||||
dialog.setStatusTip(progressText)
|
||||
|
||||
dialog.show()
|
||||
QtGui.qApp.processEvents()
|
||||
try:
|
||||
url = Pastebin.paste(api_dev_key, self.errorText,
|
||||
paste_expire_date="1M")
|
||||
except Exception as e:
|
||||
log.warn("Failed to upload to pastebin!", exc_info=1)
|
||||
self.copyToPastebinLabel.setText(self.tr("Failed to upload to pastebin: ") + str(e))
|
||||
finally:
|
||||
dialog.hide()
|
||||
|
||||
if url:
|
||||
self.pastebinURLBox.setVisible(True)
|
||||
self.pastebinURLBox.setText(url)
|
||||
QtGui.QApplication.clipboard().setText(url)
|
||||
self.copyToPastebinLabel.setText(self.tr("Pastebin URL copied to clipboard!"))
|
||||
|
@ -72,12 +72,19 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<widget class="QLabel" name="copyToPastebinLabel">
|
||||
<property name="text">
|
||||
<string>Clicking "Copy to PasteBin" will copy a Pastebin URL to your clipboard.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="pastebinURLBox">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
@ -100,6 +107,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="restartMCEditButton">
|
||||
<property name="text">
|
||||
<string>Restart MCEdit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="continueButton">
|
||||
<property name="text">
|
||||
|
Reference in New Issue
Block a user