about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@iosphe.re>2016-02-18 18:11:48 +0100
committerPaweł Jastrzębski <pawelj@iosphe.re>2016-02-18 18:11:48 +0100
commit189c03529a653dfaef217d04944d5307dcec2ce8 (patch)
tree2cb878db69c17b64ef080106f07253f328882eb6
parentOverhauled Linux build environment (diff)
downloadkcc-189c03529a653dfaef217d04944d5307dcec2ce8.tar.gz
kcc-189c03529a653dfaef217d04944d5307dcec2ce8.tar.bz2
kcc-189c03529a653dfaef217d04944d5307dcec2ce8.zip
Replaced own error reporting mechanism with Sentry
-rw-r--r--.gitignore1
-rw-r--r--README.md9
-rwxr-xr-xkcc.py6
-rw-r--r--kcc/KCC_gui.py31
-rw-r--r--kcc/shared.py6
5 files changed, 23 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore
index 9121f45..88105c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ kindlegen*
 *.spec
 setup.bat
 setup.sh
+kcc/sentry.py
diff --git a/README.md b/README.md
index f814c9c..aaa8fe9 100644
--- a/README.md
+++ b/README.md
@@ -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).
 
diff --git a/kcc.py b/kcc.py
index 47a38de..50e564d 100755
--- a/kcc.py
+++ b/kcc.py
@@ -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)
diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py
index d8ef8f2..a5d1a98 100644
--- a/kcc/KCC_gui.py
+++ b/kcc/KCC_gui.py
@@ -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()
diff --git a/kcc/shared.py b/kcc/shared.py
index 72bc07a..921bf6c 100644
--- a/kcc/shared.py
+++ b/kcc/shared.py
@@ -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