Fix tagging errors with Sentry

This commit is contained in:
Daniel Lintott 2017-12-19 14:34:31 +00:00
parent 6cba2308e9
commit c3732a7290
No known key found for this signature in database
GPG Key ID: C87264D75D73EC6E
1 changed files with 18 additions and 12 deletions

View File

@ -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: