PHP 8.2.30
Preview: NCSentry.py Size: 1.49 KB
/proc/self/root/opt/alt/python38/lib/python3.8/site-packages/NCSentry.py

#!/opt/alt/python38/bin/python3
import os
import sentry_sdk
import warnings


class NCSentry:

    """
    Simple Wrapper

        sentry = NCSentry()

    After successfully inited class we can use Sentry debug system:

    Report to Sentry:

        SentryClient.capture_message("test")
        SentryClient.capture_exception(Exception("MyAwsomeString"))

    """

    __conflict_under_version = "0.19.2"

    def __init__(self, config_dir=None):
        self.sentry_args = {}
        if config_dir:
            dir_path = config_dir
        else:
            dir_path = os.path.dirname(os.path.realpath(__file__))

        self.conf_path = os.path.join(dir_path, ".sentry.conf")

        self.construct_args()

        with open(self.conf_path) as fh:
            self.dsn = fh.read()
            self.client = sentry_sdk.init(self.dsn, **self.sentry_args)
            self.capture_message = sentry_sdk.capture_message
            self.capture_exception = sentry_sdk.capture_exception

    def construct_args(self):
        try:
            import pkg_resources

            _conflict_under_version = pkg_resources.extern.packaging.version.Version(
                self.__conflict_under_version
            )
            if (
                pkg_resources.get_distribution("sentry-sdk").parsed_version
                >= _conflict_under_version
            ):
                self.sentry_args["traces_sample_rate"] = 0
        except Exception as err:
            warnings.warn(f"Can't setup sentry default args {err}")

Directory Contents

Dirs: 14 × Files: 7

Name Size Perms Modified Actions
certifi DIR
- drwxr-xr-x 2024-03-21 10:24:41
Edit Download
- drwxr-xr-x 2024-03-21 10:24:41
Edit Download
pip DIR
- drwxr-xr-x 2024-03-03 22:49:50
Edit Download
- drwxr-xr-x 2024-03-03 22:49:50
Edit Download
- drwxr-xr-x 2024-03-03 22:48:31
Edit Download
- drwxr-xr-x 2024-03-21 10:24:45
Edit Download
- drwxr-xr-x 2024-03-21 10:24:45
Edit Download
- drwxr-xr-x 2024-03-03 22:48:31
Edit Download
- drwxr-xr-x 2024-03-03 22:48:31
Edit Download
- drwxr-xr-x 2024-03-21 10:24:29
Edit Download
urllib3 DIR
- drwxr-xr-x 2024-08-13 07:03:05
Edit Download
- drwxr-xr-x 2024-08-13 07:03:05
Edit Download
- drwxr-xr-x 2024-03-03 22:48:31
Edit Download
- drwxr-xr-x 2025-04-04 09:00:02
Edit Download
101 B lrw------- 2025-04-04 08:02:10
Edit Download
152 B lrw-r--r-- 2023-11-13 21:45:15
Edit Download
1.49 KB lrw-r--r-- 2025-03-26 11:05:09
Edit Download
322 B lrw-r--r-- 2020-07-10 11:16:53
Edit Download
31.69 KB lrw-r--r-- 2018-12-10 00:59:34
Edit Download
29.25 KB lrw-r--r-- 2016-05-21 21:54:42
Edit Download
2.84 KB lrw-r--r-- 2016-05-21 21:54:42
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).