mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
Changed the error report so it brings the user to Github directly
Making error reporting too easy results in too much context-less tracebacks which demand attention and, in the end, aren't of much use. Requiring the user to report errors on Github will reduce the number of reports, but hopefully make these reports have better context.
This commit is contained in:
parent
b76820ebde
commit
10d1363334
@ -63,6 +63,9 @@ except ImportError:
|
|||||||
try:
|
try:
|
||||||
from PyQt5.QtCore import QUrl, QStandardPaths
|
from PyQt5.QtCore import QUrl, QStandardPaths
|
||||||
from PyQt5.QtGui import QDesktopServices
|
from PyQt5.QtGui import QDesktopServices
|
||||||
|
def _open_url(url):
|
||||||
|
QDesktopServices.openUrl(QUrl(url))
|
||||||
|
|
||||||
def _open_path(path):
|
def _open_path(path):
|
||||||
url = QUrl.fromLocalFile(str(path))
|
url = QUrl.fromLocalFile(str(path))
|
||||||
QDesktopServices.openUrl(url)
|
QDesktopServices.openUrl(url)
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
# Created By: Virgil Dupras
|
|
||||||
# Created On: 2014-01-26
|
|
||||||
# Copyright 2014 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
#
|
|
||||||
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
|
||||||
# which should be included with this package. The terms are also available at
|
|
||||||
# http://www.hardcoded.net/licenses/bsd_license
|
|
||||||
|
|
||||||
import ftplib
|
|
||||||
import io
|
|
||||||
import time
|
|
||||||
import threading
|
|
||||||
import logging
|
|
||||||
|
|
||||||
def send_error_report(text):
|
|
||||||
def do():
|
|
||||||
try:
|
|
||||||
conn = ftplib.FTP('drop.hardcoded.net')
|
|
||||||
conn.login()
|
|
||||||
conn.cwd('/drop')
|
|
||||||
textfp = io.BytesIO(text.encode('utf-8'))
|
|
||||||
cmd = 'STOR report%d.txt' % time.time()
|
|
||||||
conn.storbinary(cmd, textfp)
|
|
||||||
except Exception as e:
|
|
||||||
logging.warning("Couldn't send error report: %s", e)
|
|
||||||
|
|
||||||
threading.Thread(target=do).start()
|
|
@ -38,7 +38,7 @@ def main():
|
|||||||
from qt.{edition}.app import DupeGuru
|
from qt.{edition}.app import DupeGuru
|
||||||
app.setWindowIcon(QIcon(QPixmap(":/{0}".format(DupeGuru.LOGO_NAME))))
|
app.setWindowIcon(QIcon(QPixmap(":/{0}".format(DupeGuru.LOGO_NAME))))
|
||||||
dgapp = DupeGuru()
|
dgapp = DupeGuru()
|
||||||
install_excepthook()
|
install_excepthook('https://github.com/hsoft/dupeguru/issues')
|
||||||
return app.exec()
|
return app.exec()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -11,17 +11,16 @@ import sys
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QCoreApplication, QSize
|
from PyQt5.QtCore import Qt, QCoreApplication, QSize
|
||||||
from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPlainTextEdit, QPushButton,
|
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPlainTextEdit, QPushButton
|
||||||
QApplication)
|
|
||||||
|
|
||||||
from hscommon.trans import trget
|
from hscommon.trans import trget
|
||||||
from hscommon.error_report import send_error_report
|
from hscommon.desktop import open_url
|
||||||
from .util import horizontalSpacer
|
from .util import horizontalSpacer
|
||||||
|
|
||||||
tr = trget('qtlib')
|
tr = trget('qtlib')
|
||||||
|
|
||||||
class ErrorReportDialog(QDialog):
|
class ErrorReportDialog(QDialog):
|
||||||
def __init__(self, parent, error, **kwargs):
|
def __init__(self, parent, github_url, error, **kwargs):
|
||||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||||
super().__init__(parent, flags, **kwargs)
|
super().__init__(parent, flags, **kwargs)
|
||||||
self._setupUi()
|
self._setupUi()
|
||||||
@ -31,8 +30,9 @@ class ErrorReportDialog(QDialog):
|
|||||||
# Under windows, we end up with an error report without linesep if we don't mangle it
|
# Under windows, we end up with an error report without linesep if we don't mangle it
|
||||||
errorText = errorText.replace('\n', os.linesep)
|
errorText = errorText.replace('\n', os.linesep)
|
||||||
self.errorTextEdit.setPlainText(errorText)
|
self.errorTextEdit.setPlainText(errorText)
|
||||||
|
self.github_url = github_url
|
||||||
|
|
||||||
self.sendButton.clicked.connect(self.accept)
|
self.sendButton.clicked.connect(self.goToGithub)
|
||||||
self.dontSendButton.clicked.connect(self.reject)
|
self.dontSendButton.clicked.connect(self.reject)
|
||||||
|
|
||||||
def _setupUi(self):
|
def _setupUi(self):
|
||||||
@ -40,48 +40,45 @@ class ErrorReportDialog(QDialog):
|
|||||||
self.resize(553, 349)
|
self.resize(553, 349)
|
||||||
self.verticalLayout = QVBoxLayout(self)
|
self.verticalLayout = QVBoxLayout(self)
|
||||||
self.label = QLabel(self)
|
self.label = QLabel(self)
|
||||||
self.label.setText(tr("Something went wrong. Would you like to send the error report to Hardcoded Software?"))
|
self.label.setText(tr("Something went wrong. How about reporting the error?"))
|
||||||
self.label.setWordWrap(True)
|
self.label.setWordWrap(True)
|
||||||
self.verticalLayout.addWidget(self.label)
|
self.verticalLayout.addWidget(self.label)
|
||||||
self.errorTextEdit = QPlainTextEdit(self)
|
self.errorTextEdit = QPlainTextEdit(self)
|
||||||
self.errorTextEdit.setReadOnly(True)
|
self.errorTextEdit.setReadOnly(True)
|
||||||
self.verticalLayout.addWidget(self.errorTextEdit)
|
self.verticalLayout.addWidget(self.errorTextEdit)
|
||||||
msg = tr("Although the application should continue to run after this error, it may be in an "
|
msg = tr(
|
||||||
"instable state, so it is recommended that you restart the application.")
|
"Error reports should be reported as Github issues. You can copy the error traceback "
|
||||||
|
"above and paste it in a new issue (bonus point if you run a search to make sure the "
|
||||||
|
"issue doesn't already exist). What usually really helps is if you add a description "
|
||||||
|
"of how you got the error. Thanks!"
|
||||||
|
"\n\n"
|
||||||
|
"Although the application should continue to run after this error, it may be in an "
|
||||||
|
"unstable state, so it is recommended that you restart the application."
|
||||||
|
)
|
||||||
self.label2 = QLabel(msg)
|
self.label2 = QLabel(msg)
|
||||||
self.label2.setWordWrap(True)
|
self.label2.setWordWrap(True)
|
||||||
self.verticalLayout.addWidget(self.label2)
|
self.verticalLayout.addWidget(self.label2)
|
||||||
self.horizontalLayout = QHBoxLayout()
|
self.horizontalLayout = QHBoxLayout()
|
||||||
self.horizontalLayout.addItem(horizontalSpacer())
|
self.horizontalLayout.addItem(horizontalSpacer())
|
||||||
self.dontSendButton = QPushButton(self)
|
self.dontSendButton = QPushButton(self)
|
||||||
self.dontSendButton.setText(tr("Don\'t Send"))
|
self.dontSendButton.setText(tr("Close"))
|
||||||
self.dontSendButton.setMinimumSize(QSize(110, 0))
|
self.dontSendButton.setMinimumSize(QSize(110, 0))
|
||||||
self.horizontalLayout.addWidget(self.dontSendButton)
|
self.horizontalLayout.addWidget(self.dontSendButton)
|
||||||
self.sendButton = QPushButton(self)
|
self.sendButton = QPushButton(self)
|
||||||
self.sendButton.setText(tr("Send"))
|
self.sendButton.setText(tr("Go to Github"))
|
||||||
self.sendButton.setMinimumSize(QSize(110, 0))
|
self.sendButton.setMinimumSize(QSize(110, 0))
|
||||||
self.sendButton.setDefault(True)
|
self.sendButton.setDefault(True)
|
||||||
self.horizontalLayout.addWidget(self.sendButton)
|
self.horizontalLayout.addWidget(self.sendButton)
|
||||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||||
|
|
||||||
def accept(self):
|
def goToGithub(self):
|
||||||
send_error_report(self.errorTextEdit.toPlainText())
|
open_url(self.github_url)
|
||||||
super().accept()
|
|
||||||
|
|
||||||
|
|
||||||
def install_excepthook():
|
def install_excepthook(github_url):
|
||||||
def my_excepthook(exctype, value, tb):
|
def my_excepthook(exctype, value, tb):
|
||||||
s = ''.join(traceback.format_exception(exctype, value, tb))
|
s = ''.join(traceback.format_exception(exctype, value, tb))
|
||||||
dialog = ErrorReportDialog(None, s)
|
dialog = ErrorReportDialog(None, github_url, s)
|
||||||
dialog.exec_()
|
dialog.exec_()
|
||||||
|
|
||||||
sys.excepthook = my_excepthook
|
sys.excepthook = my_excepthook
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app = QApplication([])
|
|
||||||
QCoreApplication.setOrganizationName('Hardcoded Software')
|
|
||||||
QCoreApplication.setApplicationName('FooApp')
|
|
||||||
QCoreApplication.setApplicationVersion('1.2.3')
|
|
||||||
dialog = ErrorReportDialog(None, 'some traceback')
|
|
||||||
dialog.show()
|
|
||||||
sys.exit(app.exec_())
|
|
Loading…
x
Reference in New Issue
Block a user