File: //opt/saltstack/salt/lib/python3.10/site-packages/cheroot/__pycache__/cli.cpython-310.pyc
o
�N�gR � @ sX d Z ddlZddlmZ ddlZddlZddlZddlmZ ddlm Z ddl
mZ eZ
G dd � d �ZG d
d� de�ZG dd
� d
e�ZG dd� de�ZG dd� d�ZG dd� d�Zdd� Zdd� Zdejdd�ddeddd�d ejd!d�d"ed#d$�d%d&ed'd(�d%d)ed*d(�d%d+ed,d(�d%d-ed.d(�d%d/ed0d(�d%d1ed2d(�d%d3ed4d(�d5�Zd6d7� ZdS )8a: Command line tool for starting a Cheroot WSGI/HTTP server instance.
Basic usage:
.. code-block:: shell-session
$ # Start a server on 127.0.0.1:8000 with the default settings
$ # for the WSGI app myapp/wsgi.py:application()
$ cheroot myapp.wsgi
$ # Start a server on 0.0.0.0:9000 with 8 threads
$ # for the WSGI app myapp/wsgi.py:main_app()
$ cheroot myapp.wsgi:main_app --bind 0.0.0.0:9000 --threads 8
$ # Start a server for the cheroot.server.Gateway subclass
$ # myapp/gateway.py:HTTPGateway
$ cheroot myapp.gateway:HTTPGateway
$ # Start a server on the UNIX socket /var/spool/myapp.sock
$ cheroot myapp.wsgi --bind /var/spool/myapp.sock
$ # Start a server on the abstract UNIX socket CherootServer
$ cheroot myapp.wsgi --bind @CherootServer
.. spelling::
cli
� N)�
import_module� )�server)�wsgi)�suppressc @ s e Zd ZdZdS )�BindLocationz=A class for storing the bind location for a Cheroot instance.N)�__name__�
__module__�__qualname__�__doc__� r r �?/opt/saltstack/salt/lib/python3.10/site-packages/cheroot/cli.pyr - s r c @ � e Zd ZdZdd� ZdS )� TCPSocketz
TCPSocket.c C s ||f| _ dS )zInitialize.
Args:
address (str): Host name or IP address
port (int): TCP port number
N�� bind_addr)�self�address�portr r r
�__init__4 s zTCPSocket.__init__N�r r r
r r r r r r
r 1 � r c @ r )�
UnixSocketzUnixSocket.c C �
|| _ dS )�Initialize.Nr )r �pathr r r
r B �
zUnixSocket.__init__Nr r r r r
r ? r r c @ r )�AbstractSocketzAbstractSocket.c C s dj |d�| _dS )r z {sock_path})Z sock_pathN)�formatr )r Zabstract_socketr r r
r J s zAbstractSocket.__init__Nr r r r r
r G r r c @ s4 e Zd ZdZedd� �Zdd� Zdd� Zdd � Zd
S )�ApplicationzApplication.c C sz |� d�\}}}tt|�|pd�}tt�� t|tj�r't|�W d � S W d � | |�S 1 s4w Y | |�S )z@Read WSGI app/Gateway path string and import application module.�:ZapplicationN) � partition�getattrr r � TypeError�
issubclassr ZGateway� GatewayYo)�cls� full_pathZmod_path�_Zapp_pathZappr r r
�resolveR s
�
��zApplication.resolvec C s t |�std��|| _dS )r zHApplication must be a callable object or cheroot.server.Gateway subclassN)�callabler# �wsgi_app)r r+ r r r
r ^ s
�
zApplication.__init__c C s( dd� t |��� D �}|�t | �� |S )z%Return keyword args for Server class.c S s( i | ]\}}|� d �s|dur||�qS )r( N)�
startswith)�.0�arg�valuer r r
�
<dictcomp>i s ��z+Application.server_args.<locals>.<dictcomp>)�vars�items�update)r �parsed_args�argsr r r
�server_argsg s
�zApplication.server_argsc C s t jdi | �|���S )�Server.Nr )r ZServerr6 )r r4 r r r
r q s zApplication.serverN) r r r
r �classmethodr) r r6 r r r r r
r O s
r c @ s e Zd ZdZdd� Zdd� ZdS )r% zGateway.c C r )zInit.N)�gateway)r r9 r r r
r y r zGatewayYo.__init__c C sL t | �}|d |d<