403Webshell
Server IP : 46.62.235.243  /  Your IP : 216.73.216.217
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux Linkabili3Dicembre 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/supervisor/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/supervisor/tests/__pycache__/test_options.cpython-312.pyc
�

�C�c�7���dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
mZmZmZddlmZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZGd�dej6�ZGd�dej6�ZGd�dej6�ZGd�dej6�ZGd�dej6�Z Gd�dej6�Z!Gd�dej6�Z"Gd�dej6�Z#Gd�d ej6�Z$Gd!�d"ej6�Z%Gd#�d$ej6�Z&Gd%�d&ej6�Z'd'�Z(e)d(k(rejTd)�*�yy)+z!Test suite for supervisor.options�N)�StringIO)�as_bytes)�Mock�sentinel�patch)�LevelsByName)�DummySupervisor)�DummyLogger)�DummyOptions)�DummyPoller)�DummyPConfig)�DummyProcess)�DummySocketConfig)�lstripc��eZdZd�Zdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�OptionTestsc��ddlm}|S)Nr��Options)�supervisor.optionsr)�selfrs  �?/usr/lib/python3/dist-packages/supervisor/tests/test_options.py�_getTargetClasszOptionTests._getTargetClasss
��.���c�����|j��ddlm}G��fd�d��}|�}t�|_|jddddd�	�|jd
d
ddd
|��|S)Nr)�integerc�,��eZdZddiZW�f�fd�	Zd�Zy)�+OptionTests._makeOptions.<locals>.MyOptions�other�)c�l��||_�j|�Gd�dt�}|�|_y)Nc��eZdZy)�AOptionTests._makeOptions.<locals>.MyOptions.__init__.<locals>.FooN��__name__�
__module__�__qualname__�rr�Foor#-s�rr))�
read_error�__init__�object�
configroot)rr*r)rs   �rr+z4OptionTests._makeOptions.<locals>.MyOptions.__init__*s)���",���� � ��&�'�&�'�"%�%��rc��|jrt|j��|jjj	|j
�|jjj	|j�y�N)r*�
ValueErrorr-�__dict__�update�default_map�master)r�fps  r�read_configz7OptionTests._makeOptions.<locals>.MyOptions.read_config0sR���?�?�$�T�_�_�5�5����(�(�/�/��0@�0@�A����(�(�/�/����<rN)r%r&r'r4r+r6)rr*s��r�	MyOptionsr's������F�*4�
(�
=rr7�anoption�o�option�default)�name�confname�short�longr;r�OTHERzp:zother=)r<r=�envr>r?�handler)r�supervisor.datatypesrr�
configfile�add)rr*rr7�optionsrs `   @r�_makeOptionszOptionTests._makeOptions#st����&�&�(��0�	=��	=� �+��%�Z�������j��H�i�	�	A�����7���X�w�	�	@��rc�x�|j�}|�}|jt|jdd��y)NT)�flagrB�r�assertRaisesr0rE�r�cls�insts   r�'test_add_flag_not_None_handler_not_Nonez3OptionTests.test_add_flag_not_None_handler_not_None?s2���"�"�$���u�����*�d�h�h�T�4��Hrc�z�|j�}|�}|jt|jddd��y)NTF�rIr?r>rJrLs   r�-test_add_flag_not_None_long_false_short_falsez9OptionTests.test_add_flag_not_None_long_false_short_falseDs=���"�"�$���u�������H�H����	�	rc�z�|j�}|�}|jt|jddd��y)NTF�:rQrJrLs   r�+test_add_flag_not_None_short_endswith_colonz7OptionTests.test_add_flag_not_None_short_endswith_colonOs=���"�"�$���u�������H�H����	�	rc�z�|j�}|�}|jt|jddd��y)NT�=FrQrJrLs   r�*test_add_flag_not_None_long_endswith_equalz6OptionTests.test_add_flag_not_None_long_endswith_equalZs=���"�"�$���u�������H�H����	�	rc�x�|j�}|�}|jt|jdd��y)NrW�abc�r?r>rJrLs   r�(test_add_inconsistent_short_long_optionsz4OptionTests.test_add_inconsistent_short_long_optionses:���"�"�$���u�������H�H���		�	rc�x�|j�}|�}|jt|jdd��y)NF�-abcr[rJrLs   r�%test_add_short_option_startswith_dashz1OptionTests.test_add_short_option_startswith_dashos:���"�"�$���u�������H�H���		�	rc�x�|j�}|�}|jt|jdd��y)NFrZr[rJrLs   r�test_add_short_option_too_longz*OptionTests.test_add_short_option_too_longys:���"�"�$���u�������H�H���		�	rc��|j�}|�}ddi|_|jt|jdd��y)Nz-aTF�ar[�r�options_maprKr0rErLs   r�#test_add_duplicate_short_option_keyz/OptionTests.test_add_duplicate_short_option_key�sF���"�"�$���u�� ��;��������H�H���		�	rc�x�|j�}|�}|jt|jdd��y)Nr^Fr[rJrLs   r�$test_add_long_option_startswith_dashz0OptionTests.test_add_long_option_startswith_dash�s:���"�"�$���u�������H�H���		�	rc��|j�}|�}ddi|_|jt|jdd��y)Nz--abcTrZFr[rdrLs   r�"test_add_duplicate_long_option_keyz.OptionTests.test_add_duplicate_long_option_key�sF���"�"�$���u��#�D�>��������H�H���		�	rc��|j�}|jt|j�d�|j|jddgd��y)N����)�supervisord.confzetc/supervisord.confz/etc/supervisord.confz /etc/supervisor/supervisord.conf)rG�assertEqual�len�searchpaths�rrFs  r�test_searchpathszOptionTests.test_searchpaths�sM���#�#�%������W�0�0�1�1�5�����,�,�R�S�1�4�	rc��|j�}|jg�|j|jd�|j|jd�|j�}dt
jd<|jg�|j|jd�|j�}|jddg�|j|jd�t
jd=y)	Nr;r �42r@�*�-p�43�+)rG�realizeror8r�os�environrrs  r�test_options_and_args_orderz'OptionTests.test_options_and_args_order�s����#�#�%�����������)�)�9�5��������+��#�#�%��"��
�
�7��������������+��#�#�%������t��%��������+��J�J�w�rc���|j�}|jg�|j|jd�d|jd<|j�|j|jd�y)Nr rvr)rGrzrorr4�process_configrrs  r�test_config_reloadzOptionTests.test_config_reload�s^���#�#�%��������������+�"$����w����� ��������+rc�j�|jd��}|jt|jd�y)N�error�r*F)rGrKr0rrrs  r�!test_config_reload_do_usage_falsez-OptionTests.test_config_reload_do_usage_false�s0���#�#�w�#�7�����*�g�&<�&<��	!rc���|jd��}g��fd�|_t�x|_|_d|j
_d|j
_|jd��|j�dg�y)Nr�r�c�&���j|�Sr/��append��x�	exitcodess �r�<lambda>z>OptionTests.test_config_reload_do_usage_true.<locals>.<lambda>������!1�!1�!�!4�r�T��do_usage�)
rG�exitr�stderr�stdoutr-r8rrro)rrFr�s  @r� test_config_reload_do_usage_truez,OptionTests.test_config_reload_do_usage_true�sq����#�#�w�#�7���	�4���*2�*�4�����&'����#�#$���� ������-�����Q�C�(rc�P�ddlm}|�}|jddd�|j|jd�|j|j
dd�|jddd�|j|jd�|j|j
dd�|jddd�|j|jd�|j|j
dd�|jddd�|j|jd�y)Nrr�foo�bar�bazr��gazonk)rr�_setror��attr_priorities)rrrFs   r�	test__setzOptionTests.test__set�s���.��)�����U�E�1�%�������e�,�����0�0��7��;����U�E�1�%�������e�,�����0�0��7��;����U�H�a�(�������e�,�����0�0��7��;����U�H�a�(�������h�/rc�$��|j�}g|_g��fd�|_t�|_|j�|j
�dg�d}|j|jj�j|��y)Nc�&���j|�Sr/r�r�s �rr�z9OptionTests.test_missing_default_config.<locals>.<lambda>�r�rr�z,Error: No config file found at default paths)
rGrqr�rr��default_configfilero�
assertTrue�getvalue�
startswith�rrF�msgr�s   @r�test_missing_default_configz'OptionTests.test_missing_default_config�su����#�#�%�� ����	�4���!�����"�"�$�����Q�C�(�<��������/�/�1�<�<�S�A�Brc���|j�}tj�5}|jg|_|j�}|j
||j�ddd�y#1swYyxYwr/)rG�tempfile�NamedTemporaryFiler<rqr�ro)rrF�f�configs    r�test_default_configzOptionTests.test_default_config�sc���#�#�%��
�
(�
(�
*�	-�a�#$�6�6�(�G���/�/�1�F����V�Q�V�V�,�	-�	-�	-�s�?A-�-A6c���|j�}g��fd�|_t�|_d|_d|_|j
d�|j�dg�d}|j|jj�|�y)Nc�&���j|�Sr/r�r�s �rr�z'OptionTests.test_help.<locals>.<lambda>�r�r�	test_helpzA sample docstring for %s�rz!A sample docstring for test_help
)	rGr�rr��progname�doc�helpror�r�s   @rr�zOptionTests.test_help�su����#�#�%���	�4���!����&���1������R������Q�C�(�2��������0�0�2�C�8rN)F)r%r&r'rrGrOrRrUrXr\r_rarfrhrjrsr}r�r�r�r�r�r�r�r(rrrrsm����8I�
	�	�	����	��	�� �&,�!�
)�
0�	C�-�
9rrc�`�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zy)�ClientOptionsTestsc��ddlm}|S)Nr)�
ClientOptions)rr�)rr�s  rrz"ClientOptionsTests._getTargetClass���4��rc�,�|j��Sr/�r�rs r�_makeOnezClientOptionsTests._makeOne	���%�t�#�#�%�'�'rc�x��|j�}g|_g��fd�|_|jgd���|j	�g�|j	|j
d�|j	|jd�|j	|jd�|j	|jd�y)	z(Making sure config file is not required.c�&���j|�Sr/r�r�s �rr�z8ClientOptionsTests.test_no_config_file.<locals>.<lambda>s���)�"2�"2�1�"5�r)z-s�http://localhost:9001z-u�chrisrw�123��argsr�r�r�r�N)	r�rqr�rzro�interactive�	serverurl�username�password)r�instancer�s  @r�test_no_config_filez&ClientOptionsTests.test_no_config_files�����=�=�?��!����	�5��
����,��	-�	
����B�'�����-�-�q�1�����+�+�-D�E�����*�*�G�4�����*�*�E�2rc��tj�}td|z�}t|�}|j	�}||_|j
g��|j|jd�tjj|d�}|j|j|�|jj}|j|jd�|j|j d�|j|j"d�|j|j$d�|j|j|�y)	Nz�[supervisorctl]
        serverurl=http://localhost:9001
        username=chris
        password=123
        prompt=mysupervisor
        history_file=%s/sc_history
        r�T�
sc_history�mysupervisorr�r�r�)r��
gettempdirrrr�rDrzror�r{�path�join�history_filer-�
supervisorctl�promptr�r�r�)r�tempdir�sr5r�r�rFs       r�test_optionszClientOptionsTests.test_optionss���%�%�'�����
�
���a�[���=�=�?�� ������b��!�����-�-�t�4��w�w�|�|�G�\�:������.�.��=��%�%�3�3���������8�����*�*�,C�D�����)�)�7�3�����)�)�5�1�����-�-�|�<rc���td�}|j�}t|�|_|j	g��|j
j}|j|jd�y)Nzx
        [supervisorctl]
        serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
        r��http://127.0.0.1:9001�	rr�rrDrzr-r�ror��r�textr�rFs    r�3test_options_ignores_space_prefixed_inline_commentszFClientOptionsTests.test_options_ignores_space_prefixed_inline_comments4�c����
���=�=�?��&�t�n������b��!��%�%�3�3������*�*�,C�Drc���td�}|j�}t|�|_|j	g��|j
j}|j|jd�y)Nzw
        [supervisorctl]
        serverurl=http://127.0.0.1:9001	;use an http:// url to specify an inet socket
        r�r�r�r�s    r�1test_options_ignores_tab_prefixed_inline_commentszDClientOptionsTests.test_options_ignores_tab_prefixed_inline_comments?r�rc�~�td�}|j�}t|�|_|j	g��y)Nz�
        [supervisorctl]
        serverurl=http://localhost:9001 ;duplicate

        [supervisorctl]
        serverurl=http://localhost:9001 ;duplicate
        r��rr�rrDrz�rr�r�s   r�3test_options_parses_as_nonstrict_for_py2_py3_compatzFClientOptionsTests.test_options_parses_as_nonstrict_for_py2_py3_compatJs;����
���=�=�?��&�t�n������b��!rc�@�td�}t|�}|j�}tj�ddddddd�|_||_|jg�	�|j|jd
�|jj}|j|jd�|j|jd�|j|jd�|j|jd�|j|j d�y)
Na
        [supervisorctl]
        serverurl=http://localhost:%(ENV_SERVER_PORT)s
        username=%(ENV_CLIENT_USER)s
        password=%(ENV_CLIENT_PASS)s
        prompt=%(ENV_CLIENT_PROMPT)s
        history_file=/path/to/histdir/.supervisorctl%(ENV_CLIENT_HIST_EXT)s
        �johndoe�9210�someuser�passwordhere�xsupervisorz.hist)�ENV_HOME�ENV_USER�ENV_SERVER_PORT�ENV_CLIENT_USER�ENV_CLIENT_PASS�ENV_CLIENT_PROMPT�ENV_CLIENT_HIST_EXTr�Tzhttp://localhost:9210z$/path/to/histdir/.supervisorctl.hist)rrr�r�r��environ_expansionsrDrzror�r-r�r�r�r�r�r�)rr�r5r�rFs     r�(test_options_with_environment_expansionsz;ClientOptionsTests.test_options_with_environment_expansionsWs�����

���a�[���=�=�?��3;�3F�3F�3H�3<�:@�:D�:H�<I�>E�
'(��#�!������b��!�����-�-�t�4��%�%�3�3���������7�����*�*�,C�D�����)�)�:�6�����)�)�>�:�����-�-�/U�Vrc��|j�}td�}tj�}tj
j
|d�}t|d�5}|j|�ddd�	||_	|jg��tj|d��|jj}|j|j tj
j
|d��|j|j"dtj
j
|d	�z�y#1swY��xYw#tj|d��wxYw)
Nz}
        [supervisorctl]
        history_file=%(here)s/sc_history
        serverurl=unix://%(here)s/supervisord.sock
        rn�wr�T��
ignore_errorsr��unix://�supervisord.sock)r�rr��mkdtempr{r�r��open�writerDrz�shutil�rmtreer-r�ror�r�)rr�r��here�supervisord_confr�rFs       r�/test_options_supervisorctl_section_expands_herezBClientOptionsTests.test_options_supervisorctl_section_expands_hereus���=�=�?����
��
���!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�"2�H�����"��%��M�M�$�d�3��%�%�3�3������-�-�
�7�7�<�<��l�+�	-�����*�*��r�w�w�|�|�D�*<�=�=�	?�	�	��
�M�M�$�d�3�s�D5�7E�5D>�Ec�X�tjjtjjt�d�}|j�}	|j
|�|jd�y#t$r*}|jd|jdv�Yd}~yd}~wwxYw�N�nonexistent�nothing raisedzcould not find config filer�r{r�r��dirname�__file__r�r6�failr0r�r��rrr��excs    r�test_read_config_not_foundz-ClientOptionsTests.test_read_config_not_found��~���g�g�l�l�2�7�7�?�?�8�#<�m�L���=�=�?��	I�� � ��-��I�I�&�'���	I��O�O�8�C�H�H�Q�K�G�H�H��	I���"A6�6	B)�? B$�$B)c���|j�}d�}||_	|jt�|j	d�y#t
$r*}|j
d|jdv�Yd}~yd}~wwxYw)Nc�<�ttjd|z���NzPermission denied: %s��IOError�errno�EACCES��fn�modes  r�
dummy_openzBClientOptionsTests.test_read_config_unreadable.<locals>.dummy_open�����%�,�,�(?�"�(D�E�Erzexpected exception�could not read config filer�r�r�r6rrr0r�r��rr�rr
s    r�test_read_config_unreadablez.ClientOptionsTests.test_read_config_unreadable�sj���=�=�?��	F�"��
�	I�� � ��*��I�I�*�+���	I��O�O�8�C�H�H�Q�K�G�H�H��	I���&A�	A6� A1�1A6c���|j�}	|jt��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nrrz0.ini file does not include supervisorctl section�r�r6rrr0ror��rr�r
s   r�9test_read_config_no_supervisord_section_raises_valueerrorzLClientOptionsTests.test_read_config_no_supervisord_section_raises_valueerror�sd���=�=�?��	D�� � ���,��I�I�&�'���	D����S�X�X�a�[�B�
D�
D��	D���*=�	A/�A*�*A/c��td�}|j�}||_|jddg��|j	|j
d�y)Nz[supervisorctl]z--serverurl�unix:///dev/nullr�)rr�rDrzror�)rr5r�s   r�test_options_unixsocket_cliz.ClientOptionsTests.test_options_unixsocket_cli�sN��
�'�
(���=�=�?�� ������}�.@�A��B�����+�+�-?�@rc��td�}t|�}|j�}||_|j	g��|j|jd�y)Nz;[supervisorctl]
        serverurl=unix:///dev/null
        r�r%)rrr�rDrzror�)rr�r5r�s    r�"test_options_unixsocket_configfilez5ClientOptionsTests.test_options_unixsocket_configfile�sW����

���a�[���=�=�?�� ������b��!�����+�+�-?�@rN)r%r&r'rr�r�r�r�r�r�r�rrrr"r&r(r(rrr�r�sP���(�3� =�0	E�	E�
"�W�<?�,I�
I�D�A�Arr�c�*�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d-�Z/d.�Z0d/�Z1d0�Z2d1�Z3e4d2e5��d3��Z6d4�Z7d5�Z8d6�Z9d7�Z:d8�Z;d9�Z<d:�Z=d;�Z>d<�Z?d=�Z@e4d>e5eA�?��d@��ZBdA�ZCdB�ZDdC�ZEdD�ZFdE�ZGdF�ZHdG�ZIdH�ZJdI�ZKdJ�ZLdK�ZMdL�ZNdM�ZOdN�ZPdO�ZQdP�ZRdQ�ZSdR�ZTdS�ZUdT�ZVdU�ZWdV�ZXdW�ZYdX�ZZdY�Z[dZ�Z\d[�Z]d\�Z^d]�Z_d^�Z`d_�Zad`�Zbda�Zcdb�Zddc�Zedd�Zfde�Zgdf�Zhdg�Zidh�Zjdi�Zkdj�Zldk�Zmdl�Zndm�Zodn�Zpdo�Zqdp�Zrdq�Zsdr�Ztds�Zudt�Zvdu�Zwdv�Zxdw�Zydx�Zzdy�Z{dz�Z|d{�Z}d|�Z~d}�Zd~�Z�d�Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�e4d�e5gd������e4d�e5d�����d����Z�e4d�e5gd������e4d�e5d�����d����Z�d��Z�y�)��ServerOptionsTestsc��ddlm}|S)Nr)�
ServerOptions)rr,)rr,s  rrz"ServerOptionsTests._getTargetClass�r�rc�,�|j��Sr/r�r�s rr�zServerOptionsTests._makeOne�r�rc���ddlm}|j�}t�|_|jt|jd�|j|jj�|dz�y)Nr)�VERSION�
)
rr/r�rr�rK�
SystemExit�versionror�)rr/rFs   r�test_versionzServerOptionsTests.test_version�sP��.��-�-�/��!�������*�g�o�o�t�<�������0�0�2�G�d�N�Crc�&%�tddtj�iz�}ddlm}t|�}|j
�}||_|jg��|jj}|j|jtj��|j|jd�|j|jd�|j|jd�|j|j d	�|j|j"d
�|j|j$d�|j|j&d�|j|j(d�|j|j*d
�|j|j,tj��|jt/|j0�d�|j|j0ddt2j4�|j|j0ddd�|j|j0ddd�|j|j0ddd�|j|j0ddd�|j|j6d�|j|j8d�|j|j:d�|j|j6d�|jt/|j<�d	�|j|j>tAd���|j<d}|j|jBd�|j|jDd�|jt/|jF�d�|jFd}|j|jBd�|j|jHd�|j|jDd�|j|jJd�|j|jL|jN�|j|jPd	�|j|jRd�|j|jTd�|j|jVd�|j|jXtZj\�|j|j^d	�|j|j`d �|j|jbd �|j|jd|jgd!��|j|jhd�|j|jjdg�|j|jd"�|j|jd#�|j|j>tAd���|j<d}|j|jBd$�|j|jDd#�|jt/|jF�d�|jFd}	|j|	jBd$�|j|	jHd�|j|	jDd#�|j|	jJd�|j|	jLd �|j|	jTd�|j|	jVd%�|j|	jXtZjl�|j|	j`d �|j|	jbd �|j|	jdd&�|j|	jhd#�|j|	jjdg�|j|	jd�|j<d#}
|j|
jBd'�|j|
jDd(�|jt/|
jF�d�|
jFd}|j|jBd)�|j|jHd�|j|jDd(�|j|jJd�|j|jL|jn�|j|jTd�|j|jV|jp�|j|jd|jgd!��|j|jhd�|j|jjgd*��|j|jXtZjl�|j|j`d�|j|jbd�|j<d(}|j|jBd+�|j|jDd,�|jt/|jF�d#�|jFd}
|j|
jBd-�|j|
jHd�|j|
jDd,�|j|
jJd�|j|
jL|jN�|j|
jTd�|j|
jV|jp�|j|
jd|jgd!��|j|
jhd�|j|
jjdg�|j|
jXtZjl�|j|
j`d �|j|
jbd �|j|
jd�|jFd}|j|jBd.�|j|jHd�|j|jDd,�|j|jJd�|j|jL|jN�|j|jTd�|j|jV|jp�|j|jd|jgd!��|j|jhd�|j|jjdg�|j|jXtZjl�|j|j`d �|j|jbd �|j|jd�|j<d,}|j|jBd/�|j|jDd	�|jt/|jF�d#�|jFd}|j|jBd0�|j|jd1�|jFd}|j|jBd2�|j|jd3�trjtjwtsjx��}|j|jTd�|j|jzd�|j|jtj��|j|jd�|j|jtrjtj}|d��|j|jd�|j|j d	�|j|j"d
�|j|j$trjtj}|d��|j|j&d�|j|j(d�|j|j~d�|j|j*d
�|j|j,tj��|jt/|j0�d�|j|j0ddt2j4�|j|j0ddd�|j|j0ddd�|j|j0ddd�|j|j0ddd�|j|j6d�|j|j8d�|j|j:d�y)4Na�
        [supervisord]
        directory=%(tempdir)s
        backofflimit=10
        user=root
        umask=022
        logfile=supervisord.log
        logfile_maxbytes=1000MB
        logfile_backups=5
        loglevel=error
        pidfile=supervisord.pid
        nodaemon=true
        silent=true
        identifier=fleeb
        childlogdir=%(tempdir)s
        nocleanup=true
        minfds=2048
        minprocs=300
        environment=FAKE_ENV_VAR=/some/path

        [inet_http_server]
        port=127.0.0.1:8999
        username=chrism
        password=foo

        [program:cat1]
        command=/bin/cat
        priority=1
        autostart=true
        user=root
        stdout_logfile=/tmp/cat.log
        stopsignal=KILL
        stopwaitsecs=5
        startsecs=5
        startretries=10
        directory=/tmp
        umask=002

        [program:cat2]
        priority=2
        command=/bin/cat
        autostart=true
        autorestart=false
        stdout_logfile_maxbytes = 1024
        stdout_logfile_backups = 2
        stdout_logfile = /tmp/cat2.log

        [program:cat3]
        priority=3
        process_name = replaced
        command=/bin/cat
        autorestart=true
        exitcodes=0,1,127
        stopasgroup=true
        killasgroup=true

        [program:cat4]
        priority=4
        process_name = fleeb_%%(process_num)s
        numprocs = 2
        command = /bin/cat
        autorestart=unexpected

        [program:cat5]
        priority=5
        process_name = foo_%%(process_num)02d
        numprocs = 2
        numprocs_start = 1
        command = /bin/cat
        directory = /some/path/foo_%%(process_num)02d
        r�r��	datatypesr���supervisord.logi�>��(�supervisord.pidT�fleebr��family�hostz	127.0.0.1�porti'#r��chrismr�r�ii,�
/some/path��FAKE_ENV_VAR�cat1�/bin/cat�
�/tmp/cat.logF�50MB�/tmpr��cat2z
/tmp/cat2.log��cat3��replaced)rr���cat4��fleeb_0�fleeb_1�cat5�foo_01z/some/path/foo_01�foo_02z/some/path/foo_02)@rr�r��
supervisorr6rr�rDrzr-�supervisordro�	directory�umask�logfile�logfile_maxbytes�logfile_backups�loglevel�pidfile�nodaemon�silent�
identifier�childlogdirrp�server_configs�socket�AF_INET�	nocleanup�minfds�minprocs�process_group_configs�environment�dictr<�priority�process_configs�command�	autostart�autorestart�RestartWhenExitUnexpected�	startsecs�startretries�uid�stdout_logfile�
stopsignal�signal�SIGKILL�stopwaitsecs�stopasgroup�killasgroup�stdout_logfile_maxbytes�	byte_size�stdout_logfile_backupsr��SIGTERM�RestartUnconditionally�	Automaticr{r��abspath�getcwd�gidr��
passwdfile)rr�r6r5r�rFrD�proc1rJ�proc2rL�proc3rP�proc4_a�proc4_brT�proc5_a�proc5_br�s                   rr�zServerOptionsTests.test_options�sD���F�L��,�,�.�/�MF0�F
1��P	)�
�a�[���=�=�?�� ������b��!��%�%�1�1������*�*�H�,?�,?�,A�B��������-�������*;�<�����1�1�3E�F�����0�0�!�4�����)�)�2�.�������*;�<�����)�)�4�0��������.�����+�+�W�5�����,�,�h�.A�.A�.C�D�����W�3�3�4�a�8�����/�/��2�8�<�f�n�n�M�����/�/��2�6�:�K�H�����/�/��2�6�:�D�A�����/�/��2�:�>��I�����/�/��2�:�>��F�����*�*�D�1��������.�����)�)�3�/�����*�*�D�1�����W�:�:�;�Q�?�����,�,�d��.M�N��,�,�Q�/��������F�+��������*�����T�1�1�2�A�6��$�$�Q�'��������V�,�������
�3��������+�������$�/�����*�*�I�,O�,O�P�������!�,�����+�+�R�0�������A�&�����-�-�~�>�����)�)�6�>�>�:�����+�+�Q�/�����*�*�E�2�����*�*�E�2�����6�6�"�,�,�V�4�	6�����5�5�r�:�������1�#�.�������&�1�������a�(�����*�*�D�l�,K�L��,�,�Q�/��������F�+��������*�����T�1�1�2�A�6��$�$�Q�'��������V�,�������
�3��������+�������$�/�����*�*�E�2�������D�)�����-�-��?�����)�)�6�>�>�:�����*�*�E�2�����*�*�E�2�����6�6��=�����5�5�q�9�������1�#�.�������$�/��,�,�Q�/��������F�+��������*�����T�1�1�2�A�6��$�$�Q�'��������Z�0�������
�3��������+�������$�/�����*�*�I�,L�,L�M�������D�)�����-�-�y�/B�/B�C�����6�6�"�,�,�V�4�	6�����5�5�r�:�������)�4�����)�)�6�>�>�:�����*�*�D�1�����*�*�D�1��,�,�Q�/��������F�+��������*�����T�1�1�2�A�6��&�&�q�)��������y�1�������*�5�����)�)�1�-�����*�*�D�1�����,�,�"�<�<�	>�������d�+�����/�/��1D�1D�E�����8�8�"�,�,�V�4�	6�����7�7��<�����*�*�Q�C�0�����+�+�V�^�^�<�����,�,�e�4�����,�,�e�4�����*�*�D�1��&�&�q�)��������y�1�������*�5�����)�)�1�-�����*�*�D�1�����,�,�"�<�<�	>�������d�+�����/�/��1D�1D�E�����8�8�"�,�,�V�4�	6�����7�7��<�����*�*�Q�C�0�����+�+�V�^�^�<�����,�,�e�4�����,�,�e�4�����*�*�D�1��,�,�Q�/��������F�+��������*�����T�1�1�2�A�6��&�&�q�)��������x�0�����*�*�,?�@��&�&�q�)��������x�0�����*�*�,?�@��w�w���r�y�y�{�+��������q�)�������q�)�����+�+�X�-@�-@�-B�C��������.�����)�)�2�7�7�<�<��=N�+O�P�����2�2�4F�G�����1�1�1�5�����*�*�B�/�����)�)�2�7�7�<�<��=N�+O�P�����*�*�D�1�������$�/�����,�,�d�3�����,�,�g�6�����-�-�x�/B�/B�/D�E�����X�4�4�5�q�9�����0�0��3�H�=�v�~�~�N�����0�0��3�F�;�[�I�����0�0��3�F�;�T�B�����0�0��3�J�?��J�����0�0��3�J�?��G�����+�+�T�2�������$�/�����*�*�C�0rc��td�}|j�}t|�|_|j	g��|j
j}|j|jd�|j|jd�y)Nz�
        [supervisord]
        logfile=/tmp/supervisord.log ;(main log file;default $CWD/supervisord.log)
        minfds=123 ; (min. avail startup file descriptors;default 1024)
        r�z/tmp/supervisord.log�{)
rr�rrDrzr-rXror[rhr�s    rr�zFServerOptionsTests.test_options_ignores_space_prefixed_inline_comments�su����
��
�=�=�?��&�t�n������b��!��%�%�1�1��������*@�A��������-rc���td�}|j�}t|�|_|j	g��|j
j}|j|jd�y)Nz�
        [supervisord]
        logfile=/tmp/supervisord.log	;(main log file;default $CWD/supervisord.log)
        minfds=123	; (min. avail startup file descriptors;default 1024)
        r�r�)	rr�rrDrzr-rXrorhr�s    rr�zDServerOptionsTests.test_options_ignores_tab_prefixed_inline_comments�s`����
��
�=�=�?��&�t�n������b��!��%�%�1�1���������-rc�~�td�}|j�}t|�|_|j	g��y)Nz�
        [supervisord]

        [program:duplicate]
        command=/bin/cat

        [program:duplicate]
        command=/bin/cat
        r�r�r�s   rr�zFServerOptionsTests.test_options_parses_as_nonstrict_for_py2_py3_compat�s;����
���=�=�?��&�t�n������b��!rc��td�}|j�}t|�|_|j	g��|j
j}|jt|j�d�|jd}|jt|j�d�|jd}|jt|j�d�|j|j|ju�td�}t|�|_|jd��|j
j}|jt|j�d�|jd}|jt|j�d�|jd}|j|jd	�|j|jd
�|j|j|ju�|jd}|jt|j�d�|jd}|j|jd�|j|jd�y)
Nz�        [supervisord]
        user=root

        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/dog

        [program:four]
        command = /bin/sheep

        [group:thegroup]
        programs = one,two
        r�r�rr�z�        [supervisord]
        user=root

        [program:one]
        command = /bin/cat

        [program:three]
        command = /bin/pig

        [group:thegroup]
        programs = three
        Fr��onerE�threez/bin/pig)rr�rrDrzr-rXrorprjrnr�rr<ro)rr�r��section�cat�procs      r�test_reloadzServerOptionsTests.test_reload�s%����
��"�=�=�?��&�t�n������b��!��%�%�1�1������W�:�:�;�Q�?��+�+�A�.������S�0�0�1�1�5��+�+�A�.������S�0�0�1�1�5�����5�5� �6�6�7�	8���
��'�t�n��������/��%�%�1�1������W�:�:�;�Q�?��+�+�A�.������S�0�0�1�1�5��"�"�1�%��������E�*�������z�2�����5�5� �6�6�7�	8��+�+�A�.������S�0�0�1�1�5��"�"�1�%��������G�,�������z�2rc�`�|j�}d}|g|_|g|_|g|_t	d�}t|�|_|jg��|j||jv�|j||jv�|j||jv�y)Nz Message from a prior config read�b        [supervisord]
        user=root

        [program:cat]
        command = /bin/cat
        r�)	r��parse_criticals�parse_warnings�parse_infosrrrDrz�assertFalse)rr��old_msgr�s    r�!test_reload_clears_parse_messagesz4ServerOptionsTests.test_reload_clears_parse_messages3s����=�=�?��4��$+�9�� �#*�)��� '�y�����
��'�t�n������b��!�����H�$<�$<�<�=�����H�$;�$;�;�<�����H�$8�$8�8�9rc���|j�}d}|g|_td�}t|�|_|jg��|j
||jv�y)NzInfo from a prior config readr�r�)r��infosrrrDrzr�r�)rr��old_infor�s    r�test_reload_clears_parse_infosz1ServerOptionsTests.test_reload_clears_parse_infosGsb���=�=�?��2��"������
��'�t�n������b��!�����X�%9�%9�9�:rc�X�tjjtjjt�d�}|j�}	|j
|�|jd�y#t$r*}|jd|jdv�Yd}~yd}~wwxYwrrr	s    rrz-ServerOptionsTests.test_read_config_not_foundWrr
c���|j�}d�}||_	|jt�|j	d�y#t
$r*}|j
d|jdv�Yd}~yd}~wwxYw)Nc�<�ttjd|z��rrrs  rrzBServerOptionsTests.test_read_config_unreadable.<locals>.dummy_openbrrrrrrrs    rrz.ServerOptionsTests.test_read_config_unreadable`sj���=�=�?��	F�"��
�	I�� � ��*��I�I�&�'���	I��O�O�8�C�H�H�Q�K�G�H�H��	I�rc���|j�}tjd��5}	|jd�|j	�|j|j�|jd�ddd�y#t$rT}|jd|jdv�|j|j|jdv�Yd}~�ad}~wwxYw#1swYyxYw)N�w+�rz[supervisord]
junkr�contains parsing errors:r)r�r�r�r��flushr6r<rr0r�r�)rr�r�r
s    r�8test_read_config_malformed_config_file_raises_valueerrorzKServerOptionsTests.test_read_config_malformed_config_file_raises_valueerrorls����=�=�?��
�
(�
(�d�
3�	7�q�
7����-�.����	��$�$�Q�V�V�,��	�	�*�+�	7�	7���
7���� :�c�h�h�q�k� I�J�������#�(�(�1�+� 5�6�6��
7��
	7�	7�s0�C�A
A?�?	C�A
C�C�C�C�C(c��|j�}tjjtjj	t
�dd�}t
d|z�}	|jt|��|jd�y#t$r,}|j|jdd|z�Yd}~yd}~wwxYw)Nrr8z1        [supervisord]
        logfile=%s
        rrz9The directory named as part of the path %s does not exist)
r�r{r�r�rrrr6rrr0ror�)rr��logfile_with_nonexistent_dirr�r
s     r�1test_read_config_logfile_with_nonexistent_dirpathzDServerOptionsTests.test_read_config_logfile_with_nonexistent_dirpathys����=�=�?��')�w�w�|�|��G�G�O�O�H�%�}��(�$���+�+�,��	�� � ��$��0��I�I�&�'���	����S�X�X�a�[�K�,�-�
�
��	�s�"+B�	C�"B>�>Cc���|j�}	|jt��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nrrz..ini file does not include supervisord sectionr r!s   rr"zLServerOptionsTests.test_read_config_no_supervisord_section_raises_valueerror�sd���=�=�?��	B�� � ���,��I�I�&�'���	B����S�X�X�a�[�@�
B�
B��	B�r#c��|j�}td�}	|jt|��|j	d�y#t
$r)}|j
|jdd�Yd}~yd}~wwxYw)NzD        [supervisord]

        [include]
        ;no files=
        rrz5.ini file has [include] section, but no files setting)r�rr6rrr0ror��rr�r�r
s    r�8test_read_config_include_with_no_files_raises_valueerrorzKServerOptionsTests.test_read_config_include_with_no_files_raises_valueerror�su���=�=�?����
��	I�� � ��$��0��I�I�&�'���	I����S�X�X�a�[�G�
I�
I��	I�s�+A	�		A;�A6�6A;c��|j�}td�}|jt|��|j	|j
dg�y)NzM        [supervisord]

        [include]
        files=nonexistent/*
        z-No file matches via include "./nonexistent/*")r�rr6rror�)rr�r�s   r�<test_read_config_include_with_no_matching_files_logs_warningzOServerOptionsTests.test_read_config_include_with_no_matching_files_logs_warning�sM���=�=�?����
��	���X�d�^�,�����0�0�I�J�	Lrc�R�tj�}tjj	|d�}tj
|�tjj	|d�}t
d|�d|�d��}t|d�5}|j|�ddd�tjj	|d�}t|d�5}|jd�ddd�tjj	|d	�}t|d�5}|jd
�ddd�|j�}	|j|�tj|d��|jj}	|jt!|	j"�d
�d|z}
|j%|
|j&v�d|z}
|j%|
|j&v�y#1swY��OxYw#1swY��xYw#1swY��xYw#tj|d��wxYw)N�conf.drn�7        [supervisord]

        [include]
        files=z/conf.d/*.conf z/conf.d/*.ini
        r��a.conf�[inet_http_server]
port=8000
za.iniz"[unix_http_server]
file=/tmp/file
Tr�r��'Included extra file "%s" during parsing)r�r�r{r�r��mkdirrr�r�r�r6r�r�r-rXrorprdr�r�)rr�conf_dr�r�r��	conf_file�ini_filer�rFr�s           r�*test_read_config_include_reads_extra_filesz=ServerOptionsTests.test_read_config_include_reads_extra_files�s����"�"�$�������g�x�0��
������7�7�<�<��1C�D���
��!�"���"�C�
(�	�A�
�G�G�D�M�	��G�G�L�L���2�	�
�)�S�
!�	7�Q�
�G�G�5�6�	7��7�7�<�<���0��
�(�C�
 �	<�A�
�G�G�:�;�	<��=�=�?��	7�� � �!1�2��M�M�'��6��%�%�1�1������W�3�3�4�a�8�7�)�C������x�3�3�3�4�7�(�B������x�3�3�3�4�+	�	��	7�	7��	<�	<��
�M�M�'��6�s0�G'�G4�H�?H
�'G1�4G>�H
�
H&c	��tj�}tjj	|d�}tj
|�tjj	|d�}t
d|z�}t|d�5}|j|�ddd�ddl	m
}|dd}t|�D]R}tjj	|d|z�}	t|	d�5}|jd	|�d
|�d��ddd��T|j�}
	|
j|�tj|d�
�g}t!|�D]9}tjj	|d|z�}	|j#d|	z��;|j%|
j&|�y#1swY��xYw#1swY��xYw#tj|d�
�wxYw)Nr�rn�P        [supervisord]

        [include]
        files=%s/conf.d/*.conf
        r�r)�letters��%s.confz	[program:z]
command=/bin/r0Tr�r�)r�r�r{r�r�r�rr�r��supervisor.compatr��reversedr�r6r�r��sortedr�ror�)rrr�r�r�r�r��a_z�letter�filenamer��
expected_msgss            r�4test_read_config_include_reads_files_in_sorted_orderzGServerOptionsTests.test_read_config_include_reads_files_in_sorted_order�s����"�"�$�������g�x�0��
������7�7�<�<��1C�D����
�����"�C�
(�	�A�
�G�G�D�M�	�	.��c�r�l���s�m�	@�F��w�w�|�|�F�I��,>�?�H��h��$�
@�����/5�v�?�@�
@�
@�	@��=�=�?��	7�� � �!1�2��M�M�'��6��
��S�k�	F�F��w�w�|�|�F�I��,>�?�H�� � �9�H�D�
F�	F�	
����-�-�}�=�+	�	��
@�
@��
�M�M�'��6�s$�F(�&F5�G�(F2�5F?	�Gc��tj�}tjj	|d�}tj
|�tjj	|d�}t
d|z�}t|d�5}|j|�ddd�tjj	|d�}t|d�5}|jd�ddd�|j�}	|j|�|jd�t!j"|d��y#1swY��xYw#1swY�`xYw#t$rl}|jd|jd	v�|j||jd	v�d
|z}	|j|	|jv�Yd}~��d}~wwxYw#t!j"|d��wxYw)
Nr�rnr�r�r�z[inet_http_server]
junk
rr�rr�Tr�)r�r�r{r�r�r�rr�r�r�r6rr0r�r�r�r�r�)
rrr�r�r�r��malformed_filer�r
r�s
          r�-test_read_config_include_extra_file_malformedz@ServerOptionsTests.test_read_config_include_extra_file_malformed�s����"�"�$�������g�x�0��
������7�7�<�<��1C�D����
�����"�C�
(�	�A�
�G�G�D�M�	������f�h�7��
�.�#�
&�	2�!�
�G�G�0�1�	2��=�=�?��		7�� � �!1�2��I�I�&�'�
�M�M�'��6�#	�	��	2�	2���	9��O�O�6�#�(�(�1�+�E�F��O�O�N�c�h�h�q�k�9�:�;�n�L�C��O�O�C�8�#7�#7�7�8�8��		9��
�M�M�'��6�sC�D/�
D;�5"E�/D8�;E�	F<�A"F7�2F?�7F<�<F?�?Gc��tj�}tjj	|d�}tj
|�tjj	|d�}t
d|�dd�d��}t|d�5}|j|�ddd�tjj	|dtj�z�}t|d�5}|jd	�ddd�|j�}	|j|�tj|d
��|jj }|j#t%|j&�d�d
|z}	|j)|	|j*v�y#1swY��xYw#1swY��xYw#tj|d
��wxYw)Nr�rnr�z/conf.d/z%(host_node_name)sz.conf
        r�r�r�Tr�r�r�)r�r�r{r�r�r�rr�r��platform�noder�r6r�r�r-rXrorprdr�r�)
rrr�r�r�r�r�r�rFr�s
          r�/test_read_config_include_expands_host_node_namezBServerOptionsTests.test_read_config_include_expands_host_node_namesh���"�"�$�������g�x�0��
������7�7�<�<��1C�D���
�,�.�/���"�C�
(�	�A�
�G�G�D�M�	��G�G�L�L���X�]�]�_�)D�E�	�
�)�S�
!�	7�Q�
�G�G�5�6�	7��=�=�?��	7�� � �!1�2��M�M�'��6��%�%�1�1������W�3�3�4�a�8�7�)�C������x�3�3�3�4�	�	��	7�	7��
�M�M�'��6�s$�F�#F �F,�F� F)�,Gc�,�tjjtjjtjj	t
��dd�}tjj	|�}tjj|d�}|j
�}||_|jd�|jj}|j|j|�|j|j|�y)N�fixtureszinclude.conf�exampleT)r{r�r�r�rrr�rD�process_config_filer-rXror[rc)r�conf�	root_here�include_here�parserr�s      r�%test_read_config_include_expands_herez8ServerOptionsTests.test_read_config_include_expands_here2s����w�w�|�|��G�G�O�O�B�G�G�O�O�H�5�6�
�����G�G�O�O�D�)�	��w�w�|�|�I�y�9������� ����"�"�4�(��#�#�/�/��������)�4�����,�,�l�;rc��ddlm}	|ddd�td��#t$r)}|j	|j
dd�Yd}~yd}~wwxYw)Nr)�readFilez	/notthererFzDidn't raise�FAILED)rr��AssertionErrorr0ror�)rr�rNs   r�test_readFile_failedz'ServerOptionsTests.test_readFile_failed?sP��/�	1��[�!�R�(�!��0�0���	5����T�Y�Y�q�\�8�4�4��	5�s�
�	A�A
�
Ac��|j�}|jtj�|j	��yr/)r�ror{�getpid�get_pid�rr�s  r�test_get_pidzServerOptionsTests.test_get_pidHs,���=�=�?���������h�&6�&6�&8�9rc���|j�}|jjtjd�|jjtj
d�|j
|j�tj�|j
|j�tj
�|j
|j�d�yr/)r��signal_receiver�receiverxr��SIGCHLDro�
get_signalr�s  r�,test_get_signal_delegates_to_signal_receiverz?ServerOptionsTests.test_get_signal_delegates_to_signal_receiverLs����=�=�?��� � �(�(�����>�� � �(�(�����>�����,�,�.����?�����,�,�.����?�����,�,�.��5rc�n�|j�}ddlm}|j||jddd�y)Nr)�NotFoundz
/not/there)r�rr�rK�check_execv_args)rr�r�s   r�'test_check_execv_args_cant_find_commandz:ServerOptionsTests.test_check_execv_args_cant_find_commandTs/���=�=�?��/����(�H�$=�$=�&��d�	4rc	��|j�}ddlm}|j||jddgtjd��y)Nr��
NotExecutablez/etc/passwdz
etc/passwd�r�rr�rKr�r{�stat�rr�r�s   r�#test_check_execv_args_notexecutablez6ServerOptionsTests.test_check_execv_args_notexecutableZs<���=�=�?��4����-�"�3�3�]�'�.�"�'�'�-�*@�	Brc	��|j�}ddlm}|j||jddgtjd��y)Nrr��/r�r�s   r�test_check_execv_args_isdirz.ServerOptionsTests.test_check_execv_args_isdiras:���=�=�?��4����-�"�3�3�S��%������	/rc����|j�}g��fd�}||_td�|_ddg}|j	|��|jt
��d�|j�dd|z�y)	Nc�(���j|�yr/r���message�recorders �r�record_usagezSServerOptionsTests.test_realize_positional_args_not_supported.<locals>.record_usagel�����O�O�G�$r�
[supervisord]r�r�r�r�rz*positional arguments are not supported: %s�r��usagerrDrzrorp)rr�rr�rs    @r�*test_realize_positional_args_not_supportedz=ServerOptionsTests.test_realize_positional_args_not_supportedhsw����=�=�?����	%�%���$�_�5����u�~�����d��#�����X���*�����!��8�4�?�	Arc����|j�}g��fd�}||_td�|_|j	dg��|jt
��d�|j�dd�y)Nc�(���j|�yr/r�r�s �rrzBServerOptionsTests.test_realize_getopt_error.<locals>.record_usage{rrrz--bad=1r�r�rzoption --bad not recognizedr)rr�rrs   @r�test_realize_getopt_errorz,ServerOptionsTests.test_realize_getopt_errorwsh����=�=�?����	%�%���$�_�5������y�k��*�����X���*�����!��&C�Drc��td�}|j�}t|�|_|j	ddg��|j|jd�y)NzC
        [supervisord]
        identifier=from_config_file
        z-i�	from_argsr�)rr�rrDrzrorbr�s   r�)test_realize_prefers_identifier_from_argsz<ServerOptionsTests.test_realize_prefers_identifier_from_args�sV����
���=�=�?��&�t�n������t�[�1��2�����,�,�k�:rc�F�|j�}td�}ddlm}|�}|j	|�t|�|_|jt|��|jg��|jj}|j|jddtj�|j|jddd�|j|jddd	�|j|jdd
d�y)Nz�        [unix_http_server]
        file=/tmp/supvtest.sock
        username=johndoe
        password=passwordhere

        [supervisord]
        ; ...
        r��UnhosedConfigParserr�r=�file�/tmp/supvtest.sock�chmod��chown)���r�r�rrr�read_stringrrDr6rzr-rXrordre�AF_UNIX�rr�r�rr�rFs      r�test_options_afunixz&ServerOptionsTests.test_options_afunix�s����=�=�?����
��	;�$�&�����4� �&�t�n������X�d�^�,����b��!��%�%�1�1������/�/��2�8�<�f�n�n�M�����/�/��2�6�:�<P�Q�����/�/��2�7�;�S�A�����/�/��2�7�;�W�Erc��|j�}td�}ddlm}|�}|j	|�t|�|_|jt|��|jg��|jj}|j|jddtj�|j|jddd�|j|jddd	�y)
Nz�        [unix_http_server]
        file=/tmp/supvtest.sock
        username=johndoe
        password=passwordhere
        chmod=0755

        [supervisord]
        ; ...
        rrr�r=rrri�rrs      r�&test_options_afunix_chxxx_values_validz9ServerOptionsTests.test_options_afunix_chxxx_values_valid�s����=�=�?���	�	
��	;�$�&�����4� �&�t�n������X�d�^�,����b��!��%�%�1�1������/�/��2�8�<�f�n�n�M�����/�/��2�6�:�<P�Q�����/�/��2�7�;�S�Arc��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nzc        [supervisord]

        [unix_http_server]
        file=/tmp/file
        chmod=NaN
        rrzInvalid chmod value NaN�	r�rrrDr6rr0ror�r�s    r�test_options_afunix_chmod_badz0ServerOptionsTests.test_options_afunix_chmod_bad�s~���=�=�?����
��'�t�n���	+�� � ��$��0��I�I�&�'���	+����S�X�X�a�[�)�
+�
+��	+���+A�	B�"B�Bc��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nzs        [supervisord]

        [unix_http_server]
        file=/tmp/file
        chown=thisisnotavaliduser
        rrz+Invalid sockchown value thisisnotavaliduserrr�s    r�test_options_afunix_chown_badz0ServerOptionsTests.test_options_afunix_chown_bad�s~���=�=�?����
��'�t�n���	?�� � ��$��0��I�I�&�'���	?����S�X�X�a�[�=�
?�
?��	?�r!c��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)NzL        [supervisord]

        [unix_http_server]
        ;no file=
        rrz,section [unix_http_server] has no file valuerr�s    r�test_options_afunix_no_filez.ServerOptionsTests.test_options_afunix_no_file�����=�=�?����
��'�t�n���	@�� � ��$��0��I�I�&�'���	@����S�X�X�a�[�>�
@�
@��	@�r!c��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nz�        [supervisord]

        [unix_http_server]
        file=/tmp/supvtest.sock
        username=usernamehere
        ;no password=
        chmod=0755
        rr��Section [unix_http_server] contains incomplete authentication: If a username or a password is specified, both the username and password must be specifiedrr�s    r�-test_options_afunix_username_without_passwordz@ServerOptionsTests.test_options_afunix_username_without_password�����=�=�?����
��'�t�n���	 �� � ��$��0��I�I�&�'���	 ����S�X�X�a�[��
 �
 ��	 �r!c��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nz�        [supervisord]

        [unix_http_server]
        file=/tmp/supvtest.sock
        ;no username=
        password=passwordhere
        chmod=0755
        rrr(rr�s    r�-test_options_afunix_password_without_usernamez@ServerOptionsTests.test_options_afunix_password_without_usernamer*r!c��|j�}td�}tj�}tj
j
|d�}t|d�5}|j|�ddd�	||_	|jg��tj|d��|jj}|jd}|j!|dt"j$�|j!|d	tj
j
|d
��y#1swY��xYw#tj|d��wxYw)Nza        [supervisord]

        [unix_http_server]
        file=%(here)s/supervisord.sock
        rnr�r�Tr�rr=rr�)r�rr�r�r{r�r�r�r�rDrzr�r�r-rXrdrorer)rr�r�r�r�r�rF�
serverconfs        r�%test_options_afunix_file_expands_herez8ServerOptionsTests.test_options_afunix_file_expands_heres���=�=�?����
�����!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�"2�H�����"��%��M�M�$�d�3��%�%�1�1���+�+�A�.�
�����H�-�v�~�~�>�����F�+��G�G�L�L��1�2�	4�	�	��
�M�M�$�d�3�s�D#�7D/�#D,�/Ec��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nz�        [supervisord]

        [inet_http_server]
        file=/tmp/supvtest.sock
        username=usernamehere
        ;no password=
        chmod=0755
        rr��Section [inet_http_server] contains incomplete authentication: If a username or a password is specified, both the username and password must be specifiedrr�s    r�-test_options_afinet_username_without_passwordz@ServerOptionsTests.test_options_afinet_username_without_password4r*r!c��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nzn        [supervisord]

        [inet_http_server]
        password=passwordhere
        ;no username=
        rrr1rr�s    r�-test_options_afinet_password_without_usernamez@ServerOptionsTests.test_options_afinet_password_without_usernameJs����=�=�?����
��'�t�n���	 �� � ��$��0��I�I�&�'���	 ����S�X�X�a�[��
 �
 ��	 �r!c��|j�}td�}t|�|_	|j	t|��|jd�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)NzL        [supervisord]

        [inet_http_server]
        ;no port=
        rrz,section [inet_http_server] has no port valuerr�s    r�test_options_afinet_no_portz.ServerOptionsTests.test_options_afinet_no_port^r&r!c��tjd��5}|j}|jd�ddd�|j	�}d|_Gd�d�}tjd�|�fg|_d|_	|j�|jtjj|��y#1swY��xYw)	NF��delete�fooTc��eZdZy)�=ServerOptionsTests.test_cleanup_afunix_unlink.<locals>.ServerNr$r(rr�Serverr<ts��rr=�r=rr�)r�r�r<r�r��unlink_socketfilesrer�httpserversr_�cleanupr�r{r��exists�rr�rr�r=s     r�test_cleanup_afunix_unlinkz-ServerOptionsTests.test_cleanup_afunix_unlinkns���
�
(�
(��
6�	�!����B�
�G�G�F�O�	��=�=�?��&*��#�	�	�+1�>�>�"�!E�!'��!+� ,�������������������+�,�	�	�s�C�C
c�@�tjd��5}|j}|jd�ddd�	|j	�}Gd�d�}t
jd�|�fg|_d|_d|_	|j�|jtjj|��	tj|�y#1swY��xYw#t $rYywxYw#	tj�w#t $rYwwxYwxYw)NFr8r:c��eZdZy)�?ServerOptionsTests.test_cleanup_afunix_nounlink.<locals>.ServerNr$r(rrr=rG����rr=r>r�)r�r�r<r�r�rerr@r_r?rAr�r{r�rB�unlink�OSErrorrCs     r�test_cleanup_afunix_nounlinkz/ServerOptionsTests.test_cleanup_afunix_nounlink|s���
�
(�
(��
6�	�!����B�
�G�G�F�O�	�	��}�}��H�
�
�/5�~�~�b�%I�%+�X�%/�$0�H� �!�H��*/�H�'������O�O�B�G�G�N�N�2�.�/�
��	�	�"�
�	�	�� �
��
��
��	�	�"�
���
��
�sM�C�BC6�C'�C$�'	C3�2C3�6D�8D�
D�	D�D�D�Dc���tjjtjjt�d�}tjd��5}|j}|jd�ddd�	|j�}d|_
Gd�d�}tj|d�|�ftjd�|�fg|_
d	|_|j�|j!tjj#|��	tj$|�y#1swY��xYw#t&$rYywxYw#	tj$�w#t&$rYwwxYwxYw)
N�notfoundFr8r:Tc��eZdZy)�MServerOptionsTests.test_cleanup_afunix_ignores_oserror_enoent.<locals>.ServerNr$r(rrr=rO�rHrr=r>r�)r{r�r�rrr�r�r<r�r�r?rerr@r_rAr�rBrIrJ)rrMr��
socketnamer�r=s      r�*test_cleanup_afunix_ignores_oserror_enoentz=ServerOptionsTests.test_cleanup_afunix_ignores_oserror_enoent�s(���7�7�<�<������� 9�:�F��
�
(�
(��
6�	�!����J�
�G�G�F�O�	�	��}�}��H�*.�H�'�
�
�#�N�N�H�=�v�x�H�"�N�N�J�?���J�$�H� � "�H���������R�W�W�^�^�J�7�8�
��	�	�*�%�#	�	��$�
��
��
��	�	�*�%���
��
�sO�D5�?BE�E�5D>�	E
�E
�E7�E(�'E7�(	E4�1E7�3E4�4E7c�R�tjd��5}|j}|jd�ddd�	|j	�}|_t
�|_|j�|j|j�|j�|jtjj|��	tj |�y#1swY��xYw#t"$rYywxYw#	tj �w#t"$rYwwxYwxYw�NFr8�2)r�r�r<r�r�r_r
�logger�
write_pidfiler��unlink_pidfilerAr�r{r�rBrIrJ�rr�r_r�s    r�test_cleanup_removes_pidfilez/ServerOptionsTests.test_cleanup_removes_pidfile�s���
�
(�
(��
6�	�!��f�f�G�
�G�G�D�M�	�	��}�}��H�&�H��)�m�H�O��"�"�$��O�O�H�3�3�4��������R�W�W�^�^�G�4�5�
��	�	�'�"�	�	���
��
��
��	�	�'�"���
��
�sM�C$�BC?�C0�$C-�0	C<�;C<�?D&�D�D&�	D#� D&�"D#�#D&c���tjjtjjt�d�}|j�}||_|j�y)NrM)r{r�r�rrr�r_rA)rrMr�s   r�+test_cleanup_pidfile_ignores_oserror_enoentz>ServerOptionsTests.test_cleanup_pidfile_ignores_oserror_enoent�sB���7�7�<�<������� 9�:�F���=�=�?��#������rc��tjd��5}|j}|jd�ddd�	|j	�}|_|j
|j�|j�|jtjj|��	tj|�y#1swY��xYw#t$rYywxYw#	tj�w#t$rYwwxYwxYw)NFr8s1234)r�r�r<r�r�r_r�rWrAr�r{r�rBrIrJrXs    r�=test_cleanup_does_not_remove_pidfile_from_another_supervisordzPServerOptionsTests.test_cleanup_does_not_remove_pidfile_from_another_supervisord�s���
�
(�
(��
6�	�!��f�f�G�
�G�G�G��	�
	��}�}��H� '�H�����X�4�4�5������O�O�B�G�G�N�N�7�3�4�
��	�	�'�"�	�	�� �
��
��
��	�	�'�"���
��
�sM�C�A0C �/C�C�	C�C� D�"C8�7D�8	D�D�D�Dc��tjd��5}|j}|jd�ddd�	|j	�}|_t
i�}||_|j|j�|j�|j|j�	tj|�y#1swY��xYw#t$rYywxYw#	tj�w#t$rYwwxYwxYwrS)r�r�r<r�r�r_r�pollerr��closedrAr�r{rIrJ)rr�r_r�r_s     r�test_cleanup_closes_pollerz-ServerOptionsTests.test_cleanup_closes_poller�s���
�
(�
(��
6�	�!��f�f�G�
�G�G�D�M�	�
	��}�}��H�&�H�� ��_�F�$�H�O����V�]�]�+������O�O�F�M�M�*�
��	�	�'�"�	�	���
��
��
��	�	�'�"���
��
�sM�C�A/C�.C�C
�	C�C�D�!C7�6D�7	D�D�D�Dz
os.closerangec���|j��d�_�fd�}|�tjj	dd�y)NrFc�&���j�yr/)�cleanup_fds)r�s�rr�zCServerOptionsTests.test_cleanup_fds_closes_5_upto_minfds.<locals>.f�s���� � �"rr9)r�rhr{�
closerange�assert_called_with)rr�r�s  @r�%test_cleanup_fds_closes_5_upto_minfdsz8ServerOptionsTests.test_cleanup_fds_closes_5_upto_minfds�s3����=�=�?�����	#�	��
�
�
�(�(��B�/rc��|j�}Gd�d�}|�}i|fg|_|j�|j|jd�y)Nc��eZdZdZd�Zy)�9ServerOptionsTests.test_close_httpservers.<locals>.ServerFc��d|_y�NT)r`r�s r�closez?ServerOptionsTests.test_close_httpservers.<locals>.Server.close�s	��"��rN)r%r&r'r`rmr(rrr=rj�s���F�
#rr=T)r�r@�close_httpserversror`)rr�r=�servers    r�test_close_httpserversz)ServerOptionsTests.test_close_httpservers�sN���=�=�?��	#�	#����!#�V��~����"�"�$��������-rc��|j�}t�}||_|j�|j	|j
d�yrl)r�r
rU�close_loggerror`�rr�rUs   r�test_close_loggerz$ServerOptionsTests.test_close_logger�s;���=�=�?����� ��������������-rc���|j�}g��fd�}||_ddddddd�}|j|�|jt	��gd	��y)
Nc�(���j|�yr/r���fdr`s �r�close_fdz<ServerOptionsTests.test_close_parent_pipes.<locals>.close_fd�����M�M�"�rrr�r�rMrQr9��stdinr�r��child_stdin�child_stdout�child_stderr)rr�r��r�ry�close_parent_pipesror��rr�ry�pipesr`s    @r�test_close_parent_pipesz*ServerOptionsTests.test_close_parent_pipessX����=�=�?����	�$����q�A� !�1�a�I���#�#�E�*��������3rc���|j�}g��fd�}||_ddi}|j|�|j�g�y)Nc�(���j|�yr/r�rws �rryzOServerOptionsTests.test_close_parent_pipes_ignores_fd_of_none.<locals>.close_fdrzrr|)r�ryr�ror�s    @r�*test_close_parent_pipes_ignores_fd_of_nonez=ServerOptionsTests.test_close_parent_pipes_ignores_fd_of_none
sG����=�=�?����	�$����$����#�#�E�*������$rc���|j�}g��fd�}||_ddddddd�}|j|�|jt	��gd	��y)
Nc�(���j|�yr/r�rws �rryz;ServerOptionsTests.test_close_child_pipes.<locals>.close_fdrzrrr�r�rMrQr9r{)rMrQr9)r�ry�close_child_pipesror�r�s    @r�test_close_child_pipesz)ServerOptionsTests.test_close_child_pipessX����=�=�?����	�$����q�A� !�1�a�I���"�"�5�)��������3rc���|j�}g��fd�}||_ddi}|j|�|jt	��g�y)Nc�(���j|�yr/r�rws �rryzNServerOptionsTests.test_close_child_pipes_ignores_fd_of_none.<locals>.close_fd%rzrr}r�r�s    @r�)test_close_child_pipes_ignores_fd_of_nonez<ServerOptionsTests.test_close_child_pipes_ignores_fd_of_none"sL����=�=�?����	�$�����%���#�#�E�*��������,rc��|j�}t�}t�g|_||_|j	�|j|jdjd�|j|jdd�y)NrTzsupervisord logreopen)r�r
�handlersrU�
reopenlogsro�reopened�datarss   r�test_reopenlogsz"ServerOptionsTests.test_reopenlogs,sj���=�=�?�����&�=�/��� ��������������+�4�4�d�;�������Q��)@�Arc��tjd��5}|j}ddd�|jtj
j
��	|j�}t�|_	||_
|j�|jtj
j
|��t|d�5}t|j�j!��}ddd�|j#t	j$��|jj&d}|j|j)d��|j|j*�	t	j,|�y#1swY��hxYw#1swY��xYw#t.$rYywxYw#	t	j,|�w#t.$rYwwxYwxYw)NTr8�rrzsupervisord started with pid)r�r�r<r�r{r�rBr�r
rUr_rVr�r��int�read�stripror�r�r�rWrIrJ)rr�rr��pidr�s      r�test_write_pidfile_okz(ServerOptionsTests.test_write_pidfile_ok5s_��
�
(�
(��
5�	�����B�	����������+�,�	��}�}��H�)�m�H�O�!�H���"�"�$��O�O�B�G�G�N�N�2�.�/��b�#��
,�!��!�&�&�(�.�.�*�+��
,����S�"�)�)�+�.��/�/�&�&�q�)�C��O�O�C�N�N�+I�J�K��O�O�H�3�3�4�
��	�	�"�
�%	�	��
,�
,���
��
��
��	�	�"�
���
��
�sg�
F
�A0F2�(F�3BF2�4F#�
F�F �F2�#	F/�.F/�2G�4G
�	G�
	G�G�G�Gc��d}|j�}t�|_||_|j	�|jj
d}|j
|jd��|j|j�y)Nz/cannot/possibly/existrzcould not write pidfile)
r�r
rUr_rVr�r�r�r�rW)rrr�r�s    r�test_write_pidfile_failz*ServerOptionsTests.test_write_pidfile_failLsm��
%���=�=�?��%�-��������� ��o�o�"�"�1�%��������'@�A�B�����0�0�1rc��|j�}tj�\}}tj|d�tj|td��|j
|�|jttj|d�|j
|�|jttj|td��y)Nrr�)	r�r{�piper�r�rryrKrJ)rr��innie�outies    r�
test_close_fdz ServerOptionsTests.test_close_fdVs����=�=�?���w�w�y���u�
����q��
�������(����%� ����'�2�7�7�E�1�5����%� ����'�2�8�8�U�H�U�O�Drzos.close)�side_effectc�F�|j�}|jd�y)Nr)r�ryr�s  r�test_close_fd_ignores_oserrorz0ServerOptionsTests.test_close_fd_ignores_oserror`s���=�=�?�����!�rc���|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
t|�d�|d}|j
|jd�|j
|jd�|j
|jd	�|j
|jd	�|j
|jd
�|j
|jd
�|j
|jd�|j
|jd�|j
|j d�|j
|j"d�|j
|j$d�|j
|j&t(j*�|j
|j,d	�|j
|j.d�|j
|j0d
�|j
|j2d
dg�|j
|j4d	�|j
|j6dddd��y)Na~        [program:foo]
        command = /bin/cat
        priority = 1
        autostart = false
        autorestart = false
        startsecs = 100
        startretries = 100
        user = root
        stdout_logfile = NONE
        stdout_logfile_backups = 1
        stdout_logfile_maxbytes = 100MB
        stdout_events_enabled = true
        stopsignal = KILL
        stopwaitsecs = 100
        killasgroup = true
        exitcodes = 1,4
        redirect_stderr = false
        environment = KEY1=val1,KEY2=val2,KEY3=%(process_num)s
        numprocs = 2
        process_name = %(group_name)s_%(program_name)s_%(process_num)02d
        rr�program:foor�r��
bar_foo_00rEF�di@Tr�rQ�val1�val2�0)�KEY1�KEY2�KEY3)r�rrrr�processes_from_sectionrorpr<rorprqrsrtrurv�stdout_capture_maxbytesr}�stdout_events_enabledrwrxryr{r|rzr��redirect_stderrrk�rr�r�rr��pconfigs�pconfigs       r�test_processes_from_sectionz.ServerOptionsTests.test_processes_from_sectiones���=�=�?����
��,	;�$�&�����4� ��2�2�6�=�%�P������X���*��1�+��������|�4�������*�5�����*�*�E�2�����,�,�e�4�����*�*�C�0�����-�-�s�3�������a�(�����/�/��6�����8�8�!�<�����8�8�)�D�����6�6��=�����+�+�V�^�^�<�����,�,�e�4�����,�,�d�3�����-�-�s�3�����*�*�Q�q�E�2�����0�0�%�8�����,�,�!'��s�C�	Erc��|j�}td�}ddlm}|�}|j	|�|j|dd�}dt
j�z}|j|dj|�y)NzS        [program:foo]
        command = /bin/foo --host=%(host_node_name)s
        rrr�r�z/bin/foo --host=)
r�rrrrr�r�r�roro�rr�r�rr�r��expecteds       r�4test_processes_from_section_host_node_name_expansionzGServerOptionsTests.test_processes_from_section_host_node_name_expansion�su���=�=�?����
��	;�$�&�����4� ��2�2�6�=�%�P��%��
�
��7������!��,�,�h�7rc�|�|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
t|�d�dD]�}|j
||jd|z�|j
||jd	|z�|j
||jd
|z�|j
||jd|z�|j
||jd|z�|j
||jd
d|zi���y)NaX        [program:foo]
        process_name = foo_%(process_num)d
        command = /bin/foo --num=%(process_num)d
        directory = /tmp/foo_%(process_num)d
        stderr_logfile = /tmp/foo_%(process_num)d_stderr
        stdout_logfile = /tmp/foo_%(process_num)d_stdout
        environment = NUM=%(process_num)d
        numprocs = 2
        rrr�r�r��rr��foo_%dz/bin/foo --num=%dz/tmp/foo_%dz/tmp/foo_%d_stderrz/tmp/foo_%d_stdout�NUMz%d)r�rrrrr�rorpr<rorY�stderr_logfilervrk�rr�r�rr�r��nums       r�1test_processes_from_section_process_num_expansionzDServerOptionsTests.test_processes_from_section_process_num_expansion�s4���=�=�?���	�	
��	;�$�&�����4� ��2�2�6�=�%�P������X���*��	M�C����X�c�]�/�/��C��@����X�c�]�2�2�4G�#�4M�N����X�c�]�4�4�m�c�6I�J����X�c�]�9�9�$�s�*�
,����X�c�]�9�9�$�s�*�
,����X�c�]�6�6���s�
�8K�L�	Mrc�h�|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
t|�d�dD]F}|j
||jd|z�|j
||jd	dz��Hy)
Nz�        [program:foo]
        process_name = foo_%(process_num)d
        command = /bin/foo --numprocs=%(numprocs)d
        numprocs = 2
        rrr�r�r�r�r�z/bin/foo --numprocs=%d)
r�rrrrr�rorpr<ror�s       r�.test_processes_from_section_numprocs_expansionzAServerOptionsTests.test_processes_from_section_numprocs_expansion�s����=�=�?����
��	;�$�&�����4� ��2�2�6�=�%�P������X���*��	R�C����X�c�]�/�/��C��@����X�c�]�2�2�4L�q�4P�Q�	Rrc���|j�}td�}ddlm}|�}ddi|_|j|�|j
|dd�}|j|djd�y)Nz^        [program:foo]
        command = /bin/cat
        directory = /tmp/%(ENV_FOO)s
        rr�ENV_FOOr�r�z/tmp/bar)	r�rrr�
expansionsrr�rorY�rr�r�rr�r�s      r�-test_processes_from_section_expands_directoryz@ServerOptionsTests.test_processes_from_section_expands_directory�sr���=�=�?����
��
	;�$�&��&��.������4� ��2�2�6�=�%�P������!��.�.�
�;rc��|j�}td�}ddlm}|�}|j	|�|j|dd�}dtjdz}|j|dj|�y)NzO        [program:foo]
        command = /bin/foo --path='%(ENV_PATH)s'
        rrr�r�z/bin/foo --path='%s'�PATH)
r�rrrrr�r{r|roror�s       r�;test_processes_from_section_environment_variables_expansionzNServerOptionsTests.test_processes_from_section_environment_variables_expansion�sx���=�=�?����
��	;�$�&�����4� ��2�2�6�=�%�P��)�B�J�J�v�,>�>������!��,�,�h�7rc��|j�}td�}ddlm}|�}|j	|�|j|dd�}dtjdz}|j|djd|�y)Nzl        [program:foo]
        command = /bin/foo
        environment = PATH='/foo/bar:%(ENV_PATH)s'
        rrr�r�z/foo/bar:%sr�)
r�rrrrr�r{r|rorkr�s       r�6test_processes_from_section_expands_env_in_environmentzIServerOptionsTests.test_processes_from_section_expands_env_in_environment�s}���=�=�?����
��
	;�$�&�����4� ��2�2�6�=�%�P�� �2�:�:�f�#5�5������!��0�0��8�(�Crc��|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
|jdd�|j
|djd�y)Nz~        [program:foo]
        command = /bin/foo
        redirect_stderr = true
        stderr_logfile = /tmp/logfile
        rrr�r�zyFor [program:foo], redirect_stderr=true but stderr_logfile has also been set to a filename, the filename has been ignored�	r�rrrrr�ror�r�r�s      r�9test_processes_from_section_redirect_stderr_with_filenamezLServerOptionsTests.test_processes_from_section_redirect_stderr_with_filename�s����=�=�?����
��	;�$�&�����4� ��2�2�6�=�%�P������0�0��3�
I�	J�	
����!��3�3�T�:rc�V�|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
|jdd�|j
|djd�|j
|djd�y)NzY        [program:foo]
        command = /bin/foo
        stdout_logfile = syslog
        rrr�r�z�For [program:foo], stdout_logfile=syslog but this is deprecated and will be removed.  Use stdout_syslog=true to enable syslog instead.T)
r�rrrrr�ror�rv�
stdout_syslogr�s      r�=test_processes_from_section_rewrites_stdout_logfile_of_syslogzPServerOptionsTests.test_processes_from_section_rewrites_stdout_logfile_of_syslog
����=�=�?����
��
	;�$�&�����4� ��2�2�6�=�%�P������0�0��3�
�	�	
����!��3�3�T�:�����!��2�2�D�9rc�V�|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
|jdd�|j
|djd�|j
|djd�y)NzY        [program:foo]
        command = /bin/foo
        stderr_logfile = syslog
        rrr�r�z�For [program:foo], stderr_logfile=syslog but this is deprecated and will be removed.  Use stderr_syslog=true to enable syslog instead.T)
r�rrrrr�ror�r��
stderr_syslogr�s      r�=test_processes_from_section_rewrites_stderr_logfile_of_syslogzPServerOptionsTests.test_processes_from_section_rewrites_stderr_logfile_of_syslogr�rc��|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
|jg�|j
|djd�y)Nzv        [program:foo]
        command = /bin/foo
        redirect_stderr = true
        stderr_logfile = auto
        rrr�r�r�r�s      r�5test_processes_from_section_redirect_stderr_with_autozHServerOptionsTests.test_processes_from_section_redirect_stderr_with_auto.s{���=�=�?����
��	;�$�&�����4� ��2�2�6�=�%�P������0�0�"�5�����!��3�3�T�:rc�P�|j�}tdtjz�}ddlm}|�}|j
|�|j|dd�}|j|jg�|j|djtj�y)NzQ        [program:foo]
        command = /bin/foo
        stopsignal = %d
        rrr�r�)r�rrx�SIGQUITrrrr�ror�rwr�s      r�9test_processes_from_section_accepts_number_for_stopsignalzLServerOptionsTests.test_processes_from_section_accepts_number_for_stopsignal=s����=�=�?�����n�n�	���
	;�$�&�����4� ��2�2�6�=�%�P������0�0�"�5�����!��/�/����@rc��td�}ddlm}ddlm}|j�}idt
j��dd�dd	�d
d�dd
�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d!�d"d#�d$dd%d&d'd(d)d*d*dd+dd,��|_|�}|j|_	|j|�t|�|_|jt|��|jg�-�|j|j d.|jz�|j|j"d/|jz�|j|j$d0�|j|j&d1�|j|j(t*j,�|j|j.d2�|j|j0d2�|j|j2d3�|j|j4d4�|j|j6d5�|j|j8|jd�|j|j:d2�|j<j>}|j|j@dd6tBjD�|j|j@dd7d8�|j|j@dd9d:�|j|j@dd;d�|j|j@dd<d
�|jFd}|j|jHd=�|j|jJd>�|jtM|jN�d?�|jNd}|j|jHd=�|j|jPd@�|j|jJd>�|j|jRd5�|j|jT|jV�|j|jXdA�|j|jZd1�|j|j\d�|j|j^d&�|j|j`tbjd�|j|jfdA�|j|jhd2�|j|jjd2�|j|jl|jod'��|j|jpdB�|j|jrdg�|j|jtd+�|j|jvdB�|j|jxt{dC�D��y)ENa^        [supervisord]
        logfile = %(ENV_HOME)s/supervisord.log
        logfile_maxbytes = %(ENV_SUPD_LOGFILE_MAXBYTES)s
        logfile_backups = %(ENV_SUPD_LOGFILE_BACKUPS)s
        loglevel = %(ENV_SUPD_LOGLEVEL)s
        nodaemon = %(ENV_SUPD_NODAEMON)s
        minfds = %(ENV_SUPD_MINFDS)s
        minprocs = %(ENV_SUPD_MINPROCS)s
        umask = %(ENV_SUPD_UMASK)s
        identifier = supervisor_%(ENV_USER)s
        nocleanup = %(ENV_SUPD_NOCLEANUP)s
        childlogdir = %(ENV_HOME)s
        strip_ansi = %(ENV_SUPD_STRIP_ANSI)s
        environment = FAKE_ENV_VAR=/some/path

        [inet_http_server]
        port=*:%(ENV_HTSRV_PORT)s
        username=%(ENV_HTSRV_USER)s
        password=%(ENV_HTSRV_PASS)s

        [program:cat1]
        command=%(ENV_CAT1_COMMAND)s --logdir=%(ENV_CAT1_COMMAND_LOGDIR)s
        priority=%(ENV_CAT1_PRIORITY)s
        autostart=%(ENV_CAT1_AUTOSTART)s
        user=%(ENV_CAT1_USER)s
        stdout_logfile=%(ENV_CAT1_STDOUT_LOGFILE)s
        stdout_logfile_maxbytes = %(ENV_CAT1_STDOUT_LOGFILE_MAXBYTES)s
        stdout_logfile_backups = %(ENV_CAT1_STDOUT_LOGFILE_BACKUPS)s
        stopsignal=%(ENV_CAT1_STOPSIGNAL)s
        stopwaitsecs=%(ENV_CAT1_STOPWAIT)s
        startsecs=%(ENV_CAT1_STARTWAIT)s
        startretries=%(ENV_CAT1_STARTRETRIES)s
        directory=%(ENV_CAT1_DIR)s
        umask=%(ENV_CAT1_UMASK)s
        rr5rr�r�r��ENV_HTSRV_PORTr��ENV_HTSRV_USERr��ENV_HTSRV_PASSr��ENV_SUPD_LOGFILE_MAXBYTES�51MB�ENV_SUPD_LOGFILE_BACKUPS�10�ENV_SUPD_LOGLEVEL�info�ENV_SUPD_NODAEMON�false�ENV_SUPD_SILENT�ENV_SUPD_MINFDS�1024�ENV_SUPD_MINPROCS�200�ENV_SUPD_UMASK�002�ENV_SUPD_NOCLEANUP�true�ENV_SUPD_STRIP_ANSI�ENV_CAT1_COMMANDz/bin/customcat�ENV_CAT1_COMMAND_LOGDIRz
/path/to/logs�3�rootrG�78KB�2�KILL�5rI)�ENV_CAT1_PRIORITY�ENV_CAT1_AUTOSTART�
ENV_CAT1_USER�ENV_CAT1_STDOUT_LOGFILE� ENV_CAT1_STDOUT_LOGFILE_MAXBYTES�ENV_CAT1_STDOUT_LOGFILE_BACKUPS�ENV_CAT1_STOPSIGNAL�ENV_CAT1_STOPWAIT�ENV_CAT1_STARTWAIT�ENV_CAT1_STARTRETRIES�ENV_CAT1_DIR�ENV_CAT1_UMASKr�z%(ENV_HOME)s/supervisord.logzsupervisor_%(ENV_USER)si0rFFrK��Tr=r>r�r?i�#r�r�rDrMr�z%/bin/customcat --logdir=/path/to/logsr9r�rArB)>rrWr6rrr�r�r�r�r�rrrDr6rzror[rbr\r]r^r�INFOr`rarhrirgrc�
strip_ansir-rXrdrerfrjr<rmrprnrorprqrrrsrtrurvrwrxryrzr{r|r}r~rr�rYrZrkrl)	rr�r6rr�r�rFrDr�s	         rr�z;ServerOptionsTests.test_options_with_environment_expansionsKs���#�#
��H	)�:��=�=�?��'
���+�+�-�'
��	�'
�
�f�'
�
�j�	'
�

�n�'
�
(��
'
�
'��'
�
 ��'
�
 ��'
�
�w�'
�
�v�'
�
 ��'
�
�e�'
�
!�&�'
�
"�7�'
� 
� 0�!'
�"
&��#'
�$"%�"(�#�'5�06�/2�#)�!$�"%�%)�"�#�;'
��#�>%�&��$�7�7������4� �&�t�n������X�d�^�,����b��!�����)�)�7�&�:K�:K�K�	M�����,�,�2�V�5F�5F�F�	H�����2�2�H�=�����1�1�2�6�����*�*�L�,=�,=�>�����*�*�E�2�������%�0�������$�/�����*�*�C�0�����+�+�T�2�����-�-�v�/@�/@��/L�M�����,�,�e�4��%�%�1�1������/�/��2�8�<�f�n�n�M�����/�/��2�6�:�B�?�����/�/��2�6�:�D�A�����/�/��2�:�>�
�K�����/�/��2�:�>��O��,�,�Q�/��������F�+��������*�����T�1�1�2�A�6��$�$�Q�'��������V�,�������@�	B��������+�������$�/�����*�*�I�,O�,O�P�������!�,�����+�+�R�0�������A�&�����-�-�~�>�����)�)�6�>�>�:�����+�+�Q�/�����*�*�E�2�����*�*�E�2�����6�6�"�,�,�V�4�	6�����5�5�q�9�������1�#�.�������&�1�������a�(�����*�*�D�l�,K�Lrc�n�|j�}td�}tj�}tj
j
|d�}t|d�5}|j|�ddd�	||_	|jg��tj|d��|j|jtj
j
|��|j|jtj
j
|��|j|j tj
j
|d��|j|j"tj
j
|d��y#1swY��"xYw#tj|d��wxYw)	Nz�        [supervisord]
        childlogdir=%(here)s
        directory=%(here)s
        logfile=%(here)s/supervisord.log
        pidfile=%(here)s/supervisord.pid
        rnr�r�Tr�r8r;)r�rr�r�r{r�r�r�r�rDrzr�r�rorcrYr[r_)rr�r�r�r�r�s      r�-test_options_supervisord_section_expands_herez@ServerOptionsTests.test_options_supervisord_section_expands_here�sJ���=�=�?����
�����!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�"2�H�����"��%��M�M�$�d�3�����-�-��G�G�L�L���	 �����+�+��G�G�L�L���	 �����)�)��G�G�L�L��0�1�	3�����)�)��G�G�L�L��0�1�	3�	�	��
�M�M�$�d�3�s�F�7F�F�F4c��|j�}td�}tj�}tj
j
|d�}t|d�5}|j|�ddd�	||_	|jg��tj|d��|jj}|jd}|j!|j"d�|j$d}|j!|j&tj
j
|d	��y#1swY��xYw#tj|d��wxYw)
Nz�
        [supervisord]
        environment=CMD=/bin/from/supervisord/section

        [program:cmd]
        command=%(ENV_CMD)s
        rnr�r�Tr�r�cmdz/bin/from/supervisord/section�r�rr�r�r{r�r�r�r�rDrzr�r�r-rXrjror<rnro�	rr�r�r�r�r�rF�groupr�s	         r�>test_options_program_section_expands_env_from_supervisord_sectzQServerOptionsTests.test_options_program_section_expands_env_from_supervisord_sect�s���=�=�?����
�����!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�"2�H�����"��%��M�M�$�d�3��%�%�1�1���-�-�a�0��������U�+��$�$�Q�'���������G�G�L�L��>�?�	A�	�	��
�M�M�$�d�3���D2�7D>�2D;�>Ec��|j�}td�}tj�}tj
j
|d�}t|d�5}|j|�ddd�	||_	|jg��tj|d��|jj}|jd}|j!|j"d�|j$d}|j!|j&tj
j
|d	��y#1swY��xYw#tj|d��wxYw)
Nz�
        [supervisord]
        environment=CMD=/bin/from/supervisord/section

        [program:cmd]
        command=%(ENV_CMD)s
        environment=CMD=/bin/from/program/section
        rnr�r�Tr�rrz/bin/from/program/sectionrrs	         r�:test_options_program_section_expands_env_from_program_sectzMServerOptionsTests.test_options_program_section_expands_env_from_program_sect�s���=�=�?����
�����!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�"2�H�����"��%��M�M�$�d�3��%�%�1�1���-�-�a�0��������U�+��$�$�Q�'���������G�G�L�L��:�;�	=�	�	��
�M�M�$�d�3�rc��|j�}td�}tj�}tj
j
|d�}t|d�5}|j|�ddd�	||_	|jg��tj|d��|jj}|jd}|j!|j"d�|j$d}|j!|j&tj
j
|d	��|j!|j(tj
j
|d
��|j!|j*dtj
j
|d�i�|j!|j,d
tj
j
|d�z�|j!|j.tj
j
|d��|j!|j0tj
j
|d��y#1swY���xYw#tj|d��wxYw)Na-
        [supervisord]

        [program:cat]
        command=%(here)s/bin/cat
        directory=%(here)s/thedirectory
        environment=FOO=%(here)s/foo
        serverurl=unix://%(here)s/supervisord.sock
        stdout_logfile=%(here)s/stdout.log
        stderr_logfile=%(here)s/stderr.log
        rnr�r�Tr�rr��thedirectory�bin/cat�FOOr�r�r��
stdout.log�
stderr.log�r�rr�r�r{r�r�r�r�rDrzr�r�r-rXrjror<rnrYrorkr�rvr�rs	         r�)test_options_program_section_expands_herez<ServerOptionsTests.test_options_program_section_expands_heres����=�=�?���
�

�����!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�"2�H�����"��%��M�M�$�d�3��%�%�1�1���-�-�a�0��������U�+��$�$�Q�'���������G�G�L�L��~�.�	0��������G�G�L�L��y�)�	+�����)�)�
�B�G�G�L�L��u�-�.�	0�������������T�+=�>�>�	@�����,�,��G�G�L�L��|�,�	.�����,�,��G�G�L�L��|�,�	.�+	�	��
�M�M�$�d�3���I�7I&�I#�&I?c��|j�}td�}tj�}tj
j
|d�}t|d�5}|j|�ddd�	||_	|jg��tj|d��|jj}|jd}|j!|j"d�|j$d}|j!|j&tj
j
|d	��|j!|j(tj
j
|d
��|j!|j*dtj
j
|d�i�|j!|j,d
tj
j
|d�z�|j!|j.tj
j
|d��|j!|j0tj
j
|d��y#1swY���xYw#tj|d��wxYw)NaP
        [supervisord]

        [eventlistener:memmon]
        events=TICK_60
        command=%(here)s/bin/memmon
        directory=%(here)s/thedirectory
        environment=FOO=%(here)s/foo
        serverurl=unix://%(here)s/supervisord.sock
        stdout_logfile=%(here)s/stdout.log
        stderr_logfile=%(here)s/stderr.log
        rnr�r�Tr�r�memmonrz
bin/memmonrr�r�r�rrrrs	         r�/test_options_eventlistener_section_expands_herezBServerOptionsTests.test_options_eventlistener_section_expands_here?s����=�=�?����
�����!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�"2�H�����"��%��M�M�$�d�3��%�%�1�1���-�-�a�0��������X�.��$�$�Q�'���������G�G�L�L��~�.�	0��������G�G�L�L��|�,�	.�����)�)�
�B�G�G�L�L��u�-�.�	0�������������T�+=�>�>�	@�����,�,��G�G�L�L��|�,�	.�����,�,��G�G�L�L��|�,�	.�+	�	��
�M�M�$�d�3�rc�B�|j�}td�}|dz
}tj�}tj
j
|d�}t|d�5}|j|�ddd�	ddd�|_	||_
|jg��tj|d	�
�|jj}|j!|j"tj
j
|d��|j$d}|j&d}tj
j
|d
��dt)j*���}	|j!|j,|	�y#1swY��xYw#tj|d	�
�wxYw)Nze
        [supervisord]
        logfile = %(here)s/%(ENV_LOGNAME)s.log

        [program:cat]
        z\command = %(here)s/bin/cat --foo=%(ENV_FOO)s --num=%(process_num)d --node=%(host_node_name)srnr��mainlogr�)�ENV_LOGNAMEr�r�Tr�zmainlog.logrrz --foo=bar --num=0 --node=)r�rr�r�r{r�r�r�r�r�rDrzr�r�r-rXror[rjrnr�r�ro)
rr�r�r�r�r�r��	cat_group�cat_0r�s
          r�(test_options_expands_combined_expansionsz;ServerOptionsTests.test_options_expands_combined_expansionsgsb���=�=�?����
��	
�C�	D�����!���7�7�<�<��.@�A��
�"�C�
(�	�A�
�G�G�D�M�	�	4�(� �+�H�'�#3�H�����"��%��M�M�$�d�3��%�%�1�1���������G�G�L�L��}�-�	/��1�1�!�4�	��)�)�!�,���G�G�L�L��y�)��M�M�O���	
�������1�-	�	��
�M�M�$�d�3�s�!E8�<#F�8F�Fc�F�tj�}tjj	|d�}td�}t
|d�5}|j|�ddd�|j�}	||_		|jd��|jd�t!j"|d	�
�y#1swY�]xYw#t$r5}|jt|jd�d|z�Yd}~�]d}~wwxYw#t!j"|d	�
�wxYw)Nrnzq
        [supervisord]

        [program:cat]
        command = /bin/cat
        stopsignal = NOTASIGNAL
        r�Fr�rr�Qvalue 'NOTASIGNAL' is not a valid signal name in section 'program:cat' (file: %r)Tr�)r�r�r{r�r�rr�r�r�rDrrr0ro�strr�r�r�)rrr�r�r�r��es       r�.test_options_error_handler_shows_main_filenamezAServerOptionsTests.test_options_error_handler_shows_main_filename�s���"�"�$���7�7�<�<��1C�D����
���"�C�
(�	�A�
�G�G�D�M�	��=�=�?��
	7�"2�H��
N��'�'��'�7��	�	�*�+�
�M�M�'��6�	�	���
N�� � ��Q�V�V�A�Y��:�<L�M�N�N��
N��

�M�M�'��6�s<�B:�7D�?#C�:C�	D�+C?�:D�?D�D�D c�p�tj�}tjj	|d�}td|z�}t
|d�5}|j|�ddd�tjj	|d�}tj|�tjj	|d�}td�}t
|d�5}|j|�ddd�|j�}	||_
	|jd��|jd	�t#j$|d�
�y#1swY��xYw#1swY�ixYw#t$r5}|jt|j d
�d|z�Yd}~�id}~wwxYw#t#j$|d�
�wxYw)Nrnr�r�r�z
included.confzY        [program:cat]
        command = /bin/cat
        stopsignal = NOTASIGNAL
        Fr�rrr*Tr�)r�r�r{r�r�rr�r�r�r�rDrrr0ror+r�r�r�)	rrr�r�r�r��
included_confr�r,s	         r�2test_options_error_handler_shows_included_filenamezEServerOptionsTests.test_options_error_handler_shows_included_filename�s����"�"�$���7�7�<�<��1C�D����
�����"�C�
(�	�A�
�G�G�D�M�	������g�x�0��
����������V�_�=�
���
��
�-��
%�	��
�G�G�D�M�	��=�=�?��
	7�"2�H��
K��'�'��'�7��	�	�*�+�
�M�M�'��6�3	�	��	�	���
K�� � ��Q�V�V�A�Y��:�<I�J�K�K��
K��

�M�M�'��6�sH�E�E�F�#E�E�E�	F�$+F�F�F�F�F5c��|j�}td�}ddlm}|�}|j	|�|jt|j|dd�y)Nz)        [program:spaces are bad]
        rrzprogram:spaces are bad�r�rrrrrKr0r��rr�r�rr�s     r�3test_processes_from_section_bad_program_name_spaceszFServerOptionsTests.test_processes_from_section_bad_program_name_spaces��X���=�=�?����
��	;�$�&�����4� ����*�h�&E�&E� �":�D�	Brc��|j�}td�}ddlm}|�}|j	|�|jt|j|dd�y)Nz)        [program:colons:are:bad]
        rrzprogram:colons:are:badr2r3s     r�3test_processes_from_section_bad_program_name_colonszFServerOptionsTests.test_processes_from_section_bad_program_name_colons�r5rc��|j�}td�}ddlm}|�}|j	|�|jt|j|dd�y)NzN        [program:foo]
        command = /bin/cat
        numprocs = 2
        rrr�r2r3s     r�5test_processes_from_section_no_procnum_in_processnamezHServerOptionsTests.test_processes_from_section_no_procnum_in_processname��V���=�=�?����
��
	;�$�&�����4� ����*�h�&E�&E� �-��	7rc�F�|j�}td�}ddlm}|�}|j	|�	|j|dd�|j
d�y#t$r7}|j|jdjd��Yd}~yd}~wwxYw)Nz        [program:foo]
        rrr�rz6program section program:foo does not specify a command)r�rrrrr�rr0r�r�r�)rr�r�rr�r
s      r�&test_processes_from_section_no_commandz9ServerOptionsTests.test_processes_from_section_no_command�s����=�=�?����
��	;�$�&�����4� �	K��+�+�F�M�4�H��I�I�&�'���	K��O�O�C�H�H�Q�K�2�2�H�J�
K�
K��	K�s�$A � 	B �)-B�B c��|j�}td�}ddlm}|�}|j	|�|jt|j|dd�y)Nz^        [program:foo]
        command = /bin/cat
        process_name = %(not_there)s
        rrr�r2r3s     r�?test_processes_from_section_missing_replacement_in_process_namezRServerOptionsTests.test_processes_from_section_missing_replacement_in_process_name�r:rc��|j�}td�}ddlm}|�}|j	|�|jt|j|dd�y)Nz`        [program:foo]
        command = /bin/cat
        process_name = %(program_name)
        rrr�r2r3s     r�:test_processes_from_section_bad_expression_in_process_namezMServerOptionsTests.test_processes_from_section_bad_expression_in_process_name		r:rc��|j�}td�}ddlm}|�}|j	|�|jt|j|dd�y)Nz_        [program:foo]
        command = /bin/cat
        process_name = colons:are:bad
        rrr�r2r3s     r�5test_processes_from_section_bad_chars_in_process_namezHServerOptionsTests.test_processes_from_section_bad_chars_in_process_name	r:rc�L�|j�}td�}ddlm}|�}|j	|�|j|dd�}|j
t|�d�|d}|j
|jd�|j
|jd�y)Nz|        [program:foo]
        command = /bin/cat
        process_name = %(program_name)s
        stopasgroup = true
        rrr�r�r�T)
r�rrrrr�rorpr{r|r�s       r�;test_processes_from_section_stopasgroup_implies_killasgroupzNServerOptionsTests.test_processes_from_section_stopasgroup_implies_killasgroup#	s����=�=�?����
��	;�$�&�����4� ��2�2�6�=�%�P������X���*��1�+������,�,�d�3�����,�,�d�3rc��|j�}td�}ddlm}|�}|j	|�|jt|j|dd�y)Nz�        [program:foo]
        command = /bin/cat
        process_name = %(program_name)s
        stopasgroup = true
        killasgroup = false
        rrr�r2r3s     r�>test_processes_from_section_killasgroup_mismatch_w_stopasgroupzQServerOptionsTests.test_processes_from_section_killasgroup_mismatch_w_stopasgroup4	sV���=�=�?����
��	;�$�&�����4� ����*�h�&E�&E� �-��	7rc�$�|j�}td�}ddlm}|�}|j	|�	|j|dd�|j
d�y#t$r&}|jdt|�v�Yd}~yd}~wwxYw)Nzh        [program:foo]
        command = /bin/cat
        environment = KEY1=val1,KEY2=val2,KEY3
        rrr�z9instance.processes_from_section should raise a ValueErrorz^Unexpected end of key/value pairs in value 'KEY1=val1,KEY2=val2,KEY3' in section 'program:foo')
r�rrrrr�rr0r�r+)rr�r�rr�r,s      r�=test_processes_from_section_unexpected_end_of_key_value_pairszPServerOptionsTests.test_processes_from_section_unexpected_end_of_key_value_pairsC	s����=�=�?����
��
	;�$�&�����4� �		,��+�+�F�M�4�H�
�I�I�+�
,��
�	��O�O�F��q�6��
�
��	�s�A � 	B�)B
�
Bc���|j�}td�}tjd��5}	|j	|�|j�ddlm}|�}|j|j�|j|dd�|jd�ddd�y#t$r6}|j|jdd|jz�Yd}~�Cd}~wwxYw#1swYyxYw)	Nz2        [program:foo]
        ;no command
        r�r�rrr�rzZprogram section program:foo does not specify a command in section 'program:foo' (file: %r))r�rr�r�r�r�rrr�r<r�rr0ror�)rr�r�r�rr�r,s       r�=test_processes_from_section_shows_conf_filename_on_valueerrorzPServerOptionsTests.test_processes_from_section_shows_conf_filename_on_valueerrorX	s����=�=�?����
���
(�
(�d�
3�
	,�q�
,�����
����	�B�,�.�����A�F�F�#��/�/��
�t�L��	�	�*�+�
	,�
	,���
D�� � ������:�<=�F�F�C�D�D��
D��
	,�
	,�s5�C,�AB*�C,�*	C)�3,C$�C,�$C)�)C,�,C5c�6�|j�}td�}ddlm}|�}t	�|_|j
|�|j|dd�|j|jdd�|j|jdd�y)Nz�        [program:foo]
        command = /bin/foo
        stdout_logfile = AUTO
        stdout_logfile_maxbytes = 0
        stderr_logfile = AUTO
        stderr_logfile_maxbytes = 0
        rrr�z�For [program:foo], AUTO logging used for stdout_logfile without rollover, set maxbytes > 0 to avoid filling up filesystem unintentionallyr�z�For [program:foo], AUTO logging used for stderr_logfile without rollover, set maxbytes > 0 to avoid filling up filesystem unintentionally)
r�rrrr
rUrr�ror�r3s     r�4test_processes_from_section_autolog_without_rolloverzGServerOptionsTests.test_processes_from_section_autolog_without_rolloverm	s����=�=�?����
��	;�$�&��%�-������4� ��'�'��
�t�D�����0�0��3�+�	,�	
����0�0��3�+�	,rc��td�}ddlm}|�}|j|�|j	�}|j|�}|j
t|�d�|d}|j
|jd�|j
|jd�|j
t|j�d�y)Nz�        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1
        rrr��manyr��rrrrr��process_groups_from_parserrorpr<rmrn�rr�rr�r��gconfigs�gconfigs       r�+test_homogeneous_process_groups_from_parserz>ServerOptionsTests.test_homogeneous_process_groups_from_parser�	s�����
��	;�$�&�����4� ��=�=�?���6�6�v�>������X���*��1�+��������v�.�����)�)�1�-�����W�4�4�5�q�9rc��td�}ddlm}ddlm}|�}|j|�|j
�}|j|�}|jt|�d�|d}|j|jd�|j|j|�|jt|j�d�|d}|j|jd	�|j|jd
�|j|j|�|jt|j�d�|d}|j|jd�|j|jd�|j|j|�|jt|j�d�y)Na        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/dog
        numprocs = 2
        priority = 1

        [eventlistener:cat]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 3

        [eventlistener:biz]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/biz
        numprocs = 2
        rr��default_handlerrM�bizr�r�r�r�dog)rrr�supervisor.dispatchersrWrr�rProrpr<�result_handlerrnrm)rr�rrWr�r�rR�gconfig1s        r�%test_event_listener_pools_from_parserz8ServerOptionsTests.test_event_listener_pools_from_parser�	st����
��(	;�:�$�&�����4� ��=�=�?���6�6�v�>������X���*��A�;���������.�����0�0�/�B�����X�5�5�6��:��A�;���������.�����*�*�B�/�����0�0�/�B�����X�5�5�6��:��A�;���������.�����*�*�A�.�����0�0�/�B�����X�5�5�6��:rc��td�}ddlm}ddlm}|j�}t
j�ddddd	d
�|_|�}|j|_	|j|�|j|�}|jt|�d�|d}|j|jd�|j|jd
�|j|j |�|jt|j"�d�|d}|j|jd�|j|jd�|j|j |�|jt|j"�d�|j"d}	|j|	jd�|j|	j$d�|j|	jd�|j"d}
|j|
jd�|j|
j$d�|j|
jd�y)Na�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        process_name = %(ENV_EL1_PROCNAME)s_%(program_name)s_%(process_num)s
        command = %(ENV_EL1_COMMAND)s
        numprocs = %(ENV_EL1_NUMPROCS)s
        priority = %(ENV_EL1_PRIORITY)s

        [eventlistener:cat]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 3

        rrrVr��myeventlistenerz/bin/dogr��1)r�r��ENV_EL1_PROCNAME�ENV_EL1_COMMAND�ENV_EL1_NUMPROCS�ENV_EL1_PRIORITYr�r�rrMr�rY�myeventlistener_dog_0�myeventlistener_dog_1)rrrrZrWr�r�r�r�r�rrProrpr<rmr[rnro)rr�rrWr�r�rR�gconfig0r\�dog0�dog1s           r�Atest_event_listener_pools_from_parser_with_environment_expansionszTServerOptionsTests.test_event_listener_pools_from_parser_with_environment_expansions�	s�����
��	;�:��=�=�?��3;�3F�3F�3H�3<�;L�:D�;>�;>�'(��#�%�&��$�7�7������4� ��6�6�v�>������X���*��A�;���������.�����*�*�B�/�����0�0�/�B�����X�5�5�6��:��A�;���������.�����*�*�A�.�����0�0�/�B�����X�5�5�6��:��'�'��*��������$;�<�������z�2��������*��'�'��*��������$;�<�������z�2��������*rc�&�td�}ddlm}|�}|j|�|j	�}	|j|�|j
d�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nzl        [eventlistener:dog]
        events=EVENT
        command = /bin/dog
        buffer_size = 0
        rrrz8[eventlistener:dog] section sets invalid buffer_size (0)�
rrrrr�rPrr0ror��rr�rr�r�r
s      r�3test_event_listener_pool_disallows_buffer_size_zerozFServerOptionsTests.test_event_listener_pool_disallows_buffer_size_zero�	s�����
��	;�$�&�����4� ��=�=�?��	+��/�/��7��I�I�&�'���	+����S�X�X�a�[�+*�
+�
+��	+���"A�	B�'B�Bc�&�td�}ddlm}|�}|j|�|j	�}	|j|�|j
d�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nz�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        command = /bin/dog
        redirect_stderr = True
        rrrz�[eventlistener:dog] section sets redirect_stderr=true but this is not allowed because it will interfere with the eventlistener protocolrlrms      r�2test_event_listener_pool_disallows_redirect_stderrzEServerOptionsTests.test_event_listener_pool_disallows_redirect_stderr
s�����
��	;�$�&�����4� ��=�=�?��	B��/�/��7��I�I�&�'���	B����S�X�X�a�[�+A�
B�
B��	B�roc��td�}ddlm}ddlm}|�}|j|�|j
�}|j|�}|jt|�d�|d}|j|j|�y)Nz�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        command = /bin/dog
        result_handler = supervisor.tests.base:dummy_handler
        rr)�
dummy_handlerr�)rrr�supervisor.tests.basersrr�rProrpr[)rr�rrsr�r�rRr\s        r�2test_event_listener_pool_with_event_result_handlerzEServerOptionsTests.test_event_listener_pool_with_event_result_handler
s}����
��	;�7�$�&�����4� ��=�=�?���6�6�v�>������X���*��A�;������0�0�-�@rc�&�td�}ddlm}|�}|j|�|j	�}	|j|�|j
d�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nz�        [eventlistener:cat]
        events=PROCESS_COMMUNICATION
        command = /bin/cat
        result_handler = supervisor.tests.base:nonexistent
        rrrzOsupervisor.tests.base:nonexistent cannot be resolved within [eventlistener:cat]rlrms      r�4test_event_listener_pool_result_handler_unimportablezGServerOptionsTests.test_event_listener_pool_result_handler_unimportable1
s�����
��	;�$�&�����4� ��=�=�?��	7��/�/��7��I�I�&�'���	7����S�X�X�a�[�6�
7�
7��	7�roc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [eventlistener:dog]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/dog
        numprocs = 2
        priority = 1
        rr�rrrrr�rKr0rP�rr�rr�r�s     r�%test_event_listener_pool_noeventslinez8ServerOptionsTests.test_event_listener_pool_noeventslineD
�O����
��	;�$�&�����4� ��=�=�?�����*�X�%H�%H��Prc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION,THIS_EVENT_TYPE_DOESNT_EXIST
        process_name = %(program_name)s_%(process_num)s
        command = /bin/dog
        numprocs = 2
        priority = 1
        rrryrzs     r�*test_event_listener_pool_unknown_eventtypez=ServerOptionsTests.test_event_listener_pool_unknown_eventtypeR
�O����
��	;�$�&�����4� ��=�=�?�����*�X�%H�%H��Prc���ddlm}ddlm}td�}ddlm}|�}|j|�|j
�}t�}ddtjtjf|_t�}ddtjf|_td|�td|�td|�d	����}	|	||�}
tjtjf}|jt|
�d
�|
d}|j|j|�|j|j d�|j|j"d�|j|j$j&d
�|j||j$j)��|jd|j$j+��|jd|j$j-��|jt|j.�d�|j.d}
|j|
j|�|
d}|j|j d�|j|j"d�|j|j$j&d�|j||j$j)��|jd|j$j+��|jt|j.�d�|
d}|j|j d�|j|j$j&d�|jt|j.�d�|
d}|j|j d�|j|j$j&d�|jd|j$j)��|jd|j$j+��|jt|j.�d�y)Nr��FastCGIGroupConfig��FastCGIProcessConfiga�        [fcgi-program:foo]
        socket = unix:///tmp/%(program_name)s.sock
        socket_owner = testuser:testgroup
        socket_mode = 0666
        socket_backlog = 32676
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1

        [fcgi-program:bar]
        socket = unix:///tmp/%(program_name)s.sock
        process_name = %(program_name)s_%(process_num)s
        command = /bin/bar
        user = testuser
        numprocs = 3

        [fcgi-program:flub]
        socket = unix:///tmp/%(program_name)s.sock
        command = /bin/flub

        [fcgi-program:cub]
        socket = tcp://localhost:6000
        command = /bin/cub
        r�pwd.getpwuid�pwd.getpwnam�grp.getgrnamc�$�|j|�Sr/�rP�r�r�s  r�get_process_groupszMServerOptionsTests.test_fcgi_programs_from_parser.<locals>.get_process_groups�
����6�6�v�>�>rrQr�r�zunix:///tmp/foo.sock��r�r���zunix:///tmp/bar.sockrrM�cubztcp://localhost:6000�flubzunix:///tmp/flub.sock)rr�r�rrrr�rrrur��return_valuerrorp�	__class__r<rm�
socket_config�url�	get_owner�get_mode�get_backlogrn)rr�r�r�rr�r��pwd_mock�grp_mockr�rR�	exp_owner�	gconf_foo�pconfig_foo�	gconf_bar�	gconf_cub�
gconf_flubs                 r�test_fcgi_programs_from_parserz1ServerOptionsTests.test_fcgi_programs_from_parsera
s���9�;���
��4	;�$�&�����4� ��=�=�?��
�6��!%�t�X�\�\�8�<�<� H����6��!%�t�X�\�\� :���	�~�x�	(�	�~�x�	(�	�~�x�	(�	?�
)�
)�
)�	?�&�h��7���\�\�8�<�<�0�	�����X���*��Q�K�	�����,�,�.@�A��������/�����+�+�Q�/�����0�0�4�4� 6�	8�����I�$;�$;�$E�$E�$G�H�����	� 7� 7� @� @� B�C�����	� 7� 7� C� C� E�F�����Y�6�6�7��;��/�/��2������.�.�0D�E��Q�K�	��������/�����+�+�S�1�����0�0�4�4�/�	1�����I�$;�$;�$E�$E�$G�H�����	� 7� 7� @� @� B�C�����Y�6�6�7��;��Q�K�	��������/�����0�0�4�4�/�	1�����Y�6�6�7��;��a�[�
�������&�1�����1�1�5�5�0�	2�����z�7�7�A�A�C�D�����
� 8� 8� A� A� C�D�����Z�7�7�8�!�<rc�4�ddlm}ddlm}td�}ddlm}|j�}dddd	d
ddd
ddd�
|_|�}|j|_|j|�t�}ddtjtjf|_
t�}ddtjf|_
td|�td|�td|�d����}	|	||�}
tjtjf}|jt!|
�d�|
d}|j|j"|�|j|j$d�|j|j&d�|j|j(j*d�|j||j(j-��|jd|j(j/��|jd|j(j1��|jt!|j2�d�|j2d}
|j|
j"|�|j|
j4d�y)Nrr�r�a�        [fcgi-program:foo]
        socket = unix:///tmp/%(program_name)s%(ENV_FOO_SOCKET_EXT)s
        socket_owner = %(ENV_FOO_SOCKET_USER)s:testgroup
        socket_mode = %(ENV_FOO_SOCKET_MODE)s
        socket_backlog = %(ENV_FOO_SOCKET_BACKLOG)s
        process_name = %(ENV_FOO_PROCESS_PREFIX)s_%(program_name)s_%(process_num)s
        command = /bin/foo --arg1=%(ENV_FOO_COMMAND_ARG1)s
        numprocs = %(ENV_FOO_NUMPROCS)s
        priority = %(ENV_FOO_PRIORITY)s
        rrIr�z.usock�testuser�0666�32676zfcgi-r�r�r`)
r�r��ENV_FOO_SOCKET_EXT�ENV_FOO_SOCKET_USER�ENV_FOO_SOCKET_MODE�ENV_FOO_SOCKET_BACKLOG�ENV_FOO_PROCESS_PREFIX�ENV_FOO_COMMAND_ARG1�ENV_FOO_NUMPROCS�ENV_FOO_PRIORITYr�r�r�c�$�|j|�Sr/r�r�s  rr�ziServerOptionsTests.test_fcgi_programs_from_parser_with_environment_expansions.<locals>.get_process_groups�
r�rr�r�zunix:///tmp/foo.usockr�r�r�z/bin/foo --arg1=bar)rr�r�rrr�r�r�rrrrur�r�rrorpr�r<rmr�r�r�r�r�rnro)rr�r�r�rr�r�r�r�r�rRr�r�r�s              r�:test_fcgi_programs_from_parser_with_environment_expansionszMServerOptionsTests.test_fcgi_programs_from_parser_with_environment_expansions�
s;��9�;��
�

��	;��=�=�?��39�:@�=E�>H�>D�AH�AH�?D�;>�;>�
'(��#�%�&��$�7�7������4� �
�6��!%�t�X�\�\�8�<�<� H����6��!%�t�X�\�\� :���	�~�x�	(�	�~�x�	(�	�~�x�	(�	?�
)�
)�
)�	?�&�h��7���\�\�8�<�<�0�	�����X���*��Q�K�	�����,�,�.@�A��������/�����+�+�Q�/�����0�0�4�4� 7�	9�����I�$;�$;�$E�$E�$G�H�����	� 7� 7� @� @� B�C�����	� 7� 7� C� C� E�F�����Y�6�6�7��;��/�/��2������.�.�0D�E�����,�,�.C�Drc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        rrryrzs     r�test_fcgi_program_no_socketz.ServerOptionsTests.test_fcgi_program_no_socket�
r|rc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        socket=junk://blah
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        rrryrzs     r�)test_fcgi_program_unknown_socket_protocolz<ServerOptionsTests.test_fcgi_program_unknown_socket_protocolrrc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        socket=unix://relative/path
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        rrryrzs     r�$test_fcgi_program_rel_unix_sock_pathz7ServerOptionsTests.test_fcgi_program_rel_unix_sock_pathrrc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        socket=tcp://missingport
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        rrryrzs     r�%test_fcgi_program_bad_tcp_sock_formatz8ServerOptionsTests.test_fcgi_program_bad_tcp_sock_format&rrc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        socket=unix:///tmp/%(process_num)s.sock
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        rrryrzs     r�(test_fcgi_program_bad_expansion_proc_numz;ServerOptionsTests.test_fcgi_program_bad_expansion_proc_num5rrc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        socket=tcp://localhost:8000
        socket_owner=nobody:nobody
        command = /bin/foo
        rrryrzs     r�*test_fcgi_program_socket_owner_set_for_tcpz=ServerOptionsTests.test_fcgi_program_socket_owner_set_for_tcpD�O����
��	;�$�&�����4� ��=�=�?�����*�X�%H�%H��Prc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz        [fcgi-program:foo]
        socket = tcp://localhost:8000
        socket_mode = 0777
        command = /bin/foo
        rrryrzs     r�)test_fcgi_program_socket_mode_set_for_tcpz<ServerOptionsTests.test_fcgi_program_socket_mode_set_for_tcpQr�rc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        socket = unix:///tmp/foo.sock
        socket_owner = sometotaljunkuserthatshouldnobethere
        command = /bin/foo
        rrryrzs     r�"test_fcgi_program_bad_socket_ownerz5ServerOptionsTests.test_fcgi_program_bad_socket_owner^r�rc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz        [fcgi-program:foo]
        socket = unix:///tmp/foo.sock
        socket_mode = junk
        command = /bin/foo
        rrryrzs     r�!test_fcgi_program_bad_socket_modez4ServerOptionsTests.test_fcgi_program_bad_socket_modekr�rc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [fcgi-program:foo]
        socket = unix:///tmp/foo.sock
        socket_backlog = -1
        command = /bin/foo
        rrryrzs     r�$test_fcgi_program_bad_socket_backlogz7ServerOptionsTests.test_fcgi_program_bad_socket_backlogxr�rc��td�}ddlm}|�}|j|�|j	�}|j|�}|j
t|�d�|d}|j
|jd�|j
|jd�|j
t|j�d�y)Nz�        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/cat

        [group:thegroup]
        programs = one,two
        priority = 5
        rrr��thegroupr9r�rOrQs       r�-test_heterogeneous_process_groups_from_parserz@ServerOptionsTests.test_heterogeneous_process_groups_from_parser�s����
�

��	;�$�&�����4� ��=�=�?���6�6�v�>������X���*��1�+��������z�2�����)�)�1�-�����W�4�4�5�q�9rc�V�td�}ddlm}|�}|j|�|j	�}|j|�}|j
t|�d�|d}|j
|jd�|j
|jd�|j
t|j�d�|d}|j
|jd�|j
|jd�|j
t|j�d�y)	NaJ        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/cat

        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [group:thegroup]
        programs = one,two
        priority = 5
        rrr�rNr�r�r9rO)rr�rr�r�rR�
manyconfigrSs        r�&test_mixed_process_groups_from_parser1z9ServerOptionsTests.test_mixed_process_groups_from_parser1�s�����
��"	;�$�&�����4� ��=�=�?���6�6�v�>������X���*��a�[�
�������&�1�����,�,�a�0�����Z�7�7�8�!�<��1�+��������z�2�����)�)�1�-�����W�4�4�5�q�9rc��td�}ddlm}|�}|j|�|j	�}|j|�}|j
t|�d�|d}|j
|jd�|j
|jd�|j
t|j�d�y)NaP        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/cat

        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [group:thegroup]
        programs = one,two, many
        priority = 5
        rrr�r�r9rQrOrQs       r�&test_mixed_process_groups_from_parser2z9ServerOptionsTests.test_mixed_process_groups_from_parser2�s�����
��"	;�$�&�����4� ��=�=�?���6�6�v�>������X���*��1�+��������z�2�����)�)�1�-�����W�4�4�5�q�9rc��td�}ddlm}|�}|j|�|j	�}|j|�}|j
t|�d�|d}|j
|jd�|j
|jd�|j
t|j�d�y)Na�        [program:one]
        command = /bin/cat

        [fcgi-program:two]
        command = /bin/cat

        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [fcgi-program:more]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [group:thegroup]
        programs = one,two,many,more
        priority = 5
        rrr�r�r9rlrOrQs       r�&test_mixed_process_groups_from_parser3z9ServerOptionsTests.test_mixed_process_groups_from_parser3�s�����
��.	;�$�&�����4� ��=�=�?���6�6�v�>������X���*��1�+��������z�2�����)�)�1�-�����W�4�4�5�q�9rc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nz�        [program:one]
        command = /bin/cat

        [fcgi-program:one]
        command = /bin/cat

        [group:thegroup]
        programs = onerrryrzs     r�-test_ambiguous_process_in_heterogeneous_groupz@ServerOptionsTests.test_ambiguous_process_in_heterogeneous_groupsR������	;�$�&�����4� ��=�=�?�����*�h�&I�&I� �	"rc��td�}ddlm}|�}|j|�|j	�}|jt|j|�y)Nzj        [program:one]
        command = /bin/cat

        [group:foo]
        programs = notthere
        rrryrzs     r�+test_unknown_program_in_heterogeneous_groupz>ServerOptionsTests.test_unknown_program_in_heterogeneous_groupsR����
��	;�$�&�����4� ��=�=�?�����*�h�&I�&I� �	"rc��tdtz�}ddlm}|�}|j	|�|j�}|j
|dd�}|jt|�d�|d}|j|dd�|j|dtjt�|j|dd	d
d��y)Nzv        [rpcinterface:dummy]
        supervisor.rpcinterface_factory = %s
        foo = bar
        baz = qux
        rr�supervisor.rpcinterface_factory�
rpcinterface:r��dummyr�r��qux)r�r�)rr%rrrr��get_pluginsrorp�sys�modules)rr�rr�r��	factories�factorys       r�test_rpcinterfaces_from_parserz1ServerOptionsTests.test_rpcinterfaces_from_parser!s�����
����	;�$�&�����4� ��=�=�?���(�(��)J�)8�:�	�	
����Y���+��A�,��������W�-�������S�[�[��%:�;�������E��%?�@rc��td�}ddlm}|j�}|�}tdd�|_|j
|�|j|dd�}|jt|�d�|d}|j|dd	�|j|dtjt�|j|d
ddi�y)Nzq        [rpcinterface:dummy]
        supervisor.rpcinterface_factory = %(factory)s
        foo = %(pet)s
        rrr�)r��petr�r�r�r�r�r�)rrrr�r%r�rr�rorpr�r�)rr�rr�r�r�r�s       r�1test_rpcinterfaces_from_parser_factory_expansionszDServerOptionsTests.test_rpcinterfaces_from_parser_factory_expansions5s�����
��
	;��=�=�?��$�&��(0��?������4� ��(�(��)J�)8�:�	�	
����Y���+��A�,��������W�-�������S�[�[��%:�;�������e�U�^�4rc�*�td�}ddlm}|�}|j|�|j	�}	|j|dd�|j
d�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nz]        [rpcinterface:dummy]
        # note: no supervisor.rpcinterface_factory here
        rrr�r�rzOsection [rpcinterface:dummy] does not specify a supervisor.rpcinterface_factory�
rrrrr�r�rr0ror�rms      r�.test_rpcinterfaces_from_parser_factory_missingzAServerOptionsTests.test_rpcinterfaces_from_parser_factory_missingIs�����
��	;�$�&�����4� ��=�=�?��	F�� � ��!B�!0�
2�
�I�I�&�'���	F����S�X�X�a�[�+E�
F�
F��	F���$A � 	B�)B
�
Bc�*�td�}ddlm}|�}|j|�|j	�}	|j|dd�|j
d�y#t$r)}|j|jdd�Yd}~yd}~wwxYw)Nz[        [rpcinterface:dummy]
        supervisor.rpcinterface_factory = nonexistent
        rrr�r�rz:nonexistent cannot be resolved within [rpcinterface:dummy]r�rms      r�5test_rpcinterfaces_from_parser_factory_not_importablezHServerOptionsTests.test_rpcinterfaces_from_parser_factory_not_importable[s�����
��	;�$�&�����4� ��=�=�?��	/�� � ��!B�!0�
2�
�I�I�&�'���	/����S�X�X�a�[�+.�
/�
/��	/�r�c��tj�}	|j�}||_d}||_|jd|d�}|dz}|dz}t
|d�}t
|d�}|j�|jtjj|��|jtjj|��|jtjj|��|j�|j�tj|d��y#tj|d��wxYw)	NrWr�r�z.1z.2r�Tr�)r�r�r�rcrb�get_autochildlog_namer��clear_autochildlogdirr�r{r�rBrmr�r�)	r�dnr��sid�logfn�first�second�f1�f2s	         r�test_clear_autochildlogdirz-ServerOptionsTests.test_clear_autochildlogdirms���
�
�
�
��	2��}�}��H�#%�H� ��C�"%�H���2�2�5�#�h�G�E��D�L�E��T�\�F��e�S�!�B��f�c�"�B��*�*�,����R�W�W�^�^�E�2�3����R�W�W�^�^�E�2�3����R�W�W�^�^�F�3�4��H�H�J��H�H�J��M�M�"�D�1��F�M�M�"�D�1�s�DD=�=Ec��|j�}d|_t�|_|j	�|j|jjdg�y)Nz!/tmp/this/cant/possibly/existjjjjzCould not clear childlog dir)r�rcr
rUr�ror�r�s  r�*test_clear_autochildlogdir_listdir_oserrorz=ServerOptionsTests.test_clear_autochildlogdir_listdir_oserror�sH���=�=�?��B���%�-����&�&�(�������-�-�0N�/O�Prc���tj�}|j�}||_|j}t
jj|d|z�}t|d�5}|jd�ddd�d�}||_
t�|_|j�|j|jjd|zg�y#1swY�]xYw)Nzcat-stdout---%s-ayWAp9.logr��logc�4�ttj��r/)rJr�ENOENTr�s r�
raise_oserrorzSServerOptionsTests.test_clear_autochildlogdir_unlink_oserror.<locals>.raise_oserror�s���%�,�,�'�'rzFailed to clean up '%s')r�r�r�rcrbr{r�r�r�r��remover
rUr�ror�)rrr��identr�r�r�s       r�)test_clear_autochildlogdir_unlink_oserrorz<ServerOptionsTests.test_clear_autochildlogdir_unlink_oserror�s����"�"�$���=�=�?��&����#�#���7�7�<�<��)E��)M�N��
�(�C�
 �	�A�
�G�G�E�N�	�	(�'���%�-����&�&�(�������-�-�
&��
1�2�	4�	�	�s�'C�Cc���t�}|j�}d�}||_g��fd�}||_|j	|�|jt
��d�d}|j�dj|��y)Nc�H�tjtj��r/)rer�r�
EADDRINUSE�rXs r�raise_eaddrinusezhServerOptionsTests.test_openhttpservers_reports_friendly_usage_when_eaddrinuse.<locals>.raise_eaddrinuse�s���,�,�u�/�/�0�0rc�(���j|�yr/r�r�s �rrzdServerOptionsTests.test_openhttpservers_reports_friendly_usage_when_eaddrinuse.<locals>.record_usage�rrr�z$Another program is already listeningr)	r	r��make_http_serversr�openhttpserversrorpr�r�)rrXr�rrr�rs      @r�;test_openhttpservers_reports_friendly_usage_when_eaddrinusezNServerOptionsTests.test_openhttpservers_reports_friendly_usage_when_eaddrinuse�sv���%�'���=�=�?��	1�%5��"���	%�%���� � ��-�����X���*�9��������.�.�x�8�9rc���t�}|j�}d�}||_g��fd�}||_|j	|�|jt
��d�dtjz}|j�d|�y)Nc�H�tjtj��r/)rer�r�EPERMr�s rrzbServerOptionsTests.test_openhttpservers_reports_socket_error_with_errno.<locals>.make_http_servers�s���,�,�u�{�{�+�+rc�(���j|�yr/r�r�s �rrz]ServerOptionsTests.test_openhttpservers_reports_socket_error_with_errno.<locals>.record_usage�rrr�zBCannot open an HTTP server: socket.error reported errno.EPERM (%d)r)	r	r�rrrrorprr�rrXr�rrr�rs      @r�4test_openhttpservers_reports_socket_error_with_errnozGServerOptionsTests.test_openhttpservers_reports_socket_error_with_errno�s}���%�'���=�=�?��	,�%6��"���	%�%���� � ��-�����X���*�0�27�+�+�>������!��h�/rc����t�}|j�}d�}||_g��fd�}||_|j	|�|jt
��d�d}|j�d|�y)Nc�,�tjd��)Nzuh oh)rer�r�s rrz^ServerOptionsTests.test_openhttpservers_reports_other_socket_errors.<locals>.make_http_servers�s���,�,�w�'�'rc�(���j|�yr/r�r�s �rrzYServerOptionsTests.test_openhttpservers_reports_other_socket_errors.<locals>.record_usage�rrr�z7Cannot open an HTTP server: socket.error reported uh ohr�r	r�rrrrorpr	s      @r�0test_openhttpservers_reports_other_socket_errorszCServerOptionsTests.test_openhttpservers_reports_other_socket_errors�sq���%�'���=�=�?��	(�%6��"���	%�%���� � ��-�����X���*�%������!��h�/rc����t�}|j�}d�}||_g��fd�}||_|j	|�|jt
��d�d}|j�d|�y)Nc��td��)N�not prefixed with help)r0r�s rrzWServerOptionsTests.test_openhttpservers_reports_value_errors.<locals>.make_http_servers�s���5�6�6rc�(���j|�yr/r�r�s �rrzRServerOptionsTests.test_openhttpservers_reports_value_errors.<locals>.record_usage�rrr�rrrr	s      @r�)test_openhttpservers_reports_value_errorsz<ServerOptionsTests.test_openhttpservers_reports_value_errors�so���%�'���=�=�?��	7�%6��"���	%�%���� � ��-�����X���*�+������!��h�/rc��t�}|j�}d�}||_|jt|j
|�y)Nc��t�r/)�
OverflowErrorr�s rrzgServerOptionsTests.test_openhttpservers_does_not_catch_other_exception_types.<locals>.make_http_servers�s���r)r	r�rrKrr)rrXr�rs    r�9test_openhttpservers_does_not_catch_other_exception_typeszLServerOptionsTests.test_openhttpservers_does_not_catch_other_exception_types�s@��%�'���=�=�?��	 �%6��"�	
���-�"�2�2�K�	Arc�j�|j�}|jd�}|j|d�y)NzNo user specified to setuid to!�r��drop_privilegesro�rr�r�s   r�test_drop_privileges_user_nonez1ServerOptionsTests.test_drop_privileges_user_none�s.���=�=�?���&�&�t�,������?�@rr�)r�N��")r�z	os.getuidrc��|j�}|jtj��}|j	|d�yr/)r�rr{�getuidrors   r�&test_drop_privileges_nonroot_same_userz9ServerOptionsTests.test_drop_privileges_nonroot_same_user�s5���=�=�?���&�&�r�y�y�{�3������d�#r)r�N�7rc�j�|j�}|jd�}|j|d�y)Nrvz$Can't drop privilege as nonroot userrrs   r�+test_drop_privileges_nonroot_different_userz>ServerOptionsTests.test_drop_privileges_nonroot_different_user�s0���=�=�?���&�&�r�*������D�Erc��|j�}d�|_t�|_|j	�|jj
j
�|jjj
�y)Nc��yr/r(r(rrr�zYServerOptionsTests.test_daemonize_notifies_poller_before_and_after_fork.<locals>.<lambda>
s�r)r��
_daemonizerr_�	daemonize�before_daemonize�assert_called_once_with�after_daemonizer�s  r�4test_daemonize_notifies_poller_before_and_after_forkzGServerOptionsTests.test_daemonize_notifies_poller_before_and_after_fork
sV���=�=�?��*����&����������(�(�@�@�B����'�'�?�?�ArN)�r%r&r'rr�r3r�r�r�r�r�r�r�rrr�r�r"r�r�r�r�r�r�r�r�r�r�r�r�r�rr
r
rrr r#r%r)r,r/r2r4r6rDrKrQrYr[r]rarrrgrprtr�r�r�r�r�r�r�r�rJr�r�r�r�r�r�r�r�r�r�r�r�r�r�r
rrrr"r(r-r0r4r7r9r<r>r@rBrDrFrHrJrLrTr]rjrnrqrurwr{r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr
rrrrr"r%r-r(rrr*r*�s����(�D�|1�|.�
.�"�B3�H:�(;� I�
I�7��&B�
I�
L�!5�F!>�F7�>5�:<�1�:�6�4�B�/�
A�E�;�F�0B�0+�"?�"@�  �, �,4�0 �, �(@� -��(�.�$��(�&�?�D�F�#�0�$�0�	.�.�	4�%�	4�-�B��.2�E��:�t��0�1��2��0E�d8�M�6R�"<�8�D�;�":�$:�$
;�A�}M�~3�6A�2=�4%.�N&.�P#2�J7�4"7�H	B�	B�7�
K�7�7�7�4�"
7�,�*,�*,�0:�&,;�\2+�h+�$B�&A�$7�&Q�
Q�W=�r>E�@Q�
Q�
Q�
Q�
Q�Q�Q�Q�Q�Q�:�.!:�F:�<":�H"�"
"�A�(5�(F�$/�$2�*Q�4� :�$0�&0�&0�$A�A�
�>�4�-B�C�D�
�;��"�-�.�$�/�E�$�
�>�4�-B�C�D�
�;��"�-�.�F�/�E�F�
Brr*c�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�ProcessConfigTestsc��ddlm}|S)Nr)�
ProcessConfig)rr1)rr1s  rrz"ProcessConfigTests._getTargetClass
r�rc��i}dD]}|||<�	dD]}d||<�	|j|�|j�|i|��S�N)r<rorYrZrmrprqrsrtrurvr�r�r�r��stderr_capture_maxbytes�stderr_events_enabledr�rwrzr{r|r�r�rk)rr}�stderr_logfile_backups�stderr_logfile_maxbytesrF�r2r�r�arg�kw�defaultsr<s     rr�zProcessConfigTests._makeOne
�g����	$�
	"�D�"�H�T�N�
	"�J�	 �D��H�T�N�	 �	�����%�t�#�#�%�s�7�h�7�7rc��t�}|j|d��}|j|j�|j��y)N�rk�rr�ro�get_path�rrFr�s   r�.test_get_path_env_is_None_delegates_to_optionszAProcessConfigTests.test_get_path_env_is_None_delegates_to_options#
s=���.���=�=��d�=�;������*�*�,�g�.>�.>�.@�Arc��t�}|j|ddi��}|j|j�|j��y)Nrr`r?r@rBs   r�8test_get_path_env_dict_with_no_PATH_delegates_to_optionszKProcessConfigTests.test_get_path_env_dict_with_no_PATH_delegates_to_options(
sA���.���=�=��u�c�l�=�C������*�*�,�g�.>�.>�.@�Arc���t�}|j|ddi��}|j|j�|j��|j	|j�gd��y)Nr�z/a:/b:/cr?)z/az/bz/c)rr��assertNotEqualrArorBs   r�(test_get_path_env_dict_with_PATH_uses_itz;ProcessConfigTests.test_get_path_env_dict_with_PATH_uses_it-
s\���.���=�=��v�z�6J�=�K�����H�-�-�/��1A�1A�1C�D�����*�*�,�.@�Arc��t�}|j|�}ddlm}||_||_|j
�|j|j|j�|j|j
|j�y)Nr)r�)	rr�rCr�rvr��create_autochildlogsro�
tempfile_name)rrFr�r�s    r�test_create_autochildlogsz,ProcessConfigTests.test_create_autochildlogs3
sn���.���=�=��)��2�"+���"+����%�%�'�����0�0�'�2G�2G�H�����0�0�'�2G�2G�Hrc���t�}|j|�}|j�}ddlm}|j|j|�|j|jd�y)Nr��
Subprocess�rr��make_process�supervisor.processrOror�r�rrFr��processrOs     r�test_make_processz$ProcessConfigTests.test_make_process=
sR���.���=�=��)���'�'�)��1�����*�*�J�7��������-rc���t�}|j|�}|jd�}ddlm}|j|j|�|j|jd�y)NrZrrNrPrSs     r�test_make_process_with_groupz/ProcessConfigTests.test_make_process_with_groupE
sT���.���=�=��)���'�'��.��1�����*�*�J�7��������.rc���t�}|j|�}tj�5}tj�5}|j|_|j|_d|_t|�}|j|�\}}|j|djd�ddlm
}|j|dj|�|j|dd�|j|djd�ddlm}	|j|dj|	�|j|dd�ddd�ddd�y#1swY�xYw#1swYyxYw)	NFr9r�r��ProcessCommunicationStdoutEvent�r���ProcessCommunicationStderrEvent)rr�r�r�r<rvr�r�r�make_dispatchersro�channel�supervisor.eventsrZ�
event_typer]�
rrFr�rvr��process1�dispatchersr�rZr]s
          r�+test_make_dispatchers_stderr_not_redirectedz>ProcessConfigTests.test_make_dispatchers_stderr_not_redirectedM
sC���.���=�=��)��
�
(�
(�
*�	5�n��,�,�.�
5�.�*8�*=�*=��'�*8�*=�*=��'�+0��(�'��1��%-�%>�%>�x�%H�"��U�� � ��Q��!7�!7��B�M�� � ��Q��!:�!:�!@�B�� � ��x��!�4�� � ��Q��!7�!7��B�M�� � ��Q��!:�!:�!@�B�� � ��x��!�4�
5�	5�	5�
5�
5��	5�	5�s$�E�C;E�E�E	�E�E&c�~�t�}|j|�}tj�5}|j|_t
|�}|j|�\}}|j|djd�|j|dd�|j|dd�ddd�y#1swYyxYw)Nr9r�r�)
rr�r�r�r<rvrr^ror_)rrFr�rvrcrdr�s       r�'test_make_dispatchers_stderr_redirectedz:ProcessConfigTests.test_make_dispatchers_stderr_redirectedb
s����.���=�=��)��
�
(�
(�
*�	4�n�&4�&9�&9�H�#�#�H�-�H�!)�!:�!:�8�!D��K�����[��^�3�3�X�>����U�8�_�a�0����U�8�_�d�3�
	4�	4�	4�s�A:B3�3B<N)
r%r&r'rr�rCrErHrLrUrWrergr(rrr/r/
s8���8�&B�
B�
B�I�.�/�5�*	4rr/c��eZdZd�Zd�Zd�Zy)�EventListenerConfigTestsc��ddlm}|S)Nr)�EventListenerConfig)rrk)rrks  rrz(EventListenerConfigTests._getTargetClassn
���:�"�"rc��i}dD]}|||<�	dD]}d||<�	|j|�|j�|i|��Sr3r8r9s     rr�z!EventListenerConfigTests._makeOner
r=rc�v�t�}|j|�}tj�5}tj�5}|j|_|j|_d|_t|�}|j|�\}}|j|djd�|j|djd�|j|djd�ddl
m}|j|djj |j"�|j|dd�|j|djd	�dd
lm}	|j|dj(|	�|j|d	d�ddd�ddd�y#1swY�xYw#1swYyxYw)NFrQr|r9r�r)�EventListenerStatesr[r�r\)rr�r�r�r<rvr�r�rr^ror_r`�supervisor.statesrorT�listener_state�ACKNOWLEDGEDr`r]ra)
rrFr�rvr�rcrdr�ror]s
          r�test_make_dispatchersz.EventListenerConfigTests.test_make_dispatchers�
s����.���=�=��)��
�
(�
(�
*�	5�n��,�,�.�
5�.�*8�*=�*=��'�*8�*=�*=��'�+0��(�'��1��%-�%>�%>�x�%H�"��U�� � ��Q��!7�!7��A�� � ��Q��!6�!6��>�� � ��Q��!7�!7��B�A�� � ��Q��!7�!7�!F�!F�!4�!A�!A�C�� � ��x��!�4�� � ��Q��!7�!7��B�M�� � ��Q��!:�!:�!@�B�� � ��x��!�4�#
5�	5�	5�
5�
5��	5�	5�s$�F/�E
F#�F/�#F,	�(F/�/F8N)r%r&r'rr�rsr(rrririm
s��#�8�&5rric�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�FastCGIProcessConfigTestsc��ddlm}|S)Nrr�)rr�)rr�s  rrz)FastCGIProcessConfigTests._getTargetClass�
s��;�#�#rc��i}dD]}|||<�	dD]}d||<�	|j|�|j�|i|��Sr3r8r9s     rr�z"FastCGIProcessConfigTests._makeOne�
r=rc�z�t�}|j|�}|jt|j�yr/)rr�rK�NotImplementedErrorrQrBs   rrUz+FastCGIProcessConfigTests.test_make_process�
s.���.���=�=��)�����-�x�/D�/D�Erc���t�}|j|�}|jd�}ddlm}|j|j|�|j|jd�y)NrZr)�FastCGISubprocess)rr�rQrRr{ror�r)rrFr�rTr{s     rrWz6FastCGIProcessConfigTests.test_make_process_with_group�
sU���.���=�=��)���'�'��.��8�����*�*�,=�>��������.rc�N�t�}|j|�}tj�5}tj�5}|j|_|j|_d|_t|�}|j|�\}}|j|djd�|j|djd�|j|djd�ddl
m}|j|dj|�|j|dd�|j|d	jd
�ddl
m}	|j|d	j|	�|j|d
d	�ddd�ddd�y#1swY�xYw#1swYyxYw)NFrQr|Tr9r�rrYr[r�r\)rr�r�r�r<rvr�r�rr^ror_r`r`rZrar]rbs
          rrsz/FastCGIProcessConfigTests.test_make_dispatchers�
sw���.���=�=��)��
�
(�
(�
*�	5�n��,�,�.�
5�.�*8�*=�*=��'�*8�*=�*=��'�+0��(�'��1��%-�%>�%>�x�%H�"��U�� � ��Q��!7�!7��A�� � ��Q��!6�!6��=�� � ��Q��!7�!7��B�M�� � ��Q��!:�!:�!@�B�� � ��x��!�4�� � ��Q��!7�!7��B�M�� � ��Q��!:�!:�!@�B�� � ��x��!�4�#
5�	5�	5�
5�
5��	5�	5�s$�F�D9F�>F�F	�F�F$N)r%r&r'rr�rUrWrsr(rrruru�
s��$�8�&F�
/�5rruc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�ProcessGroupConfigTestsc��ddlm}|S)Nr)�ProcessGroupConfig)rr�)rr�s  rrz'ProcessGroupConfigTests._getTargetClass�
���9�!�!rc�4�|j�||||�Sr/r�)rrFr<rmr�s     rr�z ProcessGroupConfigTests._makeOne�
s��%�t�#�#�%�g�t�X�x�H�Hrc� �t�}|j|ddg�}|j|j|�|j|jd�|j|j
d�|j|jg�y)N�whateverr�)rr�rorFr<rmrnrBs   r�	test_ctorz!ProcessGroupConfigTests.test_ctor�
ss���.���=�=��*�c�2�>������)�)�7�3�������
�3�����*�*�C�0�����1�1�2�6rc��t�}t|dd�g}|j|dd|�}|j�|j	|dj
d�y)Nrc�
/bin/process1r�r�rT�rr
r��after_setuidro�autochildlogs_created�rrFr�r�s    r�test_after_setuidz)ProcessGroupConfigTests.test_after_setuid�
sT���.�� ��*�o�F�G���=�=��*�c�8�D����������!��:�:�D�Arc��t�}t|dd�g}|j|dd|�}|j�}ddlm}|j
|j|�y)Nrcr�r�r�r)�ProcessGroup)rr
r��
make_grouprRr�ror�)rrFr�r�rr�s      r�test_make_groupz'ProcessGroupConfigTests.test_make_group�
sS���.�� ��*�o�F�G���=�=��*�c�8�D���#�#�%��3�������,�7rN)r%r&r'rr�r�r�r�r(rrr~r~�
s��"�I�7�B�8rr~c�$�eZdZd�Zd�Zd�Zd�Zy)�EventListenerPoolConfigTestsc��ddlm}|S)Nr)�EventListenerPoolConfig)rr�)rr�s  rrz,EventListenerPoolConfigTests._getTargetClass�
s��>�&�&rc	�:�|j�|||||||�Sr/r�)rrFr<rmrn�buffer_size�pool_eventsr[s        rr�z%EventListenerPoolConfigTests._makeOne�
s,��%�t�#�#�%�g�t�X�&5�{�&1�>�C�	Crc	��t�}t|dd�g}|j|dd|dgd�}|j�|j	|dj
d�y)Nrcr�r<r�r�rTr�r�s    rr�z.EventListenerPoolConfigTests.test_after_setuidsZ���.�� ��*�o�F�G���=�=��&�#�x��B��M����������!��:�:�D�Arc	���t�}t|dd�g}|j|dd|dgd�}|j�}ddlm}|j
|j|�y)Nrcr�r<r�r�r)�EventListenerPool)rr
r�r�rRr�ror�)rrFr�r�rr�s      rr�z,EventListenerPoolConfigTests.test_make_group
sZ���.�� ��*�o�F�G���=�=��&�#�x��B��M���#�#�%��8�������*;�<rN)r%r&r'rr�r�r�r(rrr�r��
s��'�C�B�=rr�c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�FastCGIGroupConfigTestsc��ddlm}|S)Nrr�)rr�)rr�s  rrz'FastCGIGroupConfigTests._getTargetClassr�rc�.�|j�|i|��Sr/r��rr�r;s   rr�z FastCGIGroupConfigTests._makeOne���%�t�#�#�%�t�2�r�2�2rc�p�t�}td�}|j|ddg|�}|j|j|�|j|j
d�|j|jd�|j|jg�|j|j|�y�Nrlr�r�)	rrr�rorFr<rmrnr�)rrF�sock_configr�s    rr�z!FastCGIGroupConfigTests.test_ctors����.��'��*���=�=��*�c�2�{�K������)�)�7�3�������
�3�����*�*�C�0�����1�1�2�6�����/�/��=rc���t�}td�}|j|ddg|�}td�}|j|ddg|�}|j||k(�|j	||k7�yr��rrr�r�r��rrF�sock_config1�	instance1�sock_config2�	instance2s      r�test_same_sockets_are_equalz3FastCGIGroupConfigTests.test_same_sockets_are_equal$�m���.��(��+���M�M�'�:�s�B��M�	�(��+���M�M�'�:�s�B��M�	����	�Y�.�/�����i�/�0rc���t�}td�}|j|ddg|�}td�}|j|ddg|�}|j||k7�|j	||k(�y)Nrlr�r�r[r�r�s      r�test_diff_sockets_are_not_equalz7FastCGIGroupConfigTests.test_diff_sockets_are_not_equal/r�rc��t�}td�}|j|ddg|�}|j�}ddlm}|j
|j|�y)Nrlr<r�r)�FastCGIProcessGroup)rrr�r�rRr�ror�)rrFr�r�rr�s      rr�z'FastCGIGroupConfigTests.test_make_group:sO���.��'��*���=�=��&�#�r�;�G���#�#�%��:�������*=�>rN)	r%r&r'rr�r�r�r�r�r(rrr�r�s ��"�3�>�	1�	1�?rr�c�$�eZdZd�Zd�Zd�Zd�Zy)�SignalReceiverTestsc�^�ddlm}|�}|j|j�d�y)Nr��SignalReceiver)rr�ror��rr��srs   r�test_returns_None_initiallyz/SignalReceiverTests.test_returns_None_initiallyCs#��5�
�
���������$�/rc��ddlm}|�}|jtjd�|jtj
d�|j
|j�tj�|j
|j�tj
�|j
|j�d�y�Nrr��frame)rr�r�rxr�r�ror�r�s   r�&test_returns_signals_in_order_receivedz:SignalReceiverTests.test_returns_signals_in_order_receivedHs{��5�
�
��
�
�
�6�>�>�7�+�
�
�
�6�>�>�7�+��������&�.�.�9��������&�.�.�9��������$�/rc�:�ddlm}|�}|jtjd�|jtjd�|j|j
�tj�|j|j
�d�yr�)rr�r�rxr�ror�r�s   r�%test_does_not_queue_duplicate_signalsz9SignalReceiverTests.test_does_not_queue_duplicate_signalsQsa��5�
�
��
�
�
�6�>�>�7�+�
�
�
�6�>�>�7�+��������&�.�.�9��������$�/rc���ddlm}|�}|jtjd�|j|j
�tj�|j|j
�d�|jtjd�|j|j
�tj�|j|j
�d�yr�)rr�r�rxr�ror�r�r�s   r�%test_queues_again_after_being_emptiedz9SignalReceiverTests.test_queues_again_after_being_emptiedYs���5�
�
��
�
�
�6�>�>�7�+��������&�.�.�9��������$�/�
�
�
�6�>�>�7�+��������&�.�.�9��������$�/rN)r%r&r'r�r�r�r�r(rrr�r�Bs��0�
0�0�0rr�c�l�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�UnhosedConfigParserTestsc��ddlm}|S)Nrr)rr)rrs  rrz(UnhosedConfigParserTests._getTargetClassdrlrc�.�|j�|i|��Sr/r�r�s   rr�z!UnhosedConfigParserTests._makeOnehr�rc��|j�}|jd�ddlm}|j	|j
|jdd�y)N�[supervisord]
r)�ConfigParserrX�missing)r�rr�r�rK�
NoOptionError�saneget)rr�r�s   r�test_saneget_no_defaultz0UnhosedConfigParserTests.test_saneget_no_defaultks@����������,�-�2����,�4�4��N�N�M�9�	6rc��|j�}|jd�|jddd��}|j|d�y)Nr�rXr�rZ�r;�r�rr�ro�rr��results   r�test_saneget_with_defaultz2UnhosedConfigParserTests.test_saneget_with_defaultrs@����������,�-����
�y�%��H�������'rc��|j�}ddi|_|jd�|jddd��}|j	|d�y)Nr�rYr�rXr��%(pet)sr��r�r�rr�ror�s   r�$test_saneget_with_default_and_expandz=UnhosedConfigParserTests.test_saneget_with_default_and_expandxsL�������"�E�N������,�-����
�u�i��H�������'rc��|j�}ddi|_|jd�|jdddd��}|j	|d�y)	Nr�rYr�rXr�r�F)r;�	do_expandr�r�s   r�#test_saneget_with_default_no_expandz<UnhosedConfigParserTests.test_saneget_with_default_no_expandsT�������"�E�N������,�-����
�u��� �0�������+rc��|j�}|jd�|jddd��}|j|d�y)N�[supervisord]
foo=%(pet)s
rXr�F)r�r�r�r�s   r�!test_saneget_no_default_no_expandz:UnhosedConfigParserTests.test_saneget_no_default_no_expand�s@����������9�:����
�u���F�������+rc��|j�}ddi|_|jd�|jdd�}|j	|d�y)Nr�rYr�rXr�r�r�s   r�(test_saneget_expands_instance_expansionszAUnhosedConfigParserTests.test_saneget_expands_instance_expansions�sH�������"�E�N������9�:����
�u�5�������'rc��|j�}ddi|_|jd�|jddddi��}|j	|d�y)Nr�rYr�rXr�r�)r�r�r�s   r�#test_saneget_expands_arg_expansionsz<UnhosedConfigParserTests.test_saneget_expands_arg_expansions�sV�������"�E�N������9�:����
�u��u�~� �'�������'rc��|j�}|jd|jz�|j|j	d�d�y)Nz
[%s]
foo=bar
r�r�)r�r�	mysectionro�
getdefault�rr�s  r�+test_getdefault_does_saneget_with_mysectionzDUnhosedConfigParserTests.test_getdefault_does_saneget_with_mysection�sB����������,�v�/?�/?�?�@�����*�*�5�1�5�9rc�,�|j�}tjd��5}|jd�|j	�|j|j�}ddd�|jjg�y#1swY�'xYw�Nr�r��[foo]
�r�r�r�r�r�r�r<ro�rr�r��ok_filenamess    r�test_read_filenames_as_stringz6UnhosedConfigParserTests.test_read_filenames_as_string�sq�������
�
(�
(�d�
3�	/�q�
�G�G�I��
�G�G�I�!�;�;�q�v�v�.�L�	/�	
�������x�0�		/�	/�s�=B
�
Bc�.�|j�}tjd��5}|jd�|j	�|j|jg�}ddd�|jjg�y#1swY�'xYwr�r�r�s    r�test_read_filenames_as_listz4UnhosedConfigParserTests.test_read_filenames_as_list�ss�������
�
(�
(�d�
3�	1�q�
�G�G�I��
�G�G�I�!�;�;����x�0�L�	1�	
�������x�0�		1�	1�s�>B�Bc��tjjtjjt�d�}|j�}t
jd��5}|jd�|j�|j||jg�}ddd�|jjg�y#1swY�'xYw)Nrr�r�r�)
r{r�r�rrr�r�r�r�r�r�r<ro)rrr�r�r�s     r�3test_read_returns_ok_filenames_like_rawconfigparserzLUnhosedConfigParserTests.test_read_returns_ok_filenames_like_rawconfigparser�s����g�g�l�l�2�7�7�?�?�8�#<�m�L�������
�
(�
(�d�
3�	>�q�
�G�G�I��
�G�G�I�!�;�;��Q�V�V�'<�=�L�	>�	
�������x�0�		>�	>�s�(?C
�
Cc�\�|j�}|j|ji�yr/)r�ro�section_to_filer�s  r�)test_read_section_to_file_initially_emptyzBUnhosedConfigParserTests.test_read_section_to_file_initially_empty�s#�����������/�/��4rc�F�|j�}tjd��5}|jd�|j	�|j|jg�ddd�|j|jdj�y#1swY�3xYw)Nr�r�r�r��	r�r�r�r�r�r�r<ror�)rr�r�s   r�'test_read_section_to_file_read_one_filez@UnhosedConfigParserTests.test_read_section_to_file_read_one_file�sz�������
�
(�
(�d�
3�	"�q�
�G�G�I��
�G�G�I��K�K�����!�	"�	
����/�/��6����?�		"�	"�s�>B�B c�F�|j�}tjd��5}tjd��5}|jd�|j	�|jd�|j	�|j|j|jg�ddd�ddd�|j|jdj�|j|jdj�y#1swY�dxYw#1swY�hxYw)Nr�r�r�z[bar]
r�r�r�)rr�r�r�s    r�-test_read_section_to_file_read_multiple_fileszFUnhosedConfigParserTests.test_read_section_to_file_read_multiple_files�s��������
�
(�
(�d�
3�	0�r��,�,�$�7�
0�2�����#����
�����#����
����R�W�W�b�g�g�.�/�
0�	0�	
����/�/��6����@�����/�/��6����@�
0�
0��	0�	0�s#�D�A*D�(D�D	�D�D N)r%r&r'rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r(rrr�r�csT��#�3�6�(�(�,�,�(�(�:�
1�1�1�5�@�
Arr�c��eZdZd�Zd�Zy)�UtilFunctionsTestsc�t�ddlm}|j|dd�d�|j|dd�d�y)Nr)�
make_namespecrrTz
group:process)rr�ro)rr�s  r�test_make_namespecz%UtilFunctionsTests.test_make_namespec�s3��4�����w�	�:�O�L�����y�)�<�i�Hrc���ddlm}|}|j|d�d�|j|d�d�|j|d�d�|j|d	�d�y)
Nr)�split_namespecz
process:group)rTrrT)rTrTzgroup:)rNzgroup:*)rr�ro)rr�r�s   r�test_split_namespecz&UtilFunctionsTests.test_split_namespec�s]��5�������?�+�-A�B�����9��'=�>�����8��o�6�����9���7rN)r%r&r'r�r�r(rrr�r��s
��I�
8rr�c�V�tjtjt�Sr/)�unittest�
findTestCasesr�r�r%r(rr�
test_suiter�s���!�!�#�+�+�h�"7�8�8r�__main__r)�defaultTest)+�__doc__r{r�r�rerrxr�rr�r�rrrtrrr�supervisor.loggersrr	r
rrr
rrr�TestCaserr�r*r/rirur~r�r�r�r�r�rr%�mainr(rr�<module>r
s^��'�	�
��
��
�
���&�&�7�7�+�1�-�.�-�.�.�3�(�e9�(�#�#�e9�NtA��*�*�tA�lO-B��*�*�O-B�bZ`4��*�*�`4�D-5�x�0�0�-5�`:5�� 1� 1�:5�x8�h�/�/�8�>=�8�#4�#4�=�4.?�h�/�/�.?�`0�(�+�+�0�BmA�x�0�0�mA�^8��*�*�8�9��z���H�M�M�l�+�r

Youez - 2016 - github.com/yon3zu
LinuXploit