1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-12 17:26:23 +00:00

Replaced own error reporting mechanism with Sentry

This commit is contained in:
Paweł Jastrzębski
2016-02-18 18:11:48 +01:00
parent c9cf635229
commit 189c03529a
5 changed files with 23 additions and 30 deletions

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@ kindlegen*
*.spec
setup.bat
setup.sh
kcc/sentry.py

View File

@@ -33,15 +33,16 @@ You can find the latest released binary at the following links:
Following software is required to run Linux version of **KCC** and/or bare sources:
- Python 3.3+
- [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.1+ _(5.5+ is recommended)_
- [Pillow](http://pypi.python.org/pypi/Pillow/) 3.0.0+
- [Pillow](https://pypi.python.org/pypi/Pillow/) 3.0.0+
- [psutil](https://pypi.python.org/pypi/psutil) 3.2.1+
- [python-slugify](http://pypi.python.org/pypi/python-slugify) 1.1.4+
- [python-slugify](https://pypi.python.org/pypi/python-slugify) 1.1.4+
- [raven](https://pypi.python.org/pypi/raven) 5.10+
- [scandir](https://pypi.python.org/pypi/scandir) 1.1.0+ _(needed only when using Python 3.3 or 3.4)_
On Debian based distributions these two commands should install all needed dependencies:
```
sudo apt-get install python3 python3-dev python3-pip python3-pyqt5 libpng-dev libjpeg-dev p7zip-full unrar
sudo pip3 install --upgrade pillow python-slugify psutil scandir
sudo pip3 install --upgrade pillow python-slugify psutil scandir raven
```
### Optional dependencies
@@ -454,8 +455,6 @@ The app relies and includes the following scripts:
* When MCD metadata are used - Cover download
* When error occurs - Automatic reporting
Error report include **KCC** version, OS version and content of error message.
## KNOWN ISSUES
Please check [wiki page](https://github.com/ciromattia/kcc/wiki/Known-issues).

6
kcc.py
View File

@@ -56,6 +56,12 @@ elif sys.platform.startswith('win'):
else:
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/windows/;' + os.environ['PATH']
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Load additional Sentry configuration
if getattr(sys, 'frozen', False):
try:
import kcc.sentry
except:
pass
from kcc.shared import dependencyCheck
dependencyCheck(3)

View File

@@ -32,6 +32,7 @@ from copy import copy
from distutils.version import StrictVersion
from xml.sax.saxutils import escape
from platform import platform
from raven import Client
from .shared import md5Checksum, HTMLStripper, sanitizeTrace
from . import __version__
from . import comic2ebook
@@ -328,6 +329,8 @@ class WorkerThread(QtCore.QThread):
GUI.progress.content = ''
self.errors = True
_, _, traceback = sys.exc_info()
if ' is corrupted.' not in str(err):
GUI.sentry.captureException()
MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
% (jobargv[-1], str(err), sanitizeTrace(traceback)), 'error')
MW.addMessage.emit('Error during conversion! Please consult '
@@ -525,6 +528,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
self.editor.loadData(fname)
except Exception as err:
_, _, traceback = sys.exc_info()
GUI.sentry.captureException()
self.showDialog("Failed to parse metadata!\n\n%s\n\nTraceback:\n%s"
% (str(err), sanitizeTrace(traceback)), 'error')
else:
@@ -688,31 +692,6 @@ class KCCGUI(KCC_ui.Ui_KCC):
def showDialog(self, message, kind):
if kind == 'error':
QtWidgets.QMessageBox.critical(MW, 'KCC - Error', message, QtWidgets.QMessageBox.Ok)
try:
doc = Document()
root = doc.createElement('KCCErrorReport')
doc.appendChild(root)
main = doc.createElement('Timestamp')
root.appendChild(main)
text = doc.createTextNode(datetime.fromtimestamp(time()).strftime('%Y-%m-%d %H:%M:%S'))
main.appendChild(text)
main = doc.createElement('OS')
root.appendChild(main)
text = doc.createTextNode(platform())
main.appendChild(text)
main = doc.createElement('Version')
root.appendChild(main)
text = doc.createTextNode(__version__)
main.appendChild(text)
main = doc.createElement('Error')
root.appendChild(main)
text = doc.createTextNode(message)
main.appendChild(text)
urlopen(Request(url='https://kcc.iosphe.re/ErrorHandle/', data=doc.toxml(encoding='utf-8'),
headers={'Content-Type': 'application/xml',
'User-Agent': 'KindleComicConverter/' + __version__}))
except:
pass
elif kind == 'question':
GUI.versionCheck.setAnswer(QtWidgets.QMessageBox.question(MW, 'KCC - Question', message,
QtWidgets.QMessageBox.Yes,
@@ -915,6 +894,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
self.GammaValue = 1.0
self.currentMode = 1
self.targetDirectory = ''
self.sentry = Client(release=__version__)
if sys.platform.startswith('darwin'):
self.listFontSize = 11
self.statusBarFontSize = 10
@@ -1136,6 +1116,7 @@ class KCCGUI_MetaEditor(KCC_MetaEditor_ui.Ui_MetaEditorDialog):
self.parser.saveXML()
except Exception as err:
_, _, traceback = sys.exc_info()
GUI.sentry.captureException()
GUI.showDialog("Failed to save metadata!\n\n%s\n\nTraceback:\n%s"
% (str(err), sanitizeTrace(traceback)), 'error')
self.ui.close()

View File

@@ -158,6 +158,12 @@ def dependencyCheck(level):
missing.append('PyQt 5.2.1+')
except ImportError:
missing.append('PyQt 5.2.1+')
try:
from raven import VERSION as ravenVersion
if StrictVersion('5.10') > StrictVersion(ravenVersion):
missing.append('raven 5.10+')
except ImportError:
missing.append('raven 5.10+')
if level > 1:
try:
from psutil import __version__ as psutilVersion