[PATCH 1 of 4 sentry] Drop monkeypatch from ccplugin.py

Philippe Pepiot philippe.pepiot at logilab.fr
Fri Sep 13 15:25:07 CEST 2019


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1568379996 -7200
#      Fri Sep 13 15:06:36 2019 +0200
# Node ID a157e5ff8fa346e0895540660c12db3268639a35
# Parent  be126a8a644724230cf6771179f0ead0ff709280
# Available At https://hg.logilab.org/review/cubes/sentry
#              hg pull https://hg.logilab.org/review/cubes/sentry -r a157e5ff8fa3
Drop monkeypatch from ccplugin.py

It appear this monkeypatch has never worked because "config" is a "bootstrap
config" where all-in-one.conf has never been read.

What worked to have errors from cw-ctl commands was initializing sentry support
in a registration_callback. This is added in the following changeset.

diff --git a/cubicweb_sentry/ccplugin.py b/cubicweb_sentry/ccplugin.py
deleted file mode 100644
--- a/cubicweb_sentry/ccplugin.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from logilab.common.decorators import monkeypatch
-from logilab.common.clcommands import Command
-from cubicweb import ConfigurationError
-from cubicweb.cwconfig import CubicWebConfiguration
-
-from cubicweb_sentry import init_sdk
-
-
-original_main_run = Command.main_run
-
-
- at monkeypatch(Command, 'main_run')
-def sentry_main_run(self, args, rcfile=None):
-    try:
-        return original_main_run(self, args, rcfile=rcfile)
-    except Exception as exc:
-        cmd_args = self.load_command_line_configuration(args)
-        if cmd_args:
-            try:
-                config = CubicWebConfiguration.config_for(cmd_args[0])
-            except ConfigurationError:
-                pass
-            else:
-                sentry_sdk = init_sdk(config)
-                if sentry_sdk:
-                    with sentry_sdk.push_scope() as scope:
-                        scope.set_extra('args', args)
-                        sentry_sdk.capture_exception(exc)
-        raise



More information about the cubicweb-devel mailing list