SQ+ކY d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl m Z ddlmZ ddl mZ dd lmZ ej Ze d ZddZ G d d e ZdS )z raven.contrib.sanic ~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2018 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. )absolute_importN) setup_logging)Client) SentryHandler)urlparse) to_unicode)convert_optionslogging_configuredc | di t |j |t |j dg t |j g z d|id S )NSENTRY_INCLUDE_PATHSapp)dsn include_pathsextra)defaults )r configsetgetname) client_clsr r s e/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/raven/contrib/sanic.pymake_clientr s~ : J '=rBBCC38*oo& 3 c e Zd ZdZdedddej fdZd Zd Z d Z d Zd Zd Z ddZd Zd Zd Zd Zd Zd Zd Zd ZdS )Sentryaj Sanic application for Sentry. Look up configuration from ``os.environ['SENTRY_DSN']``:: >>> sentry = Sentry(app) Pass an arbitrary DSN:: >>> sentry = Sentry(app, dsn='http://public:secret@example.com/1') Pass an explicit client:: >>> sentry = Sentry(app, client=client) Automatically configure logging:: >>> sentry = Sentry(app, logging=True, level=logging.ERROR) Capture an exception:: >>> try: >>> 1 / 0 >>> except ZeroDivisionError: >>> sentry.captureException() Capture a message:: >>> sentry.captureMessage('hello, world!') NFc |r$t |t st d || _ || _ || _ || _ || _ || _ | | d S )Nz&client should be an instance of Client) isinstancer TypeErrorclientr r logginglogging_exclusionslevelinit_app)selfr r r r r! r" r# s r __init__zSentry.__init__M so F*VV44 FDEEE$"4 cr c V | j sd S | j | | nC# t $ r6}| j j t | Y d }~nd }~ww xY wt | ||j f}| | d S )N)exc_info) r http_context get_http_info Exceptionlogger exceptionr type __traceback__captureException)r% requestr- eexception_infos r handle_exceptionzSentry.handle_exceptionZ s { F 8K$$T%7%7%@%@AAAA 8 8 8K((A77777777 8 y//9i6MN~66666s -9 A9,A44A9c |j S N)formr% r1 s r get_form_datazSentry.get_form_datag |r c v | | r| j }n| j }| || S )zR Determine how to retrieve actual data by using request.mimetype. )is_json_type get_json_datar9 get_http_info_with_retriever)r% r1 retrievers r r* zSentry.get_http_infoj sB W%% +*II*I00)DDDr c |j S r6 )jsonr8 s r r= zSentry.get_json_datat r: r c t j |j } || }n# t $ r i }Y nw xY wd |j |j |j |j |j ||j |j d|j idS )zT Exact method for getting http_info but with form data work around. z{0}://{1}{2}REMOTE_ADDR)urlquery_stringmethoddatacookiesheadersenv) r urlsplitrD r+ formatschemenetlocpathqueryrF rH rI remote_addr)r% r1 r? urlpartsrG s r r> z#Sentry.get_http_info_with_retrieverw s $W[11 9W%%DD DDD "(((-A A$Nnw2 s ' 66c B |j d }|dk S )Nzcontent-typezapplication/json)rI r )r% r1 content_types r r<