403Webshell
Server IP : 192.64.118.117  /  Your IP : 18.117.79.92
Web Server : LiteSpeed
System : Linux premium56.web-hosting.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64
User : thecgapy ( 1160)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/hc_python/lib/python3.12/site-packages/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/hc_python/lib/python3.12/site-packages/NCSentry.py
#!/opt/hc_python/bin/python3
import os
import warnings
import importlib.metadata as metadata
import sentry_sdk

from packaging.version import Version




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("MyAwesomeString"))
    """

    __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().strip()
            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:
            dist_version_str = metadata.version("sentry-sdk")

            installed_version = Version(dist_version_str)
            conflict_version = Version(self.__conflict_under_version)

            if installed_version >= conflict_version:
                self.sentry_args["traces_sample_rate"] = 0

        except Exception as err:
            warnings.warn(f"Can't set up sentry default args properly: {err}")

Youez - 2016 - github.com/yon3zu
LinuXploit