
`Tc           @  s  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z y d d l	 Z	 Wn e
 k
 r d d l Z	 n Xy0 d d l m Z m Z d d l m Z m Z Wn= e
 k
 r d d l m Z m Z d d l m Z m Z n Xd d l Z d d l m Z d d l m Z m Z m Z m Z m Z d d l m Z m Z d d	 l  m! Z! m" Z" d
 e e# f d     YZ$ e$ Z% d d  Z' d d d  Z( d   Z) d   Z* d d  Z+ d e# f d     YZ, d   Z- d e e# f d     YZ. d e e. f d     YZ/ d e e. f d     YZ0 d e1 d d e1 d d  Z2 d   Z3 d d d  Z4 d d d  Z5 e4 Z6 d   Z7 d d d   Z8 e1 e1 e9 d d e1 d d d e1 d d!  Z: d"   Z; e< d# k re;   n  d S($   sn  
    werkzeug.serving
    ~~~~~~~~~~~~~~~~

    There are many ways to serve a WSGI application.  While you're developing
    it you usually don't want a full blown webserver like Apache but a simple
    standalone one.  From Python 2.5 onwards there is the `wsgiref`_ server in
    the standard library.  If you're using older versions of Python you can
    download the package from the cheeseshop.

    However there are some caveats. Sourcecode won't reload itself when
    changed and each time you kill the server using ``^C`` you get an
    `KeyboardInterrupt` error.  While the latter is easy to solve the first
    one can be a pain in the ass in some situations.

    The easiest way is creating a small ``start-myproject.py`` that runs the
    application::

        #!/usr/bin/env python
        # -*- coding: utf-8 -*-
        from myproject import make_app
        from werkzeug.serving import run_simple

        app = make_app(...)
        run_simple('localhost', 8080, app, use_reloader=True)

    You can also pass it a `extra_files` keyword argument with a list of
    additional files (like configuration files) you want to observe.

    For bigger applications you should consider using `werkzeug.script`
    instead of a simple start file.


    :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
i(   t   with_statementN(   t   ThreadingMixInt   ForkingMixIn(   t
   HTTPServert   BaseHTTPRequestHandler(   t   _log(   t	   iteritemst   PY2t   reraiset	   text_typet   wsgi_encoding_dance(   t	   url_parset   url_unquote(   t   InternalServerErrort
   BadRequestt   WSGIRequestHandlerc           B  s   e  Z d  Z e d    Z d   Z d   Z d   Z d   Z d d  Z
 d   Z d d  Z d	   Z d
   Z d d d  Z d   Z d   Z d   Z RS(   s3   A request handler that implements WSGI dispatching.c         C  s   d t  j S(   Ns	   Werkzeug/(   t   werkzeugt   __version__(   t   self(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   server_versionF   s    c           s  t    j  }   f d   }   j j d  k r6 d p9 d } t | j  } i d# d 6| d 6  j d 6t j d	 6  j j	 d
 6  j j
 d 6t d 6| d 6  j d 6  j d 6d d 6t |  d 6t | j  d 6  j j d d  d 6  j j d d  d 6  j d d 6  j d d 6  j j d d 6t   j j d  d 6  j d 6} xR   j j   D]A \ } } d | j   j d d  } | d$ k r]| | | <q]q]W| j r| j | d" <n  | S(%   Nc             s   t    j _ d  S(   N(   t   Truet   servert   shutdown_signal(    (   R   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   shutdown_serverM   s    t   httpt   httpsi   i    s   wsgi.versions   wsgi.url_schemes
   wsgi.inputs   wsgi.errorss   wsgi.multithreads   wsgi.multiprocesss   wsgi.run_onces   werkzeug.server.shutdownt   SERVER_SOFTWAREt   REQUEST_METHODt    t   SCRIPT_NAMEt	   PATH_INFOt   QUERY_STRINGs   Content-Typet   CONTENT_TYPEs   Content-Lengtht   CONTENT_LENGTHt   REMOTE_ADDRt   REMOTE_PORTt   SERVER_NAMEt   SERVER_PORTt   SERVER_PROTOCOLt   HTTP_t   -t   _t   HTTP_CONTENT_TYPEt   HTTP_CONTENT_LENGTHt	   HTTP_HOST(   i   i    (   R*   R+   (   R   t   pathR   t   ssl_contextt   NoneR   t   rfilet   syst   stderrt   multithreadt   multiprocesst   FalseR   t   commandR
   t   queryt   headerst   gett   client_addresst   server_addresst   strt   request_versiont   itemst   uppert   replacet   netloc(   R   t   request_urlR   t
   url_schemet	   path_infot   environt   keyt   value(    (   R   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   make_environJ   s@    



	c           sm   j  j d d  j   j   d k r:  j j d  n   j    g    g       f d    d      f d       f d   } y |  j j	  Wn t
 j t
 j f k
 r }  j |   n t k
 rh j j r   n  d d	 l m } | d
 t  } y  s*  2n  | t    Wn t k
 rKn X j j d d | j  n Xd  S(   Nt   ExpectR   s   100-continues   HTTP/1.1 100 Continue

c           s    s t  d    sD  \ } }  (y | j d  d  \ } } Wn t k
 re | d } } n X j t |  |  t   } x= | D]5 \ } }  j | |  | j   } | j	 |  q Wd | k r t
  _  j d d  n  d | k r j d  j    n  d	 | k r7 j d
  j    n   j   n  t |   t k sbt  d    j j |    j j   d  S(   Ns   write() before start_responsei   R   s   content-lengtht
   Connectiont   closeR   t   Servert   datet   Dates   applications must write bytes(   t   AssertionErrort   splitR/   t
   ValueErrort   send_responset   intt   sett   send_headert   lowert   addR   t   close_connectiont   version_stringt   date_time_stringt   end_headerst   typet   bytest   wfilet   writet   flush(   t   datat   statust   response_headerst   codet   msgt   header_keysRF   RG   (   t   headers_sett   headers_sentR   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR_   }   s0    		c           sP   | r* z  r t  |   n  Wd  d  } Xn   r? t d   n  |  | g   ( S(   Ns   Headers already set(   R   R/   RO   (   Rb   Rc   t   exc_info(   Rg   Rh   R_   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   start_response   s    
c           sk   |     } z2 x | D] }  |  q W  s@  d  n  Wd  t  | d  r` | j   n  d  } Xd  S(   NR   RK   (   t   hasattrRK   R/   (   t   appt   application_iterRa   (   Rh   Rj   R_   RE   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   execute   s    i(   t   get_current_tracebackt   ignore_system_exceptionst   errors   Error on request:
%s(   R8   R9   RV   t   stripR^   R_   RH   R/   R   Rl   t   socketRq   t   timeoutt   connection_droppedt	   Exceptiont   passthrough_errorst   werkzeug.debug.tbtoolsRo   R   R   t   logt	   plaintext(   R   Rn   t   eRo   t	   traceback(    (   Rg   Rh   Rj   R   R_   RE   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   run_wsgiu   s2    'c         C  s   d } y t j |   } Wn^ t j t j f k
 rG } |  j |  n3 t k
 ry |  j j	 d k sp t
   rz   qz n X|  j j r |  j   n  | S(   s/   Handles a request ignoring dropped connections.N(   R/   R   t   handleRs   Rq   Rt   Ru   Rv   R   R.   t   is_ssl_errorR   t   initiate_shutdown(   R   t   rvR{   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR~      s    
c         C  sb   t  t d t j  } t j j d  d k rF t j t j   |  n  t |  j	 _
 t |  j	 _ d S(   sp   A horrible, horrible way to kill the server for Python 2.6 and
        later.  It's the best we can do.
        t   SIGKILLt   WERKZEUG_RUN_MAINt   trueN(   t   getattrt   signalt   SIGTERMt   osRE   R9   t   killt   getpidR   R   t   _BaseServer__shutdown_requestR5   t   _BaseServer__serving(   R   t   sig(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR      s
    c         C  s   d S(   s`   Called if the connection was closed by the client.  By default
        nothing happens.
        N(    (   R   Rq   RE   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyRu      s    c         C  sA   |  j  j   |  _ |  j s' d |  _ n |  j   r= |  j   Sd S(   s   Handle a single HTTP request.i   N(   R0   t   readlinet   raw_requestlineRX   t   parse_requestR}   (   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   handle_one_request   s
    	c         C  s   |  j  |  | d k rB | |  j k r9 |  j | d p< d } n  |  j d k r d |  j | | f } |  j j | j d   n  d S(   s3   Send the response header and log the response code.i    R   s   HTTP/0.9s
   %s %d %s
t   asciiN(   t   log_requestR/   t	   responsesR=   t   protocol_versionR^   R_   t   encode(   R   Rd   t   messaget   hdr(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyRR      s    )c         C  s   t  j |   j   S(   N(   R   RY   Rr   (   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyRY      s    c         C  s   |  j  d S(   Ni    (   R:   (   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   address_string   s    R(   c         C  s    |  j  d d |  j | |  d  S(   Nt   infos
   "%s" %s %s(   Ry   t   requestline(   R   Rd   t   size(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR      s    c         G  s   |  j  d |  d  S(   NRq   (   Ry   (   R   t   args(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt	   log_error   s    c         G  s   |  j  d | |  d  S(   NR   (   Ry   (   R   t   formatR   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   log_message  s    c         G  s.   t  | d |  j   |  j   | | f  d  S(   Ns   %s - - [%s] %s
(   R   R   t   log_date_time_string(   R   R\   R   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyRy     s    	N(   t   __name__t
   __module__t   __doc__t   propertyR   RH   R}   R~   R   R/   Ru   R   RR   RY   R   R   R   R   Ry   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR   C   s   	+	O								c         C  s   d d l  m  } d d l m } |  d  k r5 d }  n  | j   } | j t |   t j   | j	 d  | j
 d  | j   } |  | _ d	 | _ | j   } d
 | _ d | _ | j   } | j | j d  | j |  | j | d  | | f S(   Ni(   t   random(   t   cryptot   *i    i<   i   im  s   Dummy Certificates   Untrusted Authoritys   Self-Signedi   t   md5i  iQ i3(   R   t   OpenSSLR   R/   t   X509t   set_serial_numberRS   R1   t   maxintt   gmtime_adj_notBeforet   gmtime_adj_notAftert   get_subjectt   CNt   Ot
   get_issuert   PKeyt   generate_keyt   TYPE_RSAt
   set_pubkeyt   sign(   t   cnR   R   t   certt   subjectt   issuert   pkey(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   generate_adhoc_ssl_pair  s&    					c   	   	   C  s   d d l  m } | d k	 r/ d | | f } n  t d |  \ } } |  d } |  d } t | d  # } | j | j | j |   Wd QXt | d  # } | j | j | j |   Wd QX| | f S(	   s  Creates an SSL key for development.  This should be used instead of
    the ``'adhoc'`` key which generates a new cert on each server start.
    It accepts a path for where it should store the key and cert and
    either a host or CN.  If a host is given it will use the CN
    ``*.host/CN=host``.

    For more information see :func:`run_simple`.

    .. versionadded:: 0.9

    :param base_path: the path to the certificate and key.  The extension
                      ``.crt`` is added for the certificate, ``.key`` is
                      added for the key.
    :param host: the name of the host.  This can be used as an alternative
                 for the `cn`.
    :param cn: the `CN` to use.
    i(   R   s
   *.%s/CN=%sR   s   .crts   .keyt   wN(	   R   R   R/   R   t   openR_   t   dump_certificatet   FILETYPE_PEMt   dump_privatekey(	   t	   base_patht   hostR   R   R   R   t	   cert_filet	   pkey_filet   f(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   make_ssl_devcert,  s    

""c          C  sO   d d l  m }  t   \ } } |  j |  j  } | j |  | j |  | S(   s:   Generates an adhoc SSL context for the development server.i(   t   SSL(   R   R   R   t   Contextt   SSLv23_METHODt   use_privatekeyt   use_certificate(   R   R   R   t   ctx(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   generate_adhoc_ssl_contextN  s    c         C  s@   d d l  m } | j | j  } | j |   | j |  | S(   s=   Loads an SSL context from a certificate and private key file.i(   R   (   R   R   R   R   t   use_certificate_filet   use_privatekey_file(   R   R   R   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   load_ssl_contextX  s
    c         C  s?   |  d k r t j   d }  n  d d l m } t |  | j  S(   s?   Checks if the given error (or the current one) is an SSL error.i   i(   R   N(   R/   R1   Ri   R   R   t
   isinstancet   Error(   Rq   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR   a  s    t   _SSLConnectionFixc           B  s5   e  Z d  Z d   Z d   Z d   Z d d  Z RS(   s>   Wrapper around SSL connection to provide a working makefile().c         C  s   | |  _  d  S(   N(   t   _con(   R   t   con(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   __init__l  s    c         C  s   t  j |  j | |  S(   N(   Rs   t   _fileobjectR   (   R   t   modet   bufsize(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   makefileo  s    c         C  s   t  |  j |  S(   N(   R   R   (   R   t   attrib(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   __getattr__r  s    c         C  s)   y |  j  j   Wn t k
 r$ n Xd  S(   N(   R   t   shutdownRv   (   R   t   arg(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR   u  s    N(   R   R   R   R   R   R   R/   R   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR   i  s
   			c         C  s)   d |  k r" t  t d  r" t j St j S(   s>   Returns AF_INET4 or AF_INET6 depending on where to connect to.t   :t   AF_INET6(   Rk   Rs   R   t   AF_INET(   R   t   port(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   select_ip_version|  s    t   BaseWSGIServerc           B  sV   e  Z d  Z e Z e Z d Z d e d d  Z d   Z	 d   Z
 d   Z d   Z RS(   s3   Simple single-threaded, single-process WSGI server.i   c         C  s  | d  k r t } n  t | |  |  _ t j |  | t |  f |  | |  _ | |  _ t	 |  _
 | d  k	 r y d d l m } Wn t k
 r t d   n Xt | t  r t |   } n  | d k r t   } n  | j | |  j  |  _ | |  _ n	 d  |  _ d  S(   Ni(   t   tsafes=   SSL is not available if the OpenSSL library is not installed.t   adhoc(   R/   R   R   t   address_familyR   R   RS   Rl   Rw   R5   R   R   R   t   ImportErrort	   TypeErrorR   t   tupleR   R   RJ   Rs   R.   (   R   R   R   Rl   t   handlerRw   R.   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR     s&    				c         G  s   t  | | |  d  S(   N(   R   (   R   R\   R   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyRy     s    c         C  s2   t  |  _ y t j |   Wn t k
 r- n Xd  S(   N(   R5   R   R   t   serve_forevert   KeyboardInterrupt(   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR     s
    	c         C  s&   |  j  r   n t j |  | |  Sd  S(   N(   Rw   R   t   handle_error(   R   t   requestR:   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR     s    	c         C  s=   |  j  j   \ } } |  j d  k	 r3 t |  } n  | | f S(   N(   Rs   t   acceptR.   R/   R   (   R   R   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   get_request  s    N(   R   R   R   R5   R3   R4   t   request_queue_sizeR/   R   Ry   R   R   R   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR     s   			t   ThreadedWSGIServerc           B  s   e  Z d  Z e Z RS(   s"   A WSGI server that does threading.(   R   R   R   R   R3   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR     s   t   ForkingWSGIServerc           B  s)   e  Z d  Z e Z d d e d d  Z RS(   s    A WSGI server that does forking.i(   c         C  s,   t  j |  | | | | | |  | |  _ d  S(   N(   R   R   t   max_children(   R   R   R   Rl   t	   processesR   Rw   R.   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR     s    
N(   R   R   R   R   R4   R/   R5   R   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyR     s   i   c      	   C  s   | r! | d k r! t  d   n` | r@ t |  | | | | |  S| d k rh t |  | | | | | |  St |  | | | | |  Sd S(   st   Create a new server instance that is either threaded, or forks
    or just processes one request after another.
    i   s5   cannot have a multithreaded and multi process server.N(   RQ   R   R   R   (   R   R   Rl   t   threadedR   t   request_handlerRw   R.   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   make_server  s    

c          c  s   x t  t j j    D] }  t |  d d   } | r d  } xc t j j |  sz | } t j j	 |  } | | k r= Pq= q= W| d d k r | d  } n  | Vq q Wd  S(   Nt   __file__is   .pycs   .pyoi(   s   .pycs   .pyo(
   t   listR1   t   modulest   valuesR   R/   R   R-   t   isfilet   dirname(   t   modulet   filenamet   old(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   _iter_module_files  s    c         C  s   d d l  m } i  } x x | t   |  p. d  D] } y t j |  j } Wn t k
 rd q2 n X| j |  } | d k r | | | <q2 q2 | | k r2 t	 d d |  t
 j d  q2 q2 Wt j |  q d S(   s[  When this function is run from the main thread, it will force other
    threads to exit when any modules currently loaded change.

    Copyright notice.  This function is based on the autoreload.py from
    the CherryPy trac which originated from WSGIKit which is now dead.

    :param extra_files: a list of additional files it should watch.
    i(   t   chainR   s#    * Detected change in %r, reloadingi   N(    (   t	   itertoolsR  R  R   t   statt   st_mtimet   OSErrorR9   R/   R   R1   t   exitt   timet   sleep(   t   extra_filest   intervalR  t   mtimesR  t   mtimet   old_time(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   _reloader_stat_loop  s     	
c   
        sP  t  g   d d l m } m } y d d l m } | j Wn# t t f k
 r_ d d  l } n X|   } | j | j	 B| j
 B| j B}   f d   } x' |  p d D] } | j | | |  q W| |  }	 ze x^   d s/x$ t   D] } | j | | |  q W|	 j   |	 j d |  r |	 j   q q WWd  |	 j   Xt j d  d  S(	   Ni(   t   WatchManagert   Notifier(   t   EventsCodesc           s0     d r d  St  d d |  j  t g   (d  S(   Ni    R   s#    * Detected change in %r, reloading(   R   R-   R   (   t   event(   t   changed(    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   signal_changed(  s    
i    Rt   i   (    (   R5   t	   pyinotifyR  R  R  t	   IN_ATTRIBR   t   AttributeErrort   IN_DELETE_SELFt   IN_MOVE_SELFt	   IN_MODIFYt	   add_watchR  t   process_eventst   check_eventst   read_eventst   stopR1   R  (
   R  R  R  R  t   ect   wmt   maskR  t   fnamet   notif(    (   R  sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   _reloader_inotify  s,    		
c          C  s   x t  d d  t j g t j }  t j j   } d | d <t j d k r t r xB t	 |  D]1 \ } } t
 | t  r^ | j d  | | <q^ q^ Wn  t j |  d | } | d k r | Sq d	 S(
   sm   Spawn a new Python interpreter with the same arguments as this one,
    but running the reloader thread.
    R   s    * Restarting with reloaderR   R   t   nts
   iso-8859-1t   envi   N(   R   R1   t
   executablet   argvR   RE   t   copyt   nameR   R   R   R	   R   t
   subprocesst   call(   R   t   new_environRF   RG   t	   exit_code(    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   restart_with_reloaderG  s    
c         C  s   d d l  } | j  | j d    t j j d  d k rs t j |  d  y t | |  Wqs t k
 ro d SXn  y t	 j
 t    Wn t k
 r n Xd S(   s<   Run the given function in an independent python interpreter.iNc          W  s   t  j d  S(   Ni    (   R1   R  (   R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   <lambda>a  s    R   R   (    (   R   R   R   RE   R9   t   threadt   start_new_threadt   reloader_loopR   R1   R  R6  (   t	   main_funcR  R  R   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   run_with_reloader^  s    c      
     sf  | r( d d l  m } |  |   n  | rP d d l m } |  |   n           f d   } t j j d  d k r  d k r  p d } d	 | k r d
 | } n  t d d  d k r d p d |   n  | r[t	    } t
 j
 | t
 j  } | j t
 j t
 j d  | j   f  | j   t | | |  n |   d S(   s'  Start an application using wsgiref and with an optional reloader.  This
    wraps `wsgiref` to fix the wrong default reporting of the multithreaded
    WSGI variable and adds optional multithreading and fork support.

    This function has a command-line interface too::

        python -m werkzeug.serving --help

    .. versionadded:: 0.5
       `static_files` was added to simplify serving of static files as well
       as `passthrough_errors`.

    .. versionadded:: 0.6
       support for SSL was added.

    .. versionadded:: 0.8
       Added support for automatically loading a SSL context from certificate
       file and private key.

    .. versionadded:: 0.9
       Added command-line interface.

    :param hostname: The host for the application.  eg: ``'localhost'``
    :param port: The port for the server.  eg: ``8080``
    :param application: the WSGI application to execute
    :param use_reloader: should the server automatically restart the python
                         process if modules were changed?
    :param use_debugger: should the werkzeug debugging system be used?
    :param use_evalex: should the exception evaluation feature be enabled?
    :param extra_files: a list of files the reloader should watch
                        additionally to the modules.  For example configuration
                        files.
    :param reloader_interval: the interval for the reloader in seconds.
    :param threaded: should the process handle each request in a separate
                     thread?
    :param processes: if greater than 1 then handle each request in a new process
                      up to this maximum number of concurrent processes.
    :param request_handler: optional parameter that can be used to replace
                            the default one.  You can use this to replace it
                            with a different
                            :class:`~BaseHTTPServer.BaseHTTPRequestHandler`
                            subclass.
    :param static_files: a dict of paths for static files.  This works exactly
                         like :class:`SharedDataMiddleware`, it's actually
                         just wrapping the application in that middleware before
                         serving.
    :param passthrough_errors: set this to `True` to disable the error catching.
                               This means that the server will die on errors but
                               it can be useful to hook debuggers in (pdb etc.)
    :param ssl_context: an SSL context for the connection. Either an OpenSSL
                        context, a tuple in the form ``(cert_file, pkey_file)``,
                        the string ``'adhoc'`` if the server should
                        automatically create one, or `None` to disable SSL
                        (which is the default).
    i(   t   DebuggedApplication(   t   SharedDataMiddlewarec        	     s)   t            j   d  S(   N(   R   R   (    (   R   R   t   hostnameR.   t   applicationRw   R   R   (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   inner  s    R   R   R   t	   localhostR   s   [%s]R   s    * Running on %s://%s:%d/R   R   i   N(   t   werkzeug.debugR=  t   werkzeug.wsgiR>  R   RE   R9   R   R/   R   Rs   t   SOCK_STREAMt
   setsockoptt
   SOL_SOCKETt   SO_REUSEADDRt   bindRK   R<  (   R?  R   R@  t   use_reloadert   use_debuggert
   use_evalexR  t   reloader_intervalR   R   R   t   static_filesRw   R.   R=  R>  RA  t   display_hostnameR   t   test_socket(    (   R   R   R?  R@  R.   Rw   R   R   sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt
   run_simplen  s*    <$
c    	      C  s  d d l  }  d d l m } |  j d d  } | j d d d d	 d
 d | j d d d d d d d t d
 d | j d d d d d d d t d
 d | j   \ } } d  \ } } | j r | j j	 d  } | d } t
 |  d k r | d } q n  t
 |  d k r1t j j d  t j d  n  | | d  } t d | pPd d t | p_d  d | d | j d | j  d S(!   s:   A simple command-line interface for :py:func:`run_simple`.iN(   t   import_stringt   usages,   Usage: %prog [options] app_module:app_objects   -bs   --bindt   destt   addresst   helps+   The hostname:port the app should listen on.s   -ds   --debugRK  t   actiont
   store_truet   defaults   Use Werkzeug's debugger.s   -rs   --reloadRJ  s(   Reload Python process if modules change.R   i    i   s1   No application supplied, or too much. See --help
R?  s	   127.0.0.1R   i  R@  (   NN(   t   optparset   werkzeug.utilsRR  t   OptionParsert
   add_optionR5   t
   parse_argsR/   RU  RP   t   lenR1   t   stdoutR_   R  RQ  RS   RJ  RK  (	   RZ  RR  t   parsert   optionsR   R?  R   RU  Rl   (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   main  s4    	
t   __main__(=   R   t
   __future__R    R   Rs   R1   R  R   R2  R8  R   t   _threadt   SocketServerR   R   t   BaseHTTPServerR   R   t   socketservert   http.serverR   t   werkzeug._internalR   t   werkzeug._compatR   R   R   R	   R
   t   werkzeug.urlsR   R   t   werkzeug.exceptionsR   R   t   objectR   t   BaseRequestHandlerR/   R   R   R   R   R   R   R   R   R   R   R5   R   R  R  R+  R:  R6  R<  R   RQ  Rc  R   (    (    (    sV   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/serving.pyt   <module>%   sf   ("	
			6		-			V	$