Browse Source

[MIG] sentry to V11

- [FIX] sentry: fixes missing `raven` library preventing loading of modules
- [FIX] 2to3 script on py file
- [FIX] add requirements.txt
pull/1082/head
Naglis Jonaitis 8 years ago
committed by Nicolas JEUDY
parent
commit
a38bf51ba6
  1. 1
      requirements.txt
  2. 6
      sentry/__init__.py
  3. 3
      sentry/__manifest__.py
  4. 6
      sentry/logutils.py
  5. 4
      sentry/tests/test_client.py

1
requirements.txt

@ -1 +1,2 @@
checksumdir checksumdir
raven

6
sentry/__init__.py

@ -10,6 +10,8 @@ from odoo.tools import config as odoo_config
from . import const from . import const
from .logutils import LoggerNameFilter, OdooSentryHandler from .logutils import LoggerNameFilter, OdooSentryHandler
import collections
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
HAS_RAVEN = True HAS_RAVEN = True
try: try:
@ -28,7 +30,7 @@ def get_odoo_commit(odoo_dir):
return raven.fetch_git_sha(odoo_dir) return raven.fetch_git_sha(odoo_dir)
except raven.exceptions.InvalidGitRepository: except raven.exceptions.InvalidGitRepository:
_logger.debug( _logger.debug(
u'Odoo directory: "%s" not a valid git repository', odoo_dir)
'Odoo directory: "%s" not a valid git repository', odoo_dir)
def initialize_raven(config, client_cls=None): def initialize_raven(config, client_cls=None):
@ -46,7 +48,7 @@ def initialize_raven(config, client_cls=None):
} }
for option in const.get_sentry_options(): for option in const.get_sentry_options():
value = config.get('sentry_%s' % option.key, option.default) value = config.get('sentry_%s' % option.key, option.default)
if callable(option.converter):
if isinstance(option.converter, collections.Callable):
value = option.converter(value) value = option.converter(value)
options[option.key] = value options[option.key] = value

3
sentry/__manifest__.py

@ -4,11 +4,12 @@
{ {
'name': 'Sentry', 'name': 'Sentry',
'summary': 'Report Odoo errors to Sentry', 'summary': 'Report Odoo errors to Sentry',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Extra Tools', 'category': 'Extra Tools',
'website': 'https://odoo-community.org/', 'website': 'https://odoo-community.org/',
'author': 'Mohammed Barsi,' 'author': 'Mohammed Barsi,'
'Versada,' 'Versada,'
'Nicolas JEUDY,'
'Odoo Community Association (OCA)', 'Odoo Community Association (OCA)',
'license': 'AGPL-3', 'license': 'AGPL-3',
'application': False, 'application': False,

6
sentry/logutils.py

@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging import logging
import urlparse
import urllib.parse
import odoo.http import odoo.http
@ -24,7 +24,7 @@ def get_request_info(request):
Heavily based on flask integration for Sentry: https://git.io/vP4i9. Heavily based on flask integration for Sentry: https://git.io/vP4i9.
''' '''
urlparts = urlparse.urlsplit(request.url)
urlparts = urllib.parse.urlsplit(request.url)
return { return {
'url': '%s://%s%s' % (urlparts.scheme, urlparts.netloc, urlparts.path), 'url': '%s://%s%s' % (urlparts.scheme, urlparts.netloc, urlparts.path),
'query_string': urlparts.query, 'query_string': urlparts.query,
@ -101,6 +101,6 @@ class SanitizeOdooCookiesProcessor(SanitizePasswordsProcessor):
Allows to sanitize sensitive Odoo cookies, namely the "session_id" cookie. Allows to sanitize sensitive Odoo cookies, namely the "session_id" cookie.
''' '''
FIELDS = frozenset([
KEYS = frozenset([
'session_id', 'session_id',
]) ])

4
sentry/tests/test_client.py

@ -74,13 +74,13 @@ class TestClientSetup(unittest.TestCase):
def assertEventCaptured(self, client, event_level, event_msg): def assertEventCaptured(self, client, event_level, event_msg):
self.assertTrue( self.assertTrue(
client.has_event(event_level, event_msg), client.has_event(event_level, event_msg),
msg=u'Event: "%s" was not captured' % event_msg
msg='Event: "%s" was not captured' % event_msg
) )
def assertEventNotCaptured(self, client, event_level, event_msg): def assertEventNotCaptured(self, client, event_level, event_msg):
self.assertFalse( self.assertFalse(
client.has_event(event_level, event_msg), client.has_event(event_level, event_msg),
msg=u'Event: "%s" was captured' % event_msg
msg='Event: "%s" was captured' % event_msg
) )
def test_initialize_raven_sets_dsn(self): def test_initialize_raven_sets_dsn(self):

Loading…
Cancel
Save