Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/__pycache__/clselectctlpython.cpython-311.pyc

�

!�gy���D�ddlmZddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmcmcmZddlmZddlmZddlmZdd	lmZdd
lmZddlZddlmZm Z m!Z!m"Z"ddl#m$Z$m%Z%dd
l&m'Z'ddl(m)Z)m*Z*m+Z+ddl,m-Z-m.Z.ddl/m0Z0ddl1m2Z2m3Z3m4Z4ddl5m6Z6m7Z7dZ8dZ9dZ:dZ;dZ<ej=d��Z>d�Z?d4d�Z@d5d�ZA			d6d�ZBd�ZCd7d�ZDd5d �ZEd7d!�ZFd"�ZGd8d$�ZHd%�ZId5d&�ZJd7d'�ZKd7d(�ZLd7d)�ZMd*�ZNd+�ZOd,�ZPd-�ZQd.�ZRd/�ZSd9d1�ZTd:d3�ZUdS);�)�print_function)�absolute_import)�divisionN)�ConnectionError)�	iteritems�)�clpassenger)�clselectctl)�utils)�userdomains�docroot�cpusers�CP_NAME)�NoDomain�NotSupported)�mod_makedirs)�ApplicationsManager�PythonAppFormatVersion�get_venv_rel_path)�ClSelectExcept�BaseClSelectException)�clprint)�
extensions�environments�interpreters)�APP_STARTED_CONST�APP_STOPPED_CONSTzpassenger_wsgi.py�started�applicationz�import imp
import os
import sys


sys.path.insert(0, os.path.dirname(__file__))

wsgi = imp.load_source('wsgi', '%s')
application = wsgi.%s
aHimport os
import sys


sys.path.insert(0, os.path.dirname(__file__))


def %s(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    message = 'It works!\n'
    version = 'Python v' + sys.version.split()[0] + '\n'
    response = '\n'.join([message, version])
    return [response.encode()]
zJimp\.load_source\(.+, '(?P<script>.+)'\)\s+application.+\.(?P<callable>.+)c��td��td��td��td��td��td��td��td��td	��td
��td��td��td
��td��td��td��td��td��td��td��td��td��td��td��td��td��td��td��td��td��td��dS)Nz�Warning: selectorctl utility for --interpreter python is deprecated. Only update-interpreter option is still possible to use. 
Please, use cloudlinux-selector utility to manage your python applicationszF -v | --version VERSION                  : Specify alternative versionz3 -u | --user USERNAME                    : Usernamez^      --domain DOMAIN                    : Domain (or subdomain); users main domain as defaultzL -l | --list                             : List alternatives for interpreterzF -G | --list-extensions                  : List global set of packageszG -K | --list-extensions-version          : List version set of packageszG -s | --user-summary                     : List user summary of webappsz= -y | --create-webapp                    : Create user webappzi    | --update-interpreter               : Update binary python in virtual environment; you can use with zj                                           --user=* for all users; application name as default * (all app)z> -n | --destroy-webapp                   : Destroy user webappza -f | --relocate-webapp                  : Change webapp directory (files must be moved manually)zE -F | --transit-webapp                   : Change webapp domain/aliasz9 -Z | --restart-webapp                   : Restart webappz6 -t | --stop-webapp                      : Stop webappz^ -c | --user-current                     : Show currently selected alternative for user webappzQ -b | --set-user-current                 : Set alternative as user webapp defaultzc -e | --enable-user-extensions PACKAGES  : Install comma-separated list of packages for user webappze -d | --disable-user-extensions PACKAGES : Uninstall comma-separated list of packages for user webappzK                                         : Use '-' (minus) for all packageszb -r | --replace-user-extensions PACKAGES : Update comma-separated list of packages for user webappzN      --recreate-virtualenv              : Recreate python virtual environmentzX      --freeze-requirements              : Freeze virtual environment installed packageszR -g | --list-user-extensions             : List installed packages for user webappz5 -o | --setup-wsgi WSGI[:CALLABLE]       : Setup wsgizZ -p | --print-summary                    : If specified along with setting an alternative z>                                           prints user summaryz= -j | --json                             : Print data as JSONzO    | --verbose                          : show detail information about action)�print���Q/opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/clselectctlpython.py�usager%Rs���	�Y�Z�Z�Z�
�
R�S�S�S�	�
?�@�@�@�	�
j�k�k�k�	�
X�Y�Y�Y�	�
R�S�S�S�	�
S�T�T�T�	�
S�T�T�T�	�
I�J�J�J�	�
u�v�v�v�	�
v�w�w�w�	�
J�K�K�K�	�
m�n�n�n�	�
Q�R�R�R�	�
E�F�F�F�	�
B�C�C�C�	�
j�k�k�k�	�
]�^�^�^�	�
o�p�p�p�	�
q�r�r�r�	�
W�X�X�X�	�
n�o�o�o�	�
W�X�X�X�	�
Z�[�[�[�	�
d�e�e�e�	�
^�_�_�_�	�
A�B�B�B�	�
f�g�g�g�	�
J�K�K�K�	�
I�J�J�J�	�
[�\�\�\�\�\r#Tc��t||��\}}|s|}tj|||��}|���r|st	j|j���|���sT	tjd���|}n"#t$rt	j	|���wxYw|�
|��|S)a#
    Create new environment (or use existing if use_existing=True)
    :param user: unix user name that app belongs to
    :param directory: app root
    :param version: python version
    :param env_name: DEPRECATED
    :param use_existing: do not raise exception if env already exists
    �version��key)rr�Environment�existsr�EnvironmentAlreadyExists�pathr�KeyError�NoSuchAlternativeVersion�create)	�user�	directoryr'�env_name�use_existing�_�prefix�environment�interpreters	         r$�_create_environmentr9vs���"�$�	�2�2�I�A�v������*�8�T�6�B�B�K������H�L�H��5�k�6F�G�G�G������(�	C�&�3�	�B�B�B�7�K�K�K���	C�	C�	C� �9�'�B�B�B�	C�������;�'�'�'��s�2B�B-c�Z�|�t��}	|r	|d}n.|�||tj|��j��}n]#t
j$rKtj|���	|��}|�tj
d|z���|d}YnwxYwtj�
tj�tj�|������}t||��\}}t!j|||��}|S)N�binary�8No such application (or application not configured) "%s")r�get_binary_path�pwd�getpwnam�pw_dirr�ConfigMissingErrorr	�summary�get�WebAppError�osr-�basename�dirnamerrr*)	r1r2�app_summary�apps_managerr;r3r5r6r7s	         r$�_get_environmentrJ�s����*�,�,��'��	^� ��*�F�F�!�1�1�$�	�3�<�PT�CU�CU�C\�]�]�F����,�'�'�'�"�)�$�/�/�3�3�I�>�>���� �,�-g�js�-s�t�t�t��X�&����
'�����w������������0G�0G� H� H�I�I�H�!�$�	�2�2�I�A�v��*�8�T�6�B�B�K��s�9A�AB&�%B&c
�f�|	�t��}	|�tjd���tj|��}tj|��}	tj|||��}tj	|d���#t$rYnwxYwt|||d���}
|
���j
}tj||||	j|||
���tj||��|rt"|z}nt
j}|r�|t&kr�t)|||��}t*j�|��}t*j�|��st3|d��tj||��|rt7||||��nAt&}t)|||��}tj||��|rt7||||��|si}|st8}|s2tj|��}tj|||��}|d}|t:j||t>|g||d	�	}|
r|
|d
<|	� |||��	|	�!||||��dS#tD$r0}tGj$ddtK|��d
���Yd}~dSd}~wwxYw)a�
    Create new python application
    :param user: unix user name
    :param directory: application path in user's home (app-root)
    :param alias: alias (app-uri)
    :param version: version of interpreter
    :param doc_root: doc_root
    :param env_vars: dict with environment variables
    :param startup_file: main application file
    :param domain_name: domain name
    :param entry_point: application entry point
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :param passenger_log_file: Passenger log filename to write to app's .htaccess
    :return: None
    NzNot passed version as argumentr2F)r4)�doc_root�passenger_log_filei��domain)	�python_version�app_versionrN�app_uri�
app_status�startup_file�config_files�env_vars�entry_pointrM�text�ERROR��status�message)&rr�	WrongDatar
�	get_aliasr	rBr�get_using_realpath_keys�AppRootBusyr.r9r8r;�	configure�INTERPRETER�restart�_CONFIGURABLE_WSGI_TEMPLATE�
WSGI_TEMPLATE�DEFAULT_STARTUP_FILE�_get_full_path_to_startup_filerEr-rGr+r�
file_write�
setup_wsgi�DEFAULT_APP_ENTRYPOINTr�STABLE�DEFAULT_APP_STATE�add_app_to_config�add_env_vars_for_htaccess�	Exceptionr�
print_diag�str)r1r2�aliasr'rLrUrS�domain_namerVrIrM�user_summaryrHr7r;�content�startup_file_name�dir_name�summary_data�app_data�errs                     r$r0r0�s3��(��*�,�,�����&�'G�H�H�H��!�%�(�(�E��&�t�,�,�L�C��3�D�)�\�R�R���(��[�)A�B�B�B���
�
�
���
����
&�d�I�w�U�S�S�S�K�
�
$�
$�
&�
&�
-�F���$�	�5�,�2J�F�]e�/A�C�C�C�C����i�(�(�(��,�-��;����+���H��(<�<�<�:�4��L�Y�Y���7�?�?�#4�5�5���w�~�~�h�'�'�	*���5�)�)�)�
��*�G�4�4�4��	H��t�Y�(9�;�G�G�G��,��;�4��L�Y�Y��
��*�G�4�4�4��	H��t�Y�(9�;�G�G�G������-�-���,�"�*�4�0�0���3�D�)�\�R�R��!�(�+��#�.�5���(�%���#�
�
�H��=�*<��&�'��"�"�4��H�=�=�=�M��.�.�t�Y��(�S�S�S�S�S���M�M�M���6�g�#�c�(�(�#K�#K�L�L�L�L�L�L�L�L�L�����M���s*�B�
B
�B
�I6�6
J0�%J+�+J0c��ddlm}|����|��st	j||d���dS)z�
    Check whether particular interpreter version is enabled and raises
    exception if not
    :param user: user to include in exception
    r)�python_managerzversion is not enabledN)�clselectpythonr{�
PythonManager�is_version_enabledr�UnableToSetAlternative)r'r1r{s   r$�_ensure_version_enabledr�s_��/�.�.�.�.�.��'�'�)�)�<�<�W�E�E�5��3��'�3�5�5�	5�5�5r#c��d}d}d}tjj�tj��t
|��stjd���d�	||���}	tj
|d���}nc#t$rV|�d	d
��}	tj
|d���}n%#t$rtj
||z���wxYwYnwxYw|j�
d��}|j�
d��}	|��	tj
|d���}n%#t$rtj
||z���wxYw|j�
d��}
|j�
d��}|���|
���ks&|	|kr|	�|	d
d�dks|�(|d
d�dkrtj
||||
fz���d
Sd
S)a@
    Check response from user's webapp before and after calling action.
    Also compare both responses
    :param domain: domain associated with webapp
    :param alias: URI associated with webapp
    :param action: called action, that make something with webapp: install modules, transit it, etc
    :return: None
    zTWeb application is inaccessible by its address "%s". The operation wasn't performed.z�The operation was performed, but check availability of application has failed. Web application is inaccessible by its address "%s" after the operation.z�The operation was performed, but check availability of application has failed. Web application responds, but its return code "%s" or content type before operation "%s" doesn't equal to contet type after operation "%s".z+Wrong action for calling in checking webappzhttps://{domain}/{alias})rNrqF)�verifyzhttps://zhttp://zContent-Type�StatusN��500)�requests�packages�urllib3�disable_warnings�urllib_exceptions�InsecureRequestWarning�callablerr\�formatrCr�replacerD�headers�lower)rNrq�action�app_is_inaccessible_before�app_is_inaccessible_after�
app_is_broken�
webapp_url�request�before_mime_type�
before_status�after_mime_type�after_statuss            r$�check_response_from_webappr�sn��"y��!k��m�M�
���.�.�/@�/W�X�X�X��F���V��&�'T�U�U�U�+�2�2���3���J�V��,�z�%�8�8�8�����V�V�V��'�'�
�I�>�>�
�	V��l�:�e�<�<�<�G�G���	V�	V�	V� �,�-G�*�-T�U�U�U�	V����
�G�	V������*�*�>�:�:���O�'�'��1�1�M�
�F�H�H�H�Q��,�z�%�8�8�8�����Q�Q�Q��(�)B�Z�)O�P�P�P�Q�����o�)�)�.�9�9�O��?�&�&�x�0�0�L������?�#8�#8�#:�#:�:�:�	�,�	&�	&�=�+D��WY�XY�WY�IZ�^c�Ic�Ic��(�\�"�1�"�-=��-F�-F��(��,�HX�Zi�9j�)j�k�k�k�)�(�-F�-Fs6�0B� C'�(B?�>C'�?"C!�!C'�&C'�)E�"E"c������tjd�����tjd����d}t���}��fd�|D��}t|��dkrtjd���|d}||fS)z�
    Get info (alias and domain) about user's web application
    :param app_summary: dict -> summary info about user's web application
    :param user: str -> name of unix user
    :return: tuple -> (alias, domain)
    Nz3Was passed incorrect summary info about applicationz!Was passed incorrect name of userrqc�R��g|]#\}}tj�|�d���!|��$S)r
)r�realpaths_are_equal)�.0rNrLrHr1s   ��r$�
<listcomp>z*_get_info_about_webapp.<locals>.<listcomp>ZsN���R�R�R�'�v�x��(��x��Y�9O�P�P�R��R�R�Rr#rz-Can not found suitable domain for application)rr\r�len)rHr1rq�user_domains�
found_domains�
app_domains``    r$�_get_info_about_webappr�Ls��������&�'\�]�]�]��|��&�'J�K�K�K��� �E��t�$�$�L�R�R�R�R�R�+7�R�R�R�M��=���Q����&�'V�W�W�W��q�!�J��*��r#c���|�t��}|�||��}	|�|�||d|��n<#t$r/}t	jddt
|��d���Yd}~nd}~wwxYw|��|�d��tkr�tj
|��j}tj
�|t||��d��}	t!j|��n#t$$rYnwxYw|�+|�|||��}t)j|��|�||��t)j||��dSt||��\}	}
t1j||
��\}}		t!j|��n#t$$rYnwxYwt)j|��}|�||��}
	t1j|||��n*#t8$r|
rYdSt;jd|z���wxYwt)j||��	t)j||��dS#t:j $rYdSwxYw)aa
    Destroy web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    NrWrXrYrRrr<)!r�get_app_configrmrnrrorprCrr>r?r@rEr-�joinr�shutil�rmtree�OSError�get_htaccess_by_appdirr	�$remove_passenger_lines_from_htaccess�remove_app_from_configrbr�get_abs_relrBr^r.rr\�unconfigure�MissingApprootDirectory)r1�
app_directoryrLrI�
app_configry�	user_home�virtual_env_path�htaccess_filenamer5r6�abs_dirrs�
app_in_configs              r$�destroyr�ds�����*�,�,���,�,�T�=�A�A�J�M����2�2�4���h�W�W�W����M�M�M���6�g�#�c�(�(�#K�#K�L�L�L�L�L�L�L�L�����M������*�.�.��">�">�BS�"S�"S��L��&�&�-�	��7�<�<��(��}�=�=�a�@�B�B��	��M�*�+�+�+�+���	�	�	��D�	������ ,� C� C�D�-�Ya� b� b���<�=N�O�O�O��+�+�D�-�@�@�@���D�-�0�0�0���
"�$�
�6�6�I�A�v��"�4��0�0�J�G�Q�
��
�g�������
�
�
���
�����&�t�,�,�L� �7�7��m�L�L�M�<�
�%�d�M�<�H�H�H�H���<�<�<��	<��4�4� �*�+g�-:�,;�<�<�
<�<������D�-�0�0�0�
���D�-�0�0�0�0�0���1�
�
�
����
���s_�A�
A<�
%A7�7A<�-D�
D�D�F-�-
F:�9F:�(G?�?H&�H&�?I�I)�(I)c�(��tj|��}tj|tj��\}}t
jtj�	|dd����D�]%}t
jtj�	|dd����D]�}tj�
|��r�"tj|d��}g}|����d|vrJ|�
��D]4}d|vrtjd�fd�|��}|�|���5n1|�d��r|�
��}d�z|d	<|r tj|d
�|D��d�����'dS)N�*�bin�rbsVIRTUAL_ENVs+VIRTUAL_ENV[^\\]([\"\'])(?P<old_path>.+)\1$c�|��|�d���|�d�����S)Nr�old_path)�groupr�)�m�encoded_envs �r$�<lambda>zfix_homedir.<locals>.<lambda>�s-���a�g�g�a�j�j�&8�&8�����9L�9L�k�&Z�&Z�r#s#!s#!%s/bin/pythonrc3� K�|]	}d|zV��
dS)s%s
Nr")r��lines  r$�	<genexpr>zfix_homedir.<locals>.<genexpr>�s&����.U�.U�$�w��~�.U�.U�.U�.U�.U�.Ur#�wb)r
�get_userrr�r�DEFAULT_PREFIX�globrEr-r��islink�	file_read�encode�
splitlines�re�sub�append�
startswith�file_writelines)	r1�envsr5�env�script�
old_script�
new_scriptr�r�s	        @r$�fix_homedirr��s�������%�%�D����l�&A�B�B�G�D�!��y�����d�C��5�5�6�6�]�]���i�����S�%�� =� =�>�>�	]�	]�F��w�~�~�f�%�%�
������6�6�J��J��*�*�,�,�K���+�+�&�1�1�3�3�,�,�D�%��-�-� "�v�K�Z�Z�Z�Z� � "� "���%�%�d�+�+�+�+�,��&�&�u�-�-�
A�'�2�2�4�4�
� 2�[� @�
�1�
��
]��%�f�.U�.U�*�.U�.U�.U�W[�\�\�\��1	]�]�]r#Fc�*����
�|�t��}tj|��}|�|��}	t	j|�|��}n5#t$r(tjd�	������wxYw|dtkrd}t|�|����
��
��fd�}|sO	t|d|d|�	��dS#tj
$r}	tj
d
|	z���d}	~	wwxYw|��dS)a
    Install defined extension to python web application
    :param requirements_path: path to the text file with list of python modules for installation
    :param user: name of owner of web application
    :param directory: application's root
    :param extension: name of installed module
    :param skip_web_check: skip check web application after change it's properties
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    Nz%Record about application {} is absentrRT�rIc����������dS��5��tj�������dSdS�N)�extension_install�extension_install_requirementsrEr-r�)r2r7�	extension�requirements_paths����r$r�zinstall.<locals>.action�s\���� ��)�)�)�4�4�4�4�4�
�
*��6�6�r�w�|�|�I�O`�7a�7a�b�b�b�b�b�+�
*r#rNrQ)rNrqr�z3An error occured during installation of modules. %s)rr
r��get_user_config_datarr^r.rr\r�rrJr�rD)r1r2r�r��skip_web_checkrI�user_configrxr�ryr7s ```      @r$�installr��s���������*�,�,�����%�%�D��3�3�D�9�9�K�b��0��y�+�N�N�����b�b�b��&�'N�'U�'U�V_�'`�'`�a�a�a�b�������!2�2�2���"�4���N�N�N�K�c�c�c�c�c�c�c�c��
�	j�&���)��y�)��
�
�
�
�
�
��
�)�	j�	j�	j� �,�-b�eh�-h�i�i�i�����	j����	������s#�A�2B�;C�D�*D�Dc�r�tj|��}t||��}|���Sr�)r
r�rJr)r1r2r7s   r$�list_extensionsr�s3�����%�%�D�"�4��3�3�K��!�!�#�#�#r#c�B�|�t��}|�||��}|�2|�d��tkr|�t	|||��n/tj|��}||vrtjd|z���tj	||��dS)ab
    Restarts web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    NrRr<)
rr�rCr�startr	rBrr\rb)r1r�rLrIr��apps_summarys      r$rbrbs�����*�,�,���,�,�T�=�A�A�J���*�.�.��">�">�BS�"S�"S����$�
�x�0�0�0��"�*�4�0�0����,�,� �*�J�]�Z�\�\�
\����m�,�,�,�,�,r#c�~�|�t��}|�||��}|�tjd|z���|�d��t
krdS|�||||��}tj|��|�	||t
��tj
||��dS)a_
    Stops web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    Nr<rR)rr�rr\rCrr�r	r��set_app_statusrb)r1r�rLrIr�r�s      r$�stopr�"s�����*�,�,���,�,�T�=�A�A�J����&�'c�)6�(7�8�8�	8��~�~�l�#�#�'8�8�8���$�;�;�D�-�QY�[e�f�f���4�5F�G�G�G�����m�5F�G�G�G����m�,�,�,�,�,r#c�*�|�t��}|�||��}|�tjd|z���|�d��t
krdS|�|||��|�||t
��tj	||��|�d��}|tkrKt|||�d����}t||||�d����dSdS)a`
    Starts web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    Nr<rRrSrV)
rr�rr\rCr�update_htaccess_filer�r	rbrerfrh)r1r�rLrIr�rS�startup_file_full_paths       r$r�r�@s&����*�,�,���,�,�T�=�A�A�J����&�'c�)6�(7�8�8�	8��~�~�l�#�#�'8�8�8����%�%�d�M�8�D�D�D�����m�5F�G�G�G����m�,�,�,��>�>�.�1�1�L��+�+�+�!?����N�N�>�*�*�"
�"
��
	�4��(>�
���}�@]�@]�^�^�^�^�^�
,�+r#c��tj|��}tj||��\}}t	j|��}||vrt
jd|z���tj	�
|��r�tj	�|��st
jd|z���tj||��d�
tj	j��}|st
jd���nt
jd���tj	�|tj��}|st"}tj|t&||fzd��t	j||��dS)Nr<zNo such WSGI script "%s"�z&WSGI script is not in webapp directoryz$Path to WSGI script must be absolute�w)r
r�rr�r	rBrr\rEr-�isabs�isfile�s_partition�strip�sepr��	WSGI_PATHrirgrdrb)r1r2�	wsgi_path�callable_objectr�r5r��app_wsgis        r$rhrhgs[�����%�%�D��"�4��3�3�J�G�Q��&�t�,�,�L���$�$��&�'c�fo�'o�p�p�p�	�w�}�}�Y���O��w�~�~�i�(�(�	U� �*�+G�)�+S�T�T�T��%�i��9�9�!�<�B�B�2�7�;�O�O�	��	U� �*�+S�T�T�T�	U��&�'M�N�N�N��w�|�|�G�[�%:�;�;�H��1�0��	��X�}�	�?�/K�K�S�Q�Q�Q����i�(�(�(�(�(r#c��tj|��j}tj�|d��}tj�|��S)z9
    return True if user home dir has virtualenv dir
    �
virtualenv)r>r?r@rEr-r��isdir)r1�homedirr-s   r$�has_virtenv_dirrs?���l�4� � �'�G�
�7�<�<���.�.�D�
�7�=�=����r#c	�.�tj|��}i}t|��s|Stt	j|����D�]J\}}|dtjkr�	t|||���	��}tj�|dtj
��}tj|��}t �|��}|r%|���}|d}	|d}
ndx}	}
|d|d|d|d|d	|	|
d
�d�}d|vr$t'|d��d
kr|d|d<n(#t($r}dt+|��i}Yd}~nd}~wwxYw|||<��L|S)Nr8r2r�r��rqrN�namer)r�r�)rqrNr7r8r�wsgi�domainsr�error)r
r�rrr	rBrrarJ�as_deepdictrEr-r�r�rr��WSGI_PATTERN�search�	groupdictr�rnrp)
r1�summr2�datar7r��	wsgi_conf�matchrr�r��env_info�es
             r$rBrB�s������%�%�D�
�D��4� � ����$�[�%8��%>�%>�?�?�#�#��	�4��
��"5�"A�A�A��	)�*�4��D�A�A�M�M�O�O�K��w�|�|�D��$5�{�7L�M�M�H����1�1�I� �'�'�	�2�2�E��
1�!�O�O�-�-�	�%�h�/�	�"+�J�"7���.0�0�	�O��g���x�.�*�6�2�*�=�9�)�,�7�#,�/�J�J�
��H��D� � �S��i��%9�%9�A�%=�%=�&*�9�o���#����	)�	)�	)���Q���(�H�H�H�H�H�H�����	)����#��Y����Ks�'C>E&�&
F�0F�Fc�r�tj||��\}}tj�||��S)z�
    :param user: name of system user
    :param directory: name of dir with python applicatoin
    :param startup_file: name of startup file of python application
    Get full path to startup file of python application
    )rr�rEr-r�)r1r2rSr��rel_dirs     r$rfrf�s1���(��y�9�9��G�W�
�7�<�<���.�.�.r#c�x�tj|��}t||��}|�|��dSr�)r
r�rJ�extension_uninstall�r1r2r�r7s    r$�	uninstallr�s;�����%�%�D�"�4��3�3�K��#�#�I�.�.�.�.�.r#c�x�tj|��}t||��}|�|��dSr�)r
r�rJ�extension_updaters    r$�updater�s;�����%�%�D�"�4��3�3�K�� � ��+�+�+�+�+r#c	���!�	tjtjdd�dgd���\}}nj#tj$rX}tj�t
|����t��tjd��Yd}~nd}~wwxYwd}d}d}d}d}d}d}	d}
|s"t��tjd��d�!t�!fd�|D����s,tj|d	d
d���tjd��|D�]:\}}|dvr�|d
vrd}	�|dvrd}	�|dkrd}	�"|dvrd}	�)|dvrd}	�0|dvrd}	�7|dvrd}	�>|dvrd}	�E|dvrd}	�L|dvrd }	�S|d!vrd"}	�Z|d#vrd$}	�a|d%vrd&}	|}�j|d'vrd(}	|}�s|d)vrd*}	|}�||d+vrd,}	��|d-vrd.}��|d/krd0}��|d1vrd2}	|}��|d3vrd4}	|}��|d5vr|}
��|d6vrd7}	��|d8vr|�d9��}��|d:kr|}��|d;vrd<}	tj|d=��\}
}}��|d>vrd0}��|d?vrd@}	|}��tj�dA��tjd����<|	dkr3tj�dB��tjd��|	dCvr5|s3tj�dD��tjdE��|dFkr:|	d&kr3tj�dG��tjdH��n!|rdI�|�dJ��D��}|r�	t!|��\}}n~#t"$r2tj|d	dK|zd���tjd��YnCt$$r7tj|d	dLt&zd���tjd��YnwxYw|s|}�n||kr3tj|d	dM|�dN|�dO�d���tjd��n�|	dPvrf	t)j|��}nP#t,$rC}tj|d	t
|��d���tjd��Yd}~nd}~wwxYw|rf|	dks`	t/|��}nD#t$$r7tj|d	dLt&zd���tjd��YnwxYw|dQ\}}	dQ}dQ}i}|	d7krt1dR|	z���|	d@kr*t3j���|��}d}�n|	dkrt9jdS��}�n�|	d,krt=|��}�n�|	dkr"t?||dQ|d|
|�T���n�|	dkrFdU}tA|��dkr|dQ�d9��}tC|||
f|�V���n[|	dkrtE||dQ|���n<|	dkrt1dR|	z���|	dkrd}|r|}t1dR|	z���|	dkrtG||dQ|���n�|	dkrtI||dQ|���n�|	dkrtK||dQ|���n�|	d krt1dR|	z���|	d"krt1dR|	z���|	d$krtM||dQ��}�n[|	d<krtO||dQ|
|���n;|	d(kr,tQj(��D]}|�)����n	|	d*kr+tQj(��D]}|�*���n�|dQ}|dFkrtM||��}|D]�}	|	d&krtW|||��n/|	d4krtY|||��n|	d2krt[|||��|�-|dWdXii��|dz
}�i#t,t\j/f$r6}|�-|d	t
|��d�i��|dz
}Yd}~��d}~wwxYwn�#t`t2j1f$rC}tj|d	t
|��d���tjd��Yd}~n�d}~wt$$r7tj|d	dLt&zd���tjd��YnUtd$rI}tgj4��}tj|d	|d���tjd��Yd}~nd}~wwxYw|s|rt=|��}|r|rdY}dZ}ns|rd	}d[}nl|rA|dZkr;|r#tj5|t=|����n+tj5|i��ntj5||��tjdQ��d\�6d]�to|��D����} tj||| d���tj|��dS)^Nrzhi:v:u:lGsynfFZtcbe:d:r:go:pjK:)�helpzinterpreter=zversion=zuser=zdomain=�list�list-extensions�user-summary�
create-webapp�update-interpreter�destroy-webapp�relocate-webapp�transit-webapp�restart-webapp�start-webapp�stop-webapp�user-current�set-user-currentzenable-user-extensions=zdisable-user-extensions=zreplace-user-extensions=�recreate-virtualenv�freeze-requirements�list-user-extensionszsetup-wsgi=z
print-summary�json�verbosezlist-extensions-version=rrWF)�--update-interpreterc3�,�K�|]}|d�vV��dS)rNr")r��item�allowed_optss  �r$r�zmain.<locals>.<genexpr>s,�����8�8�4�t�A�w�,�&�8�8�8�8�8�8r#rXz�Unsupported option was passed. Currently, selectorctl utility supports only update-interpreter option. Please, use cloudlinux-selector utility for python interpreterrY)z-iz
--interpreter)z-lz--listr)z-yz--create-webappr r/r!)z-nz--destroy-webappr")z-fz--relocate-webappr#)z-Fz--transit-webappr$)z-Zz--restart-webappr%)z-Sz--start-webappr&)z-tz
--stop-webappr')z-cz--user-currentr()z-bz--set-user-currentr))z-gz--list-user-extensionsr,)z-ez--enable-user-extensions�enable-user-extensions)z--recreate-virtualenvr*)z--freeze-requirementsr+)z-sz--user-summaryr)z-jz--jsonr-z	--verboseT)z-rz--replace-user-extensions�replace-user-extensions)z-dz--disable-user-extensions�disable-user-extensions)z-vz	--version)z-Gz--list-extensionsr)z-uz--userz'"z--domain)z-oz--setup-wsgi�
setup-wsgi�:)z-pz--print-summary)z-Kz--list-extensions-versionzlist-extensions-versionzunhandled optionz4ERROR:you must provide option for interpreter python)r r"r#r$r%r&r'r3r,r4r5r6r(r)zwebapp must be specifiedr��-z.installation of all extensions is not possible�c��g|]}|�|��Sr"r")r��_fs  r$r�zmain.<locals>.<listcomp>ks��8�8�8��R�8��8�8�8r#�,zNo such domain: "%s"z$Python selector not supported for %szdomain "z" is not owned by the user "�")r r"r#r$r%r&r'r3r,r4r5r6rr!r(r)rz'%s is deprecated in old python selectorr')rLr�)r1�app_namer'r.rZ�OK�PARTIALr���
c
3�zK�|]6\}}|�d|�d|�dd������V��7dS)z: r[rZrN)rC)r��k�vs   r$r�zmain.<locals>.<genexpr>sb����'�'��A�q��A�A�q�u�u�Y����h��(;�(;�<�<�<�=�'�'�'�'�'�'r#)8�getopt�sys�argv�GetoptError�stderr�writerpr%�exit�anyrror�rr��splitr
rrrr
r��
ValueErrorr�DeprecationWarningr�
ExtensionInfo�list_extensions_versionr�interpreters_dictrBr0r��update_interpreterr�rbr�r�r�rhr�recreate�
pip_freezer�rrr�ExternalProgramFailedr�PyPIRpcApiErrorrn�	traceback�
format_exc�
print_datar�r)"�opts�argsry�ext_list�fmtr.�
print_summaryr1rNr�r'�o�ar�r5r��_extsrL�user_r�domain_listr�ok�resultr>�new_doc_rootr�rqr��msgrZ�exit_statusr[r2s"                                 @r$�mainrk�s
���%��]��H�Q�R�R�L�-�0�0�0� � �
��d�d��B������
����S���"�"�"�
�����������������������
�H�
�C��G��M��D�
�F�
�F��G���
����������-�L��8�8�8�8�4�8�8�8�8�8����3�7�-:�!;�!;�	<�	<�	<�
	�������B�B���1��'�'�'��
�"�
"�
"��F�F�
�+�
+�
+�$�F�F�
�(�
(�
(�)�F�F�
�,�
,�
,�%�F�F�
�-�
-�
-�&�F�F�
�,�
,�
,�%�F�F�
�,�
,�
,�%�F�F�
�*�
*�
*�#�F�F�
�)�
)�
)�"�F�F�
�*�
*�
*�#�F�F�
�.�
.�
.�'�F�F�
�2�
2�
2�+�F�F�
�4�
4�
4�-�F��H�H�
�,�
,�
,�*�F��H�H�
�,�
,�
,�*�F��H�H�
�*�
*�
*�#�F�F�
�"�
"�
"��C�C�
�+�
�
��G�G�
�5�
5�
5�.�F��H�H�
�5�
5�
5�.�F��H�H�
�%�
%�
%��G�G�
�-�
-�
-�&�F�F�
�"�
"�
"��7�7�5�>�>�D�D�
�*�_�_��F�F�
�(�
(�
(�!�F�,1�,=�a��,E�,E�)�I�q�/�/�
�+�
+�
+� �M�M�
�5�
5�
5�.�F��H�H��J���/�0�0�0��H�Q�K�K�K�K�
��|�|��
���O�P�P�P�������
���� �	��J���7�8�8�8��H�Q�K�K�K��3����-�-�-��J���M�N�N�N��H�Q�K�K�K��	�9�8�8�h�n�n�S�1�1�8�8�8��
�/)�	�%�f�o�o�O�H�e�e���	�	�	���s�w�CY�\b�Cb�$c�$c�d�d�d��H�Q�K�K�K�K�K��	�	�	���s�w�Ci�ls�Cs�$t�$t�u�u�u��H�Q�K�K�K�K�K�	�����	��D�D�
�U�]�]���s�w�w�rx�rx�rx�z~�z~�z~�C�%A�%A�
B�
B�
B��H�Q�K�K�K���
�
�
�$
�"�+�D�1�1�����
�
�
��"�3�7�s�1�v�v�(N�(N�O�O�O����������������
�����	)��"6�6�6�
�)�$�/�/�����
�
�
��"�3�7�Gm�pw�Gw�(x�(x�y�y�y���������
����&�a�.�K�A�x�T���
�����&�&�&�$�%N�QW�%W�X�X�X�
�0�
0�
0��-�/�/�G�G��N�N�F��H�H�
�v�
�
�!�3�I�>�>�F�F�
�~�
%�
%��T�]�]�F�F�
��
&�
&��4��a��$�q�'�7�X�F�F�F�F�F�
�+�
+�
+��H��4�y�y�A�~�~���7�=�=��/�/���D�8�g�Z�Y`�a�a�a�a�a�
�'�
'�
'��D�$�q�'�8�,�,�,�,�
�(�
(�
(�$�%N�QW�%W�X�X�X�
�'�
'�
'��L��
(�'��$�%N�QW�%W�X�X�X�
�'�
'�
'��D�$�q�'�8�,�,�,�,�
�~�
%�
%��$��Q���*�*�*�*�
�}�
$�
$���t�A�w��)�)�)�)�
�~�
%�
%�$�%N�QW�%W�X�X�X�
�)�
)�
)�$�%N�QW�%W�X�X�X�
�-�
-�
-�$�T�4��7�3�3�F�F�
�|�
#�
#�

�t�T�!�W�i��A�A�A�A�
�,�
,�
,�#�0�2�2�
�
���������
�
�,�
,�
,�#�0�2�2�
!�
!����� � � � �
!���G�E��3���'��e�4�4��"�

�

�	���!9�9�9���e�Y�7�7�7�7��#<�<�<�!�$��y�9�9�9�9��#<�<�<��t�U�I�6�6�6��M�M�9�x��.>�"?�@�@�@��!�G�B�B��"�N�$H�I�����M�M�"�w�3�s�8�8�$L�$L�M�O�O�O��Q�J�E�E�E�E�E�E�����������
"�:�#=�>������3�7�s�3�x�x� H� H�I�I�I����������������������3�7�?e�ho�?o� p� p�q�q�q��������������"�$�$����3�7�s� C� C�D�D�D��������������������
��m����������������	��������	,��Q����
,��"�3���
�
�6�6�6�6��"�3��+�+�+�+���s�F�+�+�+��������i�i�'�'��f�%�%�'�'�'�'�'�G���s�v�'�B�B�C�C�C��H�[�����s��-1�B�AB�B�,L?�?9N:�:=N:�9N:�P�
Q$�!9Q�Q$�0R�>S�S�J`!�+A%_�`!�`�',`�`!�`�`!�!d
�79a5�5Ad
�8	d
�?d�d
r�c�8���fd�t��D��S)zL
    Return filtered control panels users
    :param user:
    :return:
    c�>��g|]}tj|����|��Sr")�fnmatch)r��	user_namer1s  �r$r�z_glob_users.<locals>.<listcomp>s*���U�U�U�)�G�O�I�t�4T�4T�U�I�U�U�Ur#)r)r1s`r$�_glob_usersrp
s$���V�U�U�U�w�y�y�U�U�U�Ur#�z2.7z3.3z3.4c
�(�tj��r)tj�dt
z��dSt
jd���}tj��}t��}t|��D�]}|rtj|��r�t|��s�*tj|��}tj��}	tj��}
tj|j|	��tj|j|
��t-j��t1|�|����D�]\}}t5j||��s�	t7|||���}
|
���j}||vr�M|rt=d|�d|�d���|
�d|d	|�
��}|rT	tA||��nB#tBtDf$r.}|r"t=d|�dtG|������Yd}~nd}~wwxYw��#tHj%$r2}|r%t=d
|�d|�dtG|������Yd}~��d}~wwxYwtj&|	��tj'|
����dS)NzNWARNING: Update interpreter with Python selector not supported on %s, skipped
r'r(r�zUpdating user: "z"; application: "z"...TF)�backupr.�force�_alt_interpreters_dictzFailed to restart application "z"; zFailed updating user: ")(�detect�is_pleskrGrJrKrr�detect_DA_adminrrpr�user_should_be_skippedrr>r?rE�getuid�getgid�setregid�pw_gid�setreuid�pw_uid�secureio�set_capabilityrr�rnrJr8r'r!�update_python_interpreterrbr��IOErrorrpr�InterpreterError�setuid�setgid)r1r'r>r.�alt_interpreters_dict�is_da_panelrIro�user_pwd�real_uid�real_gid�	app_name_r
r7�env_python_ver�
update_resultrs                 r$rTrTs���
������
���j�mt�t�u�u�u���(�5�)�D�D�D���(�*�*�K�&�(�(�L� ��&�&�*�*�	��	�5�7�	�B�B�	���y�)�)�	���<�	�*�*���9�;�;���9�;�;��
��H�O�X�.�.�.�
��H�O�X�.�.�.���!�!�!� )��)J�)J�9�)U�)U�V�V�	p�	p�O�I�t��?�9�h�7�7�
��
p�.�y�)�R^�_�_�_��!,�!8�!8�!:�!:�!B��!��0�0���`��E����T]�T]�T]�^�_�_�_� +� E� E�T�[b�jo�]r�!F�!t�!t�
� �b�b� �	�9�5�5�5�5��#�W�-�b�b�b�"�b�!�E�i�i�i�Y\�]^�Y_�Y_�Y_�"`�a�a�a����������b������"�2�
p�
p�
p��p��E�QZ�QZ�QZ�\e�\e�\e�gj�kl�gm�gm�gm�n�o�o�o����������
p����
	�	�(����
�	�(�����U*�*sH�,/H$�3H$�G!� H$�!H �2$H�H$�H � H$�$I%�3'I � I%)NT)NN)NNNNNNNNr�)NNFN)r�)r�rqr�T)V�
__future__rrrrFr�rEr�r�rGr>rnr�rYr��$requests.packages.urllib3.exceptionsr�r��
exceptionsr��requests.exceptionsr�future.utilsrrr	r
r�cldetectlibrv�clcommon.cpapirr
rr�clcommon.cpapi.cpapiexceptionsrr�clcommon.utilsr�clselectpython.apps_managerrrr�clselectexceptrr�
clselectprintr�clselectpythonuserrrr�baseclselectrrrerkrirdrc�compiler	r%r9rJr0r�r�r�r�r�r�r�rbr�r�rhrrBrfrrrkrprTr"r#r$�<module>r�s&��&�%�%�%�%�%�&�&�&�&�&�&�������
�
�
�
�����	�	�	�	�	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�����������������@�@�@�@�@�@�@�@�@�@�@�@�/�/�/�/�/�/�"�"�"�"�"�"�����������������������A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�A�'�'�'�'�'�'�����������
B�A�A�A�A�A�A�A�"�"�"�"�"�"�F�F�F�F�F�F�F�F�F�F�>�>�>�>�>�>�>�>�+����&��	�
�
�� �r�z�<�=�=��!]�!]�!]�H����0����*;?�KO�15�fM�fM�fM�fM�R	5�	5�	5�1l�1l�1l�1l�h����0J
�J
�J
�J
�Z]�]�]�B+�+�+�+�\$�$�$�-�-�-�-�8-�-�-�-�<#_�#_�#_�#_�N)�)�)�)�0���'�'�'�T
/�
/�
/�/�/�/�,�,�,�~�~�~�B
V�V�V�V�2�2�2�2�2�2r#

Hacked By AnonymousFox1.0, Coded By AnonymousFox