o
    j|I                  :   @  s  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d dlZd dl	m
Z
 d dlmZ d dlmZmZmZ d dlZd dlZd dlmZ d dlmZmZmZmZmZmZmZmZmZmZm Z m!Z! d dl"m#Z# d d	l$m%Z%m&Z& e'e(e) Z*e'e(e) Z+e'eZ,dddZ-e.dZ/dddZ0ej1ddidej2dddej3d e4d!d"d#d$ej3d%e5d&d'd#d$ej3d(e4dd)d*ej3d+e5dd,d*ej3d-d#d.d/d0ej3d1d2d#d3ej6d#d4d5ej3d6d7d#d8d9ej3d:d;d#d<d9ej3d=e7d>d#d?d@ej3dAde5dBdCej3dDe4e-e dEdFd#dGej3dHe4e-edEdId#dGej3dJe4e-e!dEdKd#dGej3dLe5dMdNd#d$ej3dOe5dPdQd#d$ej3dRe7dSdTd#d$ej3dUe7dSdVd#d$ej3dWe8d#dXd#d$ej3dYe+dEdZd#d$ej3d[e,dEd\d#d$ej3d]ej6d#d4dd^d#d$ej3d_ej6d#d4dd`d#d$ej3dae*ddbd#d$ej3dcd#d#ddd0ej3ded#ddfd0ej3dgd#d#dhd0ej3did#d#djd0ej3dkd#d#dld0ej3dme4ddnd*ej3doe4dpdqd*ej3dre5ddsd*ej3dte5dudvd*ej3dwe5ddxd*ej3dye5d dzd#d$ej3d{e5d|d}d#d$ej3d~e5ddd*ej3de5d|dd#d$ej3de4ddd#d$ej3de4ddd#d$ej3de4ddd#d$ej3de5e5edd#d$ej3de5e5ej9dd#d$ej3de4ddd#d$ej3de4ddd#d$ej3ddd#dd9ej3dd#e0d.d#ddej3ddpd#ddej3dde5ddd*ej3dd#d.dd#dej3dd#d.dd#dddd؄Z:d!d&dddEdEdEdMdPdSdSd#dEdEd.dddd>ddedd#d#d#d#ddpddudd d|dd|dddeej9ddddddd.dd.dٜ2dddZ;dddZ<e=dkre:  dS dS )    )annotationsN)Callable)RawConfigParser)IOAnyget_args)ASGIApplication)
INTERFACESLIFESPAN
LOG_LEVELSLOGGING_CONFIGSSL_PROTOCOL_VERSIONSTARTUP_FAILUREConfigHTTPProtocolTypeInterfaceTypeLifespanTypeLoopFactoryTypeWSProtocolType)Server)ChangeReloadMultiprocess_typer   returnstrc                 C  s    dd dd t| D  dS )N[|c                 s  s    | ]	}|d kr|V  qdS )noneN ).0keyr   r   J/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/uvicorn/main.py	<genexpr>)   s    z%_metavar_from_type.<locals>.<genexpr>])joinr   )r   r   r   r!   _metavar_from_type(   s    r%   uvicorn.errorctxclick.Contextparamclick.ParametervalueboolNonec                 C  s@   |r| j rd S tdjtjt t t	 d | 
  d S )NzKRunning uvicorn {version} with {py_implementation} {py_version} on {system})versionpy_implementation
py_versionsystem)resilient_parsingclickechoformatuvicorn__version__platformpython_implementationpython_versionr1   exit)r'   r)   r+   r   r   r!   print_version/   s   
r<   auto_envvar_prefixUVICORN)context_settingsappUVICORN_APP)envvarz--hostz	127.0.0.1zBind socket to this host.T)typedefaulthelpshow_defaultz--porti@  zABind socket to this port. If 0, an available port will be picked.z--udszBind to a UNIX domain socket.)rC   rD   rE   z--fdz)Bind to socket from this file descriptor.z--reloadFzEnable auto-reload.)is_flagrD   rE   z--reload-dirreload_dirszRSet reload directories explicitly, instead of using the current working directory.)exists)multiplerE   rC   z--reload-includereload_includeszSet glob patterns to include while watching for files. Includes '*.py' by default; these defaults can be overridden with `--reload-exclude`. This option has no effect unless watchfiles is installed.)rJ   rE   z--reload-excludereload_excludeszSet glob patterns to exclude while watching for files. Includes '.*, .py[cod], .sw.*, ~*' by default; these defaults can be overridden with `--reload-include`. This option has no effect unless watchfiles is installed.z--reload-delayg      ?zTDelay between previous and next check if application needs to be. Defaults to 0.25s.)rC   rD   rF   rE   z	--workersz~Number of worker processes. Defaults to the $WEB_CONCURRENCY environment variable if available, or 1. Not valid with --reload.)rD   rC   rE   z--loopautoz"Event loop factory implementation.)rC   metavarrD   rE   rF   z--httpzHTTP protocol implementation.z--wsz"WebSocket protocol implementation.z--ws-max-sizei   z#WebSocket max size message in bytesz--ws-max-queue    z2The maximum length of the WebSocket message queue.z--ws-ping-intervalg      4@z#WebSocket ping interval in seconds.z--ws-ping-timeoutz"WebSocket ping timeout in seconds.z--ws-per-message-deflatez)WebSocket per-message-deflate compressionz
--lifespanzLifespan implementation.z--interfacez:Select ASGI3, ASGI2, or WSGI as the application interface.z
--env-filezEnvironment configuration file.z--log-configzBLogging configuration file. Supported formats: .ini, .json, .yaml.z--log-levelzLog level. [default: info]z--access-log/--no-access-logzEnable/Disable access log.z--use-colors/--no-use-colorsz!Enable/Disable colorized logging.z"--proxy-headers/--no-proxy-headerszaEnable/Disable X-Forwarded-Proto, X-Forwarded-For to populate url scheme and remote address info.z"--server-header/--no-server-headerz%Enable/Disable default Server header.z--date-header/--no-date-headerz#Enable/Disable default Date header.z--forwarded-allow-ipszComma separated list of IP Addresses, IP Networks, or literals (e.g. UNIX Socket path) to trust with proxy headers. Defaults to the $FORWARDED_ALLOW_IPS environment variable if available, or '127.0.0.1'. The literal '*' means trust everything.z--root-path zLSet the ASGI 'root_path' for applications submounted below a given URL path.z--limit-concurrencyz^Maximum number of concurrent connections or tasks to allow, before issuing HTTP 503 responses.z	--backlogi   z0Maximum number of connections to hold in backlogz--limit-max-requestszEMaximum number of requests to service before terminating the process.z--limit-max-requests-jitterzuMaximum jitter to add to limit_max_requests. Staggers worker restarts to avoid all workers restarting simultaneously.z--timeout-keep-alive   zYClose Keep-Alive connections if no new data is received within this timeout (in seconds).z--timeout-graceful-shutdownz8Maximum number of seconds to wait for graceful shutdown.z--timeout-worker-healthcheckzKMaximum number of seconds to wait for a worker to respond to a healthcheck.z--ssl-keyfilezSSL key filez--ssl-certfilezSSL certificate filez--ssl-keyfile-passwordzSSL keyfile passwordz--ssl-versionz,SSL version to use (see stdlib ssl module's)z--ssl-cert-reqsz@Whether client certificate is required (see stdlib ssl module's)z--ssl-ca-certszCA certificates filez--ssl-cipherszNCiphers to use (see stdlib ssl module's). Defaults to OpenSSL's safe defaults.z--headerheaderszASpecify custom default HTTP response headers as a Name:Value pairz	--versionz%Display the uvicorn version and exit.)rG   callbackexpose_valueis_eagerrE   z	--app-dirzuLook for APP in the specified directory, by adding this to the PYTHONPATH. Defaults to the current working directory.)rD   rF   rE   z--h11-max-incomplete-event-sizeh11_max_incomplete_event_sizezFFor h11, the maximum number of bytes to buffer of an incomplete event.z--reset-contextvarszXRun each ASGI request in a fresh contextvars.Context. Hides context set in the lifespan.)rG   rD   rE   rF   z	--factoryzFTreat APP as an application factory, i.e. a () -> <ASGI app> callable.hostportintudsfdloopLoopFactoryType | strhttpHTTPProtocolType | strwsWSProtocolType | strws_max_sizews_max_queuews_ping_intervalfloatws_ping_timeoutws_per_message_deflatelifespanr   	interfacer   reload	list[str]reload_delayworkersenv_file
log_config	log_level
access_logproxy_headersserver_headerdate_headerforwarded_allow_ips	root_pathlimit_concurrencybackloglimit_max_requestslimit_max_requests_jittertimeout_keep_alivetimeout_graceful_shutdown
int | Nonetimeout_worker_healthcheckssl_keyfilessl_certfilessl_keyfile_passwordssl_versionssl_cert_reqsssl_ca_certsssl_ciphers
str | None
use_colorsapp_dirreset_contextvarsfactoryc2           2      C  s  t | fi d|d|d|d|d|d|d|d|d	|	d
|
d|d|d|d|d|d u r5tn|d|d|d|d|d|pGd d|pLd d|pd d|d|d|d|d|d|d|d|d|d | d!|!d"|"d#|#d$|$d%|%d&|&d'|'d(|(d)|)d*|*d+|+d,d-d. |,D d/|-d0|1d1|.d2|/d3|0 d S d|d|d|d|d|d|d|d|d|d | d!|!d"|"d#|#d$|$d%|%d&|&d'|'d(|(d)|)d*|*d+|+d,d-d. |,D d/|-d0|1d1|.d2|/d3|0 d S )4NrW   rX   rZ   r[   r\   r^   r`   rb   rc   rd   rf   rg   rh   rn   ro   rp   rq   ri   rj   rH   rK   rL   rl   rm   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r~   r   r   r   r   r   r   r   rR   c                 S  s   g | ]}| d dqS ):   )split)r   headerr   r   r!   
<listcomp>  s    zmain.<locals>.<listcomp>r   r   r   rV   r   )runr   )2r@   rW   rX   rZ   r[   r\   r^   r`   rb   rc   rd   rf   rg   rh   ri   rj   rH   rK   rL   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r~   r   r   r   r   r   r   r   rR   r   r   rV   r   r   r   r   r!   main=   sD    }	
 !"#$%&'()*+,-./012 !"#$%&'()*+,-./012r   )2rW   rX   rZ   r[   r\   r^   r`   rb   rc   rd   rf   rg   rh   ri   rj   rH   rK   rL   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r~   r   r   r   r   r   r   r   ssl_context_factoryrR   r   r   r   rV   r   *ASGIApplication | Callable[..., Any] | str/type[asyncio.Protocol] | HTTPProtocolType | str-type[asyncio.Protocol] | WSProtocolType | strfloat | Nonelist[str] | str | Nonestr | os.PathLike[str] | NoneJdict[str, Any] | str | os.PathLike[str] | RawConfigParser | IO[Any] | Nonestr | int | Noner   GCallable[[Config, Callable[[], ssl.SSLContext]], ssl.SSLContext] | Nonelist[tuple[str, str]] | Nonebool | Nonec       2   7   	   C  s  |/d urt jd|/ t| fi d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d |d!| d"|!d#|"d$|#d%|$d&|%d'|&d(|'d)|(d*|)d+|*d,|+d-|,d.|-d/|.d0|0d1|1d2|2}3|3js|3jd3krt| tst	d4}4|4
d5 t t n|3  t|3d6}5zKz,|3jr|3 }6t|3|5j|6gd7  n|3jd3kr|3 }6t|3|6gd8  n|5  W n
 ty   Y nw W |3jrtj|3jrt|3j n|3jr)tj|3jr*t|3j w w w |5js@|3jsB|3jd3krDt t d S d S d S d S )9Nr   rW   rX   rZ   r[   r\   r^   r`   rb   rc   rd   rf   rg   rh   ri   rj   rH   rK   rL   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r~   r   r   r   r   r   r   r   r   rR   r   r   rV   r   r   r&   zRYou must pass the application as an import string to enable 'reload' or 'workers'.)config)targetsockets)r   )syspathinsertr   rj   rm   
isinstancer   logging	getLoggerwarningr;   r   load_appr   should_reloadbind_socketr   r   r   KeyboardInterruptrZ   osrI   removestarted)7r@   rW   rX   rZ   r[   r\   r^   r`   rb   rc   rd   rf   rg   rh   ri   rj   rH   rK   rL   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r~   r   r   r   r   r   r   r   r   rR   r   r   r   rV   r   r   loggerserversockr   r   r!   r     s
  6	
 !"#$%&'()*+,-./0124





r   namec                 C  s8   | dkrt dt ddlm} |S tdt d|  )NServerStatezOuvicorn.main.ServerState is deprecated, use uvicorn.server.ServerState instead.r   )r   zmodule z has no attribute )warningswarnDeprecationWarninguvicorn.serverr   AttributeError__name__)r   r   r   r   r!   __getattr__x  s   r   __main__)r   r   r   r   )r'   r(   r)   r*   r+   r,   r   r-   )fr@   r   rW   r   rX   rY   rZ   r   r[   rY   r\   r]   r^   r_   r`   ra   rb   rY   rc   rY   rd   re   rf   re   rg   r,   rh   r   ri   r   rj   r,   rH   rk   rK   rk   rL   rk   rl   re   rm   rY   rn   r   ro   r   rp   r   rq   r,   rr   r,   rs   r,   rt   r,   ru   r   rv   r   rw   rY   rx   rY   ry   rY   rz   rY   r{   rY   r|   r}   r~   rY   r   r   r   r   r   r   r   rY   r   rY   r   r   r   r   rR   rk   r   r,   r   r   rV   r}   r   r,   r   r,   r   r-   )hr@   r   rW   r   rX   rY   rZ   r   r[   r}   r\   r]   r^   r   r`   r   rb   rY   rc   rY   rd   r   rf   r   rg   r,   rh   r   ri   r   rj   r,   rH   r   rK   r   rL   r   rl   re   rm   r}   rn   r   ro   r   rp   r   rq   r,   rr   r,   rs   r,   rt   r,   ru   r   rv   r   rw   r}   rx   rY   ry   r}   rz   rY   r{   rY   r|   r}   r~   rY   r   r   r   r   r   r   r   rY   r   rY   r   r   r   r   r   r   rR   r   r   r   r   r   r   r,   rV   r}   r   r,   r   r-   )r   r   r   r   )>
__future__r   asyncior   r   r8   sslr   r   collections.abcr   configparserr   typingr   r   r   r3   r6   uvicorn._typesr   uvicorn.configr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   uvicorn.supervisorsr   r   ChoicelistkeysLEVEL_CHOICESLIFESPAN_CHOICESINTERFACE_CHOICESr%   r   r   r<   commandargumentoptionr   rY   Pathre   r,   	CERT_NONEr   r   r   r   r   r   r   r!   <module>   s   8




	

	rm 


