From c3732a7290ecef6cd7785ecb770a24d5c6cc738c Mon Sep 17 00:00:00 2001 From: Daniel Lintott Date: Tue, 19 Dec 2017 14:34:31 +0000 Subject: [PATCH] Fix tagging errors with Sentry --- src/OXM/crash_report.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/OXM/crash_report.py b/src/OXM/crash_report.py index ae9ce28..3055da5 100755 --- a/src/OXM/crash_report.py +++ b/src/OXM/crash_report.py @@ -25,9 +25,11 @@ import struct try: import raven RAVEN_AVAILABLE = True + print('Raven available - Enabling logging') except ImportError: # raven is not installed with deb package in order to simplify packaging RAVEN_AVAILABLE = False + print('Raven not available - Logging not enabled') from .version import __version__ @@ -62,20 +64,24 @@ class CrashReport: if self._client is None: self._client = raven.Client(CrashReport.DSN, release=__version__) - self._client.tags_context({ - "os:name": platform.system(), - "os:release": platform.release(), - "os:win_32": " ".join(platform.win32_ver()), - "os:mac": "{} {}".format(platform.mac_ver()[0], - platform.mac_ver()[2]), - "os:linux": " ".join(platform.linux_distribution()), - "python:version": "{}.{}.{}".format(sys.version_info[0], + + tags = {"os:name": platform.system(), + "os:release": platform.release(), + "python:version": "{}.{}.{}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2]), - "python:bit": struct.calcsize("P") * 8, - "python:encoding": sys.getdefaultencoding(), - "python:frozen": "{}".format(hasattr(sys, "frozen")) - }) + "python:bit": struct.calcsize("P") * 8, + "python:encoding": sys.getdefaultencoding(), + "python:frozen": "{}".format(hasattr(sys, "frozen"))} + + if sys.platform == 'win32': + tags['os:win32'] = " ".join(platform.win32_ver()) + elif sys.platform == 'darwin': + tags['os:mac'] = "{} {}".format(platform.mac_ver()[0], platform.mac_ver()[2]) + else: + tags['os:linux'] = " ".join(platform.linux_distribution()) + + self._client.tags_context(tags) try: report = self._client.captureException((exception, value, tb)) except Exception as e: