
    g,                     @   d Z 	 ddlmZ ddlmZ ddlm	Z	m
Z
mZmZmZ ddlmZ ddlmZmZ ddlmZmZmZ dd	lmZmZmZmZmZ ddlmc m Z! dd
lm"Z" ddlm#Z$ ddlm%Z% 	 ddl%m&Z&  e&jN                         Z( e&jR                  e(      e(_*        [&ddlm,Z, dZ- e.d        e.d        ej^                         Z0	  ejb                  d      Z2 e4       e(jj                  d<    e4       e(jj                  d<   e%jl                  jo                  e(      e(_8        e(jp                  js                          e%jl                  ju                  e(      e(_;        e(jv                  js                          e%jl                  jy                  e(      e(_=         G d de>      Z? e?e(      e(_@         ej                         ZBeBjs                          d-dZC G d de      ZD eD       ZE G d de>      ZF eFd      ZG eFd      ZH G d  d!e      ZI eI       ZJd.d"ZK	 ddlLZMeMj                  eM_O        eKeM_N         G d# d$ej                        ZQ eQ       ZRd%eR_S        deR_T        deR_U        e(js                  d&      d'        ZV ej                         xZXZYd%d%d%d%d(eX_Z        d) eXj                  d&<   d* eXj                  d+<   eXj                           e,j                         Z^e(js                  d,e^       y# e$ r ddlZY w xY w# e$ r e%jV                  Z(Y tw xY w# e3$ r dZ2Y Fw xY w# e$ r Y w xY w)/a  CherryPy is a pythonic, object-oriented HTTP framework.

CherryPy consists of not one, but four separate API layers.

The APPLICATION LAYER is the simplest. CherryPy applications are written as
a tree of classes and methods, where each branch in the tree corresponds to
a branch in the URL path. Each method is a 'page handler', which receives
GET and POST params as keyword arguments, and returns or yields the (HTML)
body of the response. The special method name 'index' is used for paths
that end in a slash, and the special method name 'default' is used to
handle multiple paths via a single handler. This layer also includes:

 * the 'exposed' attribute (and cherrypy.expose)
 * cherrypy.quickstart()
 * _cp_config attributes
 * cherrypy.tools (including cherrypy.session)
 * cherrypy.url()

The ENVIRONMENT LAYER is used by developers at all levels. It provides
information about the current request and response, plus the application
and server environment, via a (default) set of top-level objects:

 * cherrypy.request
 * cherrypy.response
 * cherrypy.engine
 * cherrypy.server
 * cherrypy.tree
 * cherrypy.config
 * cherrypy.thread_data
 * cherrypy.log
 * cherrypy.HTTPError, NotFound, and HTTPRedirect
 * cherrypy.lib

The EXTENSION LAYER allows advanced users to construct and share their own
plugins. It consists of:

 * Hook API
 * Tool API
 * Toolbox API
 * Dispatch API
 * Config Namespace API

Finally, there is the CORE LAYER, which uses the core API's to construct
the default components which are available at higher layers. You can think
of the default components as the 'reference implementation' for CherryPy.
Megaframeworks (and advanced users) may replace the default components
with customized or extended components. The core API's are:

 * Application API
 * Engine API
 * Request API
 * Server API
 * WSGI API

These API's are described in the `CherryPy specification
<https://github.com/cherrypy/cherrypy/wiki/CherryPySpec>`_.
    N)local   )	HTTPErrorHTTPRedirectInternalRedirectNotFoundCherryPyException)_cpdispatch)default_toolboxTool)exposepopargsurl)
_cprequest	_cpserver_cptree
_cplogging	_cpconfig)Application)_cpwsgi)process)win32)
_cpchecker)r   r   r   r   r	   dispatchtoolsr   r   wsgir   treeengine
quickstartservingrequestresponsethread_datalogr   r   r   configzcherrypy._cptoolszcherrypy._cprequestcherrypyunknownbefore_requestafter_requestc                       e Zd ZdZd Zd Zy)_HandleSignalsPluginz_Handle signals from other processes.

    Based on the configured platform handlers above.
    c                     || _         y N)bus)selfr.   s     &/opt/Tautulli/lib/cherrypy/__init__.py__init__z_HandleSignalsPlugin.__init__   s	        c                     t        | j                  d      r$| j                  j                  j                          t        | j                  d      r%| j                  j                  j                          yy)z'Add the handlers based on the platform.signal_handlerconsole_control_handlerN)hasattrr.   r4   	subscriber5   r/   s    r0   r7   z_HandleSignalsPlugin.subscribe   sQ    488-.HH##--/48867HH,,668 8r2   N)__name__
__module____qualname____doc__r1   r7    r2   r0   r+   r+      s    
9r2   r+    c                     |rt         j                  |       t        j                  | ||       t        j
                  j                          t        j                          t        j                          y)an  Mount the given root, start the builtin server (and engine), then block.

    root: an instance of a "controller class" (a collection of page handler
        methods) which represents the root of the application.
    script_name: a string containing the "mount point" of the application.
        This should start with a slash, and be the path portion of the URL
        at which to mount the given root. For example, if root.index() will
        handle requests to "http://www.example.com:8080/dept/app1/", then
        the script_name argument would be "/dept/app1".

        It MUST NOT end in a slash. If the script_name refers to the root
        of the URI, it MUST be an empty string (not "/").
    config: a file or dict containing application config. If this contains
        a [global] section, those entries will be used in the global
        (site-wide) config.
    N)	_global_conf_aliasupdater   mountr   signalsr7   startblock)rootscript_namer%   s      r0   r   r      sG    " !!&)JJt[&)
NN
LLN
LLNr2   c                       e Zd ZdZ ej
                   ej                  dd       ej                  dd            Z	  ej                         Z
	 d Zd Zy)_Servinga  An interface for registering request and response objects.

    Rather than have a separate "thread local" object for the request
    and the response, this class works as a single threadlocal container
    for both objects (and any others which developers wish to define).
    In this way, we can easily dump those objects when we stop/start a
    new HTTP conversation, yet still refer to them as module-level
    globals in a thread-safe way.
    z	127.0.0.1P   iW  c                      || _         || _        y r-   )r!   r"   )r/   r!   r"   s      r0   loadz_Serving.load   s     r2   c                 8    | j                   j                          y)zRemove all attributes of self.N)__dict__clearr8   s    r0   rO   z_Serving.clear   s    r2   N)r9   r:   r;   r<   r   Request	_httputilHostr!   Responser"   rL   rO   r=   r2   r0   rI   rI      sa     !j  R!@!/T!BDG #z""$H!r2   rI   c                   d    e Zd ZddgZd Zd Zd Zd Zed        Z	d Z
d	 Zd
 Zd Zd Zd ZeZy)_ThreadLocalProxy__attrname__rN   c                     || _         y r-   rV   )r/   attrnames     r0   r1   z_ThreadLocalProxy.__init__   s
    $r2   c                 N    t        t        | j                        }t        ||      S r-   getattrr    rV   r/   namechilds      r0   __getattr__z_ThreadLocalProxy.__getattr__   s!    !2!23ud##r2   c                     |dv rt         j                  | ||       y t        t        | j                        }t        |||       y )NrX   )object__setattr__r\   r    rV   setattr)r/   r^   valuer_   s       r0   rc   z_ThreadLocalProxy.__setattr__   s;    %%tT51GT%6%67EE4'r2   c                 P    t        t        | j                        }t        ||       y r-   )r\   r    rV   delattrr]   s      r0   __delattr__z_ThreadLocalProxy.__delattr__   s    !2!23tr2   c                     t        t        | j                        }|j                  j                  j                         }|j                  |j                         |S r-   )r\   r    rV   	__class__rN   copyrA   )r/   r_   ds      r0   rN   z_ThreadLocalProxy.__dict__   sA    !2!23OO$$))+	 r2   c                 @    t        t        | j                        }||   S r-   r[   r/   keyr_   s      r0   __getitem__z_ThreadLocalProxy.__getitem__   s    !2!23Szr2   c                 B    t        t        | j                        }|||<   y r-   r[   )r/   ro   re   r_   s       r0   __setitem__z_ThreadLocalProxy.__setitem__   s    !2!23c
r2   c                 >    t        t        | j                        }||= y r-   r[   rn   s      r0   __delitem__z_ThreadLocalProxy.__delitem__  s    !2!23#Jr2   c                 >    t        t        | j                        }||v S r-   r[   rn   s      r0   __contains__z_ThreadLocalProxy.__contains__  s    !2!23e|r2   c                 L    t        t        | j                        }t        |      S r-   )r\   r    rV   lenr/   r_   s     r0   __len__z_ThreadLocalProxy.__len__
  s    !2!235zr2   c                 L    t        t        | j                        }t        |      S r-   )r\   r    rV   boolry   s     r0   __nonzero__z_ThreadLocalProxy.__nonzero__  s    !2!23E{r2   N)r9   r:   r;   	__slots__r1   r`   rc   rh   propertyrN   rp   rr   rt   rv   rz   r}   __bool__r=   r2   r0   rU   rU      sY    ,I%$(   Hr2   rU   r!   r"   c                       e Zd ZdZy)_ThreadDataz%A container for thread-specific data.N)r9   r:   r;   r<   r=   r2   r0   r   r     s    /r2   r   c                     t        | t              rt        t        | j                        } t        j                  | |      S )zDGiven an object or a path to an object, get the object and its name.)
isinstancerU   r\   r    rV   _pydoc_builtin_resolve)thing	forceloads     r0   _cherrypy_pydoc_resolver   )  s2    %*+!3!34""5)44r2   c                       e Zd ZdZd Zd Zy)_GlobalLogManagera  A site-wide LogManager; routes to app.log or global log as appropriate.

    This :class:`LogManager<cherrypy._cplogging.LogManager>` implements
    cherrypy.log() and cherrypy.log.access(). If either
    function is called during a request, the message will be sent to the
    logger for the current Application. If they are called outside of a
    request, the message will be sent to the site-wide logger.
    c                     t        t        d      r5t        t        j                  d      rt        j                  j                  }n| } |j                  |i |S )zLog the given message to the app.log or global log.

        Log the given message to the app.log or global log as
        appropriate.
        appr$   )r6   r!   r   r$   error)r/   argskwargsr$   s       r0   __call__z_GlobalLogManager.__call__B  sC     7E"ww{{E'B++//CCsyy$)&))r2   c                     	 t         j                  j                  j                         S # t        $ r" t
        j                  j                  |       cY S w xY w)zLog an access message to the app.log or global log.

        Log the given message to the app.log or global log as
        appropriate.
        )r!   r   r$   accessAttributeErrorr   
LogManagerr8   s    r0   r   z_GlobalLogManager.accessP  sD    	6;;??))++ 	6((//55	6s   '* (AAN)r9   r:   r;   r<   r   r   r=   r2   r0   r   r   8  s    *	6r2   r   Tr$   c                 4    t         j                  | d|       y )NENGINE)severity)r$   r   )msglevels     r0   _buslogr   d  s    IIc8eI,r2   )ztools.log_tracebacks.onztools.log_headers.onztools.trailing_slash.onztools.encode.onc                 $    t        t        | |      S r-   )rd   r$   kvs     r0   <lambda>r   r  s    Q(: r2   c                 $    t        t        | |      S r-   )rd   checkerr   s     r0   r   r   s  s    GGQ,B r2   r   rD   )Nr>   N)r   )_r<   importlib.metadatametadataimportlib_metadataImportError	threadingr   _local_cperrorr   r   r   r   r	   r>   r
   r   _cptoolsr   r   r   _helperr   r   r   r   r   r   r   r   cherrypy.lib.httputillibhttputilrQ   r   r   r   r   r   Win32Busr   ConsoleCtrlHandlerr5   r.   r   __all__
__import__Treer   version__version__	Exceptionset	listenerspluginsAutoreloader
autoreloadr7   ThreadManagerthread_managerSignalHandlerr4   rb   r+   rC   Serverserverr   rI   r    rU   r!   r"   r   r#   r   pydocr   resolver   r   r   r$   screen
error_fileaccess_filer   Configr%   r@   defaults
namespacesresetCheckerr   r=   r2   r0   <module>r      s  8t3 & 
 & 4 ) ) C C ) )    U^^F%=U%=%=f%EF"    
  ! w||~,$,,Z8K
 &)U  ! "$'E   ! OO008       55f=       !55f= 96 9" &f- 
			    6 v  F *5 5v I
&Z(
0& 0 m5	$nnF,FN
!6
-- !6H 
 %- - /i..0 0	# #	 ;  % B  )  
*


   ' "w	   <  [[F0  KB  		sG   K  /K/ 9L L 	K,+K,/LLLLLL