Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
±EYc@sádZddlmZddlZddlZddlZddlZddlZddl	Zddl
Z
ddlmZ
ddlmZddlmZddlmZddlZddlZddlZddlZddlZddlmZdd	lmZmZm Z dd
lm!Z!ej"j#Z#e
j$e%ƒZ&dej'fd„ƒYZ(d
ej)fd„ƒYZ)de*fd„ƒYZ+de+fd„ƒYZ,de,fd„ƒYZ-de*fd„ƒYZ.de*fd„ƒYZ/dS(s.Utility methods for working with WSGI servers.iÿÿÿÿ(tprint_functionN(tlog(tservice(texcutils(tdeploy(t	exception(t_t_LEt_LI(tutilstServercBsbeZdZejjZddd	ejjde	d	d„Z
d„Zd„Zd„Z
d„ZRS(
sAServer class to manage a WSGI server, serving a WSGI application.s0.0.0.0ii€c

Csãtjjtj_||_||_d|_||_	|pB|j
|_tj|jƒ|_
tjd|jƒ|_||_|	|_tjjp—d|_|dkrÄtjdtdƒƒ‚n||f}
yBtj|
d|
dtjtjƒd}|d}|d}
Wntk
r.tj}nXytj|
|d|ƒ|_Wn8tk
rˆt j!t"dƒi|d	6|d
6ƒ‚nX|jj#ƒdd!\|_$|_%t j&t'dƒi|jd
6|j$d	6|j%d
6ƒdS(sInitialize, but do not start, a WSGI server.

        :param name: Pretty name for logging.
        :param app: The WSGI application to serve.
        :param host: IP address to serve the application.
        :param port: Port number to server the application.
        :param pool_size: Maximum number of eventlets to spawn concurrently.
        :param backlog: Maximum number of queued connections.
        :param max_url_len: Maximum length of permitted URLs.
        :returns: None
        :raises: nova.exception.InvalidInput
        snova.%s.wsgi.serveritreasonsThe backlog must be more than 0iiÿÿÿÿtbacklogs#Could not bind to %(host)s:%(port)sthosttportis'%(name)s listening on %(host)s:%(port)stnameN((tCONFtwsgitmax_header_lineteventlettMAX_HEADER_LINERtapptNonet_servert	_protocoltdefault_pool_sizet	pool_sizet	GreenPoolt_pooltloggingt	getLoggert_loggert_use_sslt_max_url_lentclient_socket_timeoutRtInvalidInputRtsockettgetaddrinfot	AF_UNSPECtSOCK_STREAMt	ExceptiontAF_INETtlistent_sockettEnvironmentErrortLOGterrorRtgetsocknameR
RtinfoR(
tselfRRR
RRtprotocolRtuse_ssltmax_url_lent	bind_addrR0tfamily((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyt__init__6sB							




"c	Cs¼|jjƒ}|jtjtjdƒ|jtjtjdƒttdƒrr|jtjtj	t
jjƒn|j
r yGt
jj}t
jj}t
jj}|rÔtjj|ƒrÔttdƒ|ƒ‚n|rtjj|ƒrttdƒ|ƒ‚n|r8tjj|ƒr8ttdƒ|ƒ‚n|j
rd|sO|rdttdƒƒ‚nitd6|d6|d	6tjd
6}t
jjr¯||d<tj|d
<ntj||}Wq tk
rtjƒ9tj t!dƒi|j"d
6|j#d6|j$d6ƒWdQXq Xni
tjj%d6|d6|j&d6|j'd6|j(d6|j)d6t
jj*d6t+d6t
jj,d6|j-d6}|j.r¦|j.|d<nt/j0||_1dS(sBStart serving a WSGI application.

        :returns: None
        itTCP_KEEPIDLEsUnable to find cert_file : %ssUnable to find ca_file : %ssUnable to find key_file : %sswWhen running server in SSL mode, you must specify both a cert_file and key_file option value in your configuration filetserver_sidetcertfiletkeyfilet	cert_reqstca_certss>Failed to start %(name)s on %(host)s:%(port)s with SSL supportRR
RNtfunctsocktsiteR2tcustom_poolRt
log_formattdebugt	keepalivetsocket_timeoutturl_length_limit(2R+tdupt
setsockoptR$t
SOL_SOCKETtSO_REUSEADDRtSO_KEEPALIVEthasattrtIPPROTO_TCPR8RRttcp_keepidleR tssl_ca_filet
ssl_cert_filetssl_key_filetostpathtexiststRuntimeErrorRtTruetsslt	CERT_NONEt
CERT_REQUIREDRtwrap_sslR(Rtsave_and_reraise_exceptionR-R.RRR
RtserverRRRRtwsgi_log_formattFalset
keep_aliveR"R!R	tspawnR(R1t
dup_sockettca_filet	cert_filetkey_filet
ssl_kwargstwsgi_kwargs((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pytstartosn


	

	










	cCs|jj|jƒdS(sIReset server greenpool size to default.

        :returns: None

        N(RtresizeR(R1((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pytresetÃscCsFtjtdƒƒ|jdk	rB|jjdƒ|jjƒndS(sµStop this server.

        This is not a very nice action, as currently the method by which a
        server is stopped is by killing its eventlet.

        :returns: None

        sStopping WSGI server.iN(R-R0RRRRRhtkill(R1((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pytstopËs	cCs^y0|jdk	r/|jjƒ|jjƒnWn'tjk
rYtjt	dƒƒnXdS(s‡Block, until the server has stopped.

        Waits on the server's eventlet to finish, then returns.

        :returns: None

        sWSGI server has stopped.N(
RRRtwaitalltwaittgreenlettGreenletExitR-R0R(R1((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyRmÛs
N(t__name__t
__module__t__doc__RRRRRtHttpProtocolR^R7RgRiRkRm(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR
1s	7	T		tRequestcBseZd„ZRS(cOsWtjjr7|jtjjƒ}|r7||d<q7ntt|ƒj|||ŽdS(Nswsgi.url_scheme(RRtsecure_proxy_ssl_headertgettsuperRtR7(R1tenvirontargstkwargstscheme((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR7ìs
(RpRqR7(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyRtëstApplicationcBs&eZdZed„ƒZd„ZRS(sEBase WSGI application wrapper. Subclasses need to implement __call__.cKs
||S(sÂUsed for paste app factories in paste.deploy config files.

        Any local configuration (that is, values under the [app:APPNAME]
        section of the paste config) will be passed into the `__init__` method
        as kwargs.

        A hypothetical configuration would look like:

            [app:wadl]
            latest_version = 1.3
            paste.app_factory = nova.api.fancy_api:Wadl.factory

        which would result in a call to the `Wadl` class as

            import nova.api.fancy_api
            fancy_api.Wadl(latest_version='1.3')

        You could of course re-implement the `factory` method in subclasses,
        but using the kwarg passing it shouldn't be necessary.

        ((tclst
global_configtlocal_config((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pytfactory÷scCsttdƒƒ‚dS(s\Subclasses will probably want to implement __call__ like this:

        @webob.dec.wsgify(RequestClass=Request)
        def __call__(self, req):
          # Any of the following objects work as responses:

          # Option 1: simple string
          res = 'message\n'

          # Option 2: a nicely formatted HTTP exception page
          res = exc.HTTPForbidden(explanation='Nice try')

          # Option 3: a webob Response object (in case you need to play with
          # headers, or you want to be treated like an iterable, or ...)
          res = Response()
          res.app_iter = open('somefile')

          # Option 4: any wsgi app to be run next
          res = self.application

          # Option 5: you can get a Response object for a wsgi app, too, to
          # play with headers etc
          res = req.get_response(self.application)

          # You can then just return your response...
          return res
          # ... or set req.response and return None.
          req.response = res

        See the end of http://pythonpaste.org/webob/modules/dec.html
        for more info.

        sYou must implement __call__N(tNotImplementedErrorR(R1Rxtstart_response((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyt__call__s"(RpRqRrtclassmethodR€Rƒ(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR|ôst
MiddlewarecBsVeZdZed„ƒZd„Zd„Zd„Zej	j
deƒd„ƒZRS(sòBase WSGI middleware.

    These classes require an application to be
    initialized that will be called next.  By default the middleware will
    simply call its wrapped app, or you can override __call__ to customize its
    behavior.

    cs‡‡fd†}|S(sóUsed for paste app factories in paste.deploy config files.

        Any local configuration (that is, values under the [filter:APPNAME]
        section of the paste config) will be passed into the `__init__` method
        as kwargs.

        A hypothetical configuration would look like:

            [filter:analytics]
            redis_host = 127.0.0.1
            paste.filter_factory = nova.api.analytics:Analytics.factory

        which would result in a call to the `Analytics` class as

            import nova.api.analytics
            analytics.Analytics(app_from_paste, redis_host='127.0.0.1')

        You could of course re-implement the `factory` method in subclasses,
        but using the kwarg passing it shouldn't be necessary.

        cs
ˆ|ˆS(N((R(R}R(s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyt_factoryVs((R}R~RR†((R}Rs>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR€?scCs
||_dS(N(tapplication(R1R‡((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR7ZscCsdS(sáCalled on each request.

        If this returns None, the next application down the stack will be
        executed. If it returns a response then that response will be returned
        and execution will stop here.

        N(R(R1treq((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pytprocess_request]scCs|S(s'Do whatever you'd like to the response.((R1tresponse((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pytprocess_responsegstRequestClasscCs8|j|ƒ}|r|S|j|jƒ}|j|ƒS(N(R‰tget_responseR‡R‹(R1RˆRŠ((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyRƒks
(
RpRqRrR„R€R7R‰R‹twebobtdectwsgifyRtRƒ(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR…5s		
	tDebugcBs;eZdZejjdeƒd„ƒZed„ƒZ	RS(s Helper class for debugging a WSGI application.

    Can be inserted into any WSGI application chain to get information
    about the request and response.

    RŒcCsÀtdddƒx-|jjƒD]\}}t|d|ƒq"Wtƒ|j|jƒ}tdddƒx0tj|jƒD]\}}t|d|ƒq€Wtƒ|j|j	ƒ|_	|S(Nt*i(s REQUEST ENVIRONt=s RESPONSE HEADERS(
tprintRxtitemsRR‡tsixt	iteritemstheaderstprint_generatortapp_iter(R1Rˆtkeytvaluetresp((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyRƒ|sccsPtdddƒx0|D](}tjj|ƒtjjƒ|VqWtƒdS(s6Iterator that prints the contents of a wrapper string.R’i(s BODYN(R”tsyststdouttwritetflush(Rštpart((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR™s

	(
RpRqRrRŽRRRtRƒtstaticmethodR™(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR‘tstRoutercBsYeZdZd„Zejjdeƒd„ƒZe	ejjdeƒd„ƒƒZ
RS(s9WSGI middleware that maps incoming requests to WSGI apps.cCs+||_tjj|j|jƒ|_dS(sCreate a router for the given routes.Mapper.

        Each route in `mapper` must specify a 'controller', which is a
        WSGI app to call.  You'll probably want to specify an 'action' as
        well and have your controller be an object that can route
        the request to the action-specific method.

        Examples:
          mapper = routes.Mapper()
          sc = ServerController()

          # Explicit mapping of one route to a controller+action
          mapper.connect(None, '/svrlist', controller=sc, action='list')

          # Actions are all implicitly defined
          mapper.resource('server', 'servers', controller=sc)

          # Pointing to an arbitrary WSGI app.  You can specify the
          # {path_info:.*} parameter so the target app can be handed just that
          # section of the URL.
          mapper.connect(None, '/v1.0/{path_info:.*}', controller=BlogApp())

        N(tmaptroutest
middlewaretRoutesMiddlewaret	_dispatcht_router(R1tmapper((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR7›s	RŒcCs|jS(skRoute the incoming request to a controller based on self.map.

        If no match, return a 404.

        (Rª(R1Rˆ((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyRƒ·scCs2|jdd}|s$tjjƒS|d}|S(sDispatch the request to the appropriate controller.

        Called by self._router after matching the incoming request to a route
        and putting the information into req.environ.  Either returns 404
        or the routed WSGI app's response.

        swsgiorg.routing_argsit
controller(RxRŽtexctHTTPNotFound(RˆtmatchR((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR©Às



(RpRqRrR7RŽRRRtRƒR£R©(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR¤˜s
		tLoadercBs#eZdZdd„Zd„ZRS(s9Used to load WSGI applications from paste configurations.cCs‚d|_|ptjj}tjj|ƒsBtj|ƒ|_ntjj	|ƒr`||_n|js~t
jd|ƒ‚ndS(sŸInitialize the loader, and attempt to find the config.

        :param config_path: Full or relative path to the paste config.
        :returns: None

        RSN(Rtconfig_pathRRtapi_paste_configRRRStisabst	find_fileRTRtConfigNotFound(R1R±((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR7Ôs		cCsˆy?tjdi|d6|jd6ƒtjd|jd|ƒSWnBtk
rƒtjtdƒ|ƒtjd|d|jƒ‚nXdS(sïReturn the paste URLMap wrapped WSGI application.

        :param name: Name of the application to load.
        :returns: Paste URLMap object wrapping the requested application.
        :raises: `nova.exception.PasteAppNotFound`

        s"Loading app %(name)s from %(path)sRRSs	config:%ssCouldn't lookup app: %sN(	R-RCR±RtloadapptLookupErrorRRtPasteAppNotFound(R1R((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pytload_appæs	
N(RpRqRrRR7R¹(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyR°Ñs(0Rrt
__future__Rtos.pathRRR$RWRžRt
eventlet.wsgiRntoslo_logRRtoslo_serviceRt
oslo_utilsRtpasteRtroutes.middlewareR¦R–t	webob.decRŽt	webob.exct	nova.conftnovaRt	nova.i18nRRRR	tconfRRRpR-tServiceBaseR
RttobjectR|R…R‘R¤R°(((s>/home/tvault/.virtenv/lib/python2.7/site-packages/nova/wsgi.pyt<module>s:º	A?$9