Hacked By AnonymousFox

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

�

!�g D��"�ddlmZddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
ddlmZddl
mZmZmZmZdd	lmZmZdd
lmZmZddlZddlmZddlmZd
ZdZdZdZdZ dZ!dZ"Gd�de#��Z$dd�Z%dd�Z&dd�Z'dd�Z(dS)�)�print_function)�absolute_import)�divisionN)�datetime)�
get_directory)�
check_call�check_output�	list_dirs�run_command�)�EXTENSION_PATTERN�
ExtensionInfo)�Interpreter�interpreters)�JSONDecodeError)�ClSelectExcept�
virtualenvz.virtualenv.backupz#/opt/cloudlinux/venv/bin/virtualenv�#z/usr/share/l.v.e-manager/utils�python_wrapperzset_env_vars.pyc��eZdZdd�Zd�Zd�Zdd�Zdd�Zdd�Zd	�Z	d d�Z
dd�Zd
�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zdd�Zd!d�Zdd�Zd�ZdS)"�EnvironmentNc��||_|r||_n/tjt	j����j|_tj|j��j|_	tj
�|j	d��|_|�
t|_n||_tj
�t|j|j��|��|_
tj
�t|jt ��|j��|_d|_d|_d|_d|z|_ddi|_dS)Nz.pip/pip.log�python�MySQLdbzMySQL-python)�name�user�pwd�getpwuid�os�getuid�pw_name�getpwnam�pw_dir�homepath�path�join�pip_logfile�DEFAULT_PREFIX�prefix�_abs_prefix�
BACKUP_PREFIX�backup_path�
_requirements�_interpreter�_pip�interpreter_name�_extension_remap)�selfrrr)s    �_/opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/clselectpythonuser/environments.py�__init__zEnvironment.__init__&s�����	��	:��D�I�I���R�Y�[�[�1�1�9�D�I���T�Y�/�/�6��
��7�<�<��
�~�F�F����>�(�D�K�K� �D�K��G�L�L��T�Y���!D�!D�d�K�K��	��7�<�<���	�=�1�1�4�9�>�>���!��� �����	� (�4����!*�N� ;�����c
�j�|jj�d|jj�d|j�d|j�d|j�d�
S)N�.z(name='z	', user='z', prefix='z'))�	__class__�
__module__�__name__rrr)�r2s r3�__repr__zEnvironment.__repr__<s@���N�%�%�%�t�~�'>�'>�'>��I�I�I�t�y�y�y�$�+�+�+�/�	0r5c�H���tj�j�����fd�}|S)Nc���tj�j��tj�j���jtjd<�jtjd<dS)N�USER�HOME)r�setgid�pw_gid�setuid�pw_uidr�environr#)r2�user_pwds��r3�funcz!Environment._demote.<locals>.funcDsI����I�h�o�&�&�&��I�h�o�&�&�&�!%��B�J�v��!)��B�J�v���r5)rr"r)r2rGrFs` @r3�_demotezEnvironment._demoteAs:�����<��	�*�*��	1�	1�	1�	1�	1�	1��r5c��|j|���|���d�}|r||=t||��|iS|S)N)r�interpreter�
extensions)rrJrK�getattr)r2�key�es   r3�as_dictzEnvironment.as_dictLsZ���I��+�+�-�-��/�/�+�+�
�
��
�	+��#���D�#�&�&��*�*��r5Tc���|j|������d�}|r)|�d|���i��|r||=t||��|iS|S)N)rrJrK)rrJrO�updaterKrL)r2rM�with_extensionsrNs    r3�as_deepdictzEnvironment.as_deepdictWs����I��+�+�-�-�5�5�7�7�
�
���	�
�H�H��d�o�o�/�/��
�
�
��	+��#���D�#�&�&��*�*��r5c�2�|st|j���}|j}|r tj�||��}d�t
tj�|j����|j	��}td|d|j|g}|���|j
|d�}	t|i|��n�#tj$r�}t#|��}d}	d|vrd}
nvd|vrp|�d	|�d	��d
z��}|d|��d��}|dks|dkr|}
n|d|�}	||d
zd�}
n|}
tj|
|	�
���d}~wwxYw|���dS)N)�target_userz({}:{})z--promptz--python)�
preexec_fn�cwd�waitzDisk quota exceededzJDisk quota exceeded.
 Contact system administrator to increase disk quota.�	Traceback�:r�
���)�message�details)rrr%rr&�formatr�basenamer)r�VIRTUALENV_BIN�binaryrHr$rr�ExternalProgramFailed�str�find�rfind�configure_environment)
r2rJ�versionrXr%�prompt�args�kwargs�err�	err_trace�err_text�err_char�
err_trace_ends
             r3�createzEnvironment.createes����	=�%�$�)�<�<�<�K��y���	/��7�<�<��g�.�.�D��!�!��"�'�*�*�4�;�7�7�8�8�$�)�
�
��
�����*��	
��!%�����t�}�d�S�S��	���'��'�'�'�'���3�	�	�	��c�(�(�C��I�$��+�+�R�����#�#��8�8�C����#���q��9�9�� #�I�X�I�� 4� 4�T� :� :�
� �B�&�&�(�b�.�.�"�H�H�!$�N�]�N� 3�I�"�=��?�#3�#3�4�H�H��� �6� �!����
�����+	����4	
�"�"�$�$�$�$�$s�;C�F�B$E;�;Fc�4�d|j�d��d|jg}|D]l}tj�||��}tj�|��r'tj|���d��r|cS�mdS)Nrr7r�/opt/alt/python)r0�splitrr%r&�islink�readlink�
startswith)r2�bin_path�files_to_check�filer%s     r3�detect_python_binaryz Environment.detect_python_binary�s�����!�'�'��,�,�Q�/��!�
��
#�	�	�D��7�<�<��$�/�/�D��7�>�>�$�'�'�
�2�;�t�+<�+<�+G�+G�HY�+Z�+Z�
�����
��tr5Fc��tj�|jd��}tj�||j��dz}|�|��}|�dStj�|��rtj|��tj||��	tj�|��s=tjtj�tt��|��n-#ttf$r|rtj||���wxYwtj�tj�|t����sbtjtj�tt��tj�|t����dSdS)z�
        Configures environment:
        1. Rename binary to pythonX.Y_bin
        2. Makes symlink from python binary to python_wrapper
        �bin�_binN)rr%r&r0r{�exists�remove�rename�symlink�
WRAPPERS_PATH�PYTHON_WRAPPER�IOError�OSError�SET_ENV_VARS_SCRIPT)r2�auto_restorerx�new_interpreter_path�interpreter_paths     r3rgz!Environment.configure_environment�s����7�<�<��	�5�1�1��!�w�|�|�H�d�6K�L�L�v�U���4�4�X�>�>���#��F�
�7�>�>�.�/�/�	,��I�*�+�+�+�
�	�"�$8�9�9�9�	��7�>�>�"2�3�3�
Z��
�2�7�<�<�
�~�F�F�HX�Y�Y�Y�����!�	�	�	��
B��	�.�0@�A�A�A��	����
�w�~�~�b�g�l�l�8�5H�I�I�J�J�	D��J�r�w�|�|�M�3F�G�G��w�|�|�H�.A�B�B�
D�
D�
D�
D�
D�	D�	Ds
�0AD
�
*D7c���|j}|r tj�||��}tj�|��r(t	ddd||������dSdS)Nz/bin/rm�-rz--interactive=never)rV)r%rr&rrrH)r2rhr%s   r3�destroyzEnvironment.destroy�s{���y���	/��7�<�<��g�.�.�D�
�7�>�>�$���	2��y�$�(=�t�"&�,�,�.�.�
2�
2�
2�
2�
2�
2�	2�	2r5c�2�||jvr
|j|S|S)z�
        Returns extensions name considering extension remap table
        :param extension_name: Input extension name
        :return: Result extension name
        )r1)r2�extension_names  r3�_get_extension_namezEnvironment._get_extension_name�s&���T�2�2�2��(��8�8�!�!r5c��tj�|j|��}tj�|�|�����sdStd|��|�|��|�|��}g}tj�|��r8t|d��}|�	��}|�
��|�|���|�|d���t|d��}|�
|��|�
��t|�|���dd	|�|����dS)
zX
        Recreate python virtual environment with requirements
        :return:
        �rhNzRe-create python virtualenv:�rT)rhrX�w�installr�)rr%r&r�pip�print�_pip_freeze�pip_requirements�open�	readlines�closer�rq�
writelinesr)r2rh�env_path�requirements_path�requirements�	reqs_files      r3�	_recreatezEnvironment._recreate�sj���7�<�<��	�7�3�3���w�~�~�d�h�h�w�h�7�7�8�8�	��F�
�,�h�7�7�7�����!�!�!� �1�1�'�:�:����
�7�>�>�+�,�,�	��.��4�4�I�$�.�.�0�0�L��O�O�������W��%�%�%����G�$��/�/�/��*�C�0�0�	����\�*�*�*���������H�H�W�H�%�%�y�$��!�!�'�*�*�	,�	,�	,�	,�	,r5c�z�td������D]}|�|���dS)Nrh�rM)r�keysr��r2rhs  r3�recreatezEnvironment.recreate�sG��#�	�2�2�2�7�7�9�9�	$�	$�G��N�N�7�#�#�#�#�	$�	$r5c�J�tj�|j��S�N)rr%rr;s r3rzEnvironment.exists�s���w�~�~�d�i�(�(�(r5c�^�|js t|j|j���|_|jS)N)r)rU)r.rr%rr;s r3rJzEnvironment.interpreter�s0��� �	U� +�4�9�$�)� T� T� T�D��� � r5c�L�|�|��}tj|j��}|�t
��}|d|dd�pd}}ddd|���dz|jzdz|zf}|r7|d}ddd|���dz|jzdz|zd	z|zf}tj|||��rtd
|z���t||���|j���|�
��dS)Nrr��	/bin/bash�-l�-c� --log-file=z	 install z==z6Extension '%s' install is prohibited. System extension�rjrVrW)r�r�get_locked_extensionsr0rt�VERSION_DELIMITERr�r'�is_extensions_locked�
ValueErrorrrHr$r�)r2r��locked_extensions�t�	extensionrh�commands       r3�extension_installzEnvironment.extension_install�sJ���1�1�.�A�A��)�?��@U�V�V��� � �!2�3�3���q�T�1�Q�R�R�5�;�B�7�	���d�D�H�H�J�J��,G�$�JZ�,Z��-�!/�-0�1���	A��a�j�G�"�D�$����
�
�^�0K�d�N^�0^�"�1#�%.�1/�15�16�8?�1@�A�G��-�.?��QX�Y�Y�	h��U�Xf�f�g�g�g���D�L�L�N�N��
�N�N�N�N��������r5c���ddd|���dz|jzd�|��zf}t||���|j���|���dS)Nr�r�r�r�z install -r {}r�)r�r'r_rrHr$r�)r2r�r�s   r3�extension_install_requirementsz*Environment.extension_install_requirementssu����d�D�H�H�J�J��,G�$�JZ�,Z�#�*�*�+<�=�=�->�?����D�L�L�N�N��
�N�N�N�N��������r5c	��t|���d|jzdd||���|j���|���dS)N�--log-file=r�z	--upgrade�rVrW)rr�r'rHr$r�)r2r�s  r3�extension_updatezEnvironment.extension_updatesa���4�8�8�:�:�}�T�-=�=��k�9�"�l�l�n�n�$�-�	A�	A�	A�	A�	
�������r5c	�\�tj|j��}|�t��}|d|dd�pd}}|r|d}tj|||��rt
d|z���tj|�	��d|j
zd|f|���tjtjtj|j
d���}|�d	��\}}|jrt!|p|���|���dS)
Nrrr�z$Extension '%s' removal is prohibitedr��	uninstallT)rV�stdin�stderr�stdoutrW�text�y)rr�r0rtr�r�r��
subprocess�Popenr�r'rH�PIPEr$�communicate�
returncode�	Exceptionr�)r2r�r�r�rh�pr�r�s        r3�extension_uninstallzEnvironment.extension_uninstalls$��)�?��@U�V�V���O�O�-�.�.���q�T�1�Q�R�R�5�;�B�7�	��	!��a�j�G��-�.?��G�T�T�	Q��C�i�O�P�P�P���
�X�X�Z�Z��t�'7�7��i�P�]a�]i�]i�]k�]k��/�*�/��?��
�D�
B�
B�
B�����s�+�+�����<�	.��F�,�f�-�-�-��������r5c	���i}tj|j��}	t|���dd|jzd|���|j���}d�tj	|��D��}n�#ttttjtjf$r\t|���dd|jz|���|j���}t!j|��}YnwxYwd�|D��}t%||��D]�\\}}}tj|||��r�t)t+d�|�d��D����t+|�|����z
��}	|	rAt1|�|����d	kr|d
�|	��d�||<��||d�||<��|S)N�listr�z
--format=jsonr�c�.�g|]}|d|df��S)rrh�)�.0�xs  r3�
<listcomp>z*Environment.extensions.<locals>.<listcomp>-s%��P�P�P��1�V�9�a�	�l�3�P�P�Pr5c3�^K�|](\}}t���|��V��)dSr�)r�
extension_doc)r�r��_s   r3�	<genexpr>z)Environment.extensions.<locals>.<genexpr>1sL����0�0� �I�q����-�-�i�8�8�0�0�0�0�0�0r5c�6�g|]}|�����Sr�)�strip)r��vs  r3r�z*Environment.extensions.<locals>.<listcomp>5s ��(O�(O�(O�q������(O�(O�(Or5�,rz, )�docrh)rr�r0r	r�r'rHr$�json�loadsr�KeyErrorr�r�FileProcessErrorrcr
�findall�zipr�r��setrt�get�lenr&)
r2�resultr��outputrK�docsrrhr��version_diffs
          r3rKzEnvironment.extensions(s,����)�?��@U�V�V��	;�!�$�(�(�*�*�f�m�D�DT�6T�Ve�rv�r~�r~�sA�sA�GK�GT�U�U�U�F�P�P�T�Z��=O�=O�P�P�P�J�J����:�~�7V�Xf�X|�}�	;�	;�	;�!�$�(�(�*�*�f�m�D�DT�6T�ae�am�am�ao�ao�uy�vC�D�D�D�F�*�2�6�:�:�J�J�J�	;����0�0�$.�0�0�0��$'�
�D�$9�$9�	@�	@� �O�T�7�S��1�2C�T�7�S�S�
@�#�C�(O�(O�G�M�M�#�<N�<N�(O�(O�(O�$P�$P�&)�*;�*?�*?��*E�*E�&F�&F�%G� H� H���T�C�(9�(=�(=�d�(C�(C�$D�$D��$I�$I�+.�4�9�9�\�;R�;R�#S�#S�F�4�L��'*�w�?�?��t����
s�A$B�BD�
Dc���|�'tj�|j|dd��S|js+tj�|jdd��|_|jS)Nr}r�)rr%r&r/r�s  r3r�zEnvironment.pip>sQ�����7�<�<��	�7�E�5�A�A�A��y�	>�����T�Y��u�=�=�D�I��y�r5c��|�&tj�|j|d��Stj�|jd��S)Nzrequirement.pip)rr%r&r�s  r3r�zEnvironment.pip_requirementsEs<�����7�<�<��	�7�4E�F�F�F��w�|�|�D�I�'8�9�9�9r5c���d}|���}|r||j}ntd���|j}t��}tj�|j��r?t	j|j���	d��r|rtd��dS|jdtj���
d��zz}	t	j|j��}
tj|j|	��t	j|	|
j|
j��	|jD]�}t+j|j|j��r|sd}|rtd|z���:|r+t0j�d	|j�d
|�d���t7dd
|j|f���|�|��td����d}nk#t:t<f$rW}tdt?|��z��|D]}
tj |	|
���t	j!|	��Yd}~nd}~wwxYw|st	j!|	��|S)a_
        copy binary python from /opt/alt/pythonXY/bin/pythonX.Y to virtualenvdir/bin/pythonX.Y
        :param backup: make backup old python interpreter
        :param force: force rewrite python interpreter without check
        :param verbose: print actions details to stdout
        :return: True - updating success; False - updating fail
        Frhr�rszVNothing to do, binary in your virtual environment is already symlink to global python!z.orig_%sz%Y-%m-%d_%H-%Mz     not need updating; skip '%s'z
    copy 'z' -> 'z'...z/bin/cpz--force)�cmd�DoneTzFail %sN)"rJrhrr�rr%ru�
python_binrvrwr�r�now�strftime�stat�shutil�copy�chown�st_uid�st_gid�binary_list�filecmp�cmprb�sysr��writer�appendr�r�rd�copyfile�unlink)r2�backup�force�verbose�_alt_interpreters_dict�
update_resultrJ�main_interpreter�updated_list�
python_backup�stat_�virtualenv_python_binrN�updated_pythons              r3�update_python_interpreterz%Environment.update_python_interpreterJs����
��&�&�(�(��!�	P�5�k�6I�J���+�	�:�:�:�;�;N�O���v�v��
�7�>�>�+�0�1�1�	�b�k�+�BX�6Y�6Y�6d�6d�ev�6w�6w�	��
p��n�o�o�o��5�$�.��h�l�n�n�>U�>U�Vf�>g�>g�1g�g�
����.�/�/����K�*�M�:�:�:�
�����e�l�;�;�;�	%�)4�)@�
�
�%��;�/�6��8N�O�O��X]��$)�M��Z��@�CX�X�Y�Y�Y���t��J�$�$�$�CS�CZ�CZ�CZ�\q�\q�\q�%r�s�s�s���I�7G�7N�Pe� f�g�g�g�g��#�#�$9�:�:�:��f�
�
�
�
� �M�M����!�	%�	%�	%��)�c�!�f�f�$�%�%�%�".�
?�
?����
�~�>�>�>�>��I�m�$�$�$�$�$�$�$�$�����	%�����	%��I�m�$�$�$��s�8B.G'�'I�8A
I
�
Ic�8�tj�|�|����sdS|�|��ddf}t	|�|��d��}t
||���|j|���dS)�X
        Output installed packages in requirements format
        :return: None
        N�freezer�r�)rjrVrWr�)	rr%rr�r�r�rrHr$)r2rhr��fs    r3r�zEnvironment._pip_freeze~s���
�w�~�~�d�h�h�w�/�/�0�0�	��F��8�8�G�$�$�h��5����&�&�w�/�/��5�5����D�L�L�N�N��}�Q�	0�	0�	0�	0�	0�	0r5c�|�td������D]}|�|����dS)rrhr�r�N)rr�r�r�s  r3�
pip_freezezEnvironment.pip_freeze�sN��
$�	�2�2�2�7�7�9�9�	.�	.�G����W��-�-�-�-�	.�	.r5�NNr�)NT)NNN)F)FFTN)r:r9�__qualname__r4r<rHrOrSrqr{rgr�r�r�r�rrJr�r�r�r�rKr�r�rr�rr�r5r3rr$s�������<�<�<�<�,0�0�0�
	�	�	�	�	�	�	�����,%�,%�,%�,%�\
�
�
�D�D�D�D�82�2�2�2�	"�	"�	"�,�,�,�B$�$�$�)�)�)�!�!�!�
��� ���������"���,����:�:�:�:�
2�2�2�2�h
0�
0�
0�
0�.�.�.�.�.r5rc��|st}|r7tj�t	j|��j|��Stj�t	jtj����j|��Sr�)	r(rr%r&rr"r#rr )rr)s  r3r*r*�sd��� ����F��w�|�|�C�L��.�.�5�v�>�>�>��w�|�|�C�L�����5�5�<�f�E�E�Er5c���t||��}	t|��}n#t$rgcYSwxYwg}|D]&}|�t	|||�����'|Sr�)r*r
r�rr)rr)�	venv_path�env_list�envs�env_names      r3�environmentsr�s����D�&�)�)�I���Y�'�'���������	�	�	�����
�D��9�9�����K��$��7�7�8�8�8�8��Ks�"�1�1c�V��t�fd�t||��D����S)Nc3��K�|]9}t|����������V��:dS�r�N)r�rO�items�r�rNrMs  �r3r�z$environments_dict.<locals>.<genexpr>�sE�����U�U�Q��Q�Y�Y�3�Y�'�'�-�-�/�/�0�0�U�U�U�U�U�Ur5��dictr�rMrr)s`  r3�environments_dictr&�s0����U�U�U�U�,�t�V�:T�:T�U�U�U�U�U�Ur5c�V��t�fd�t||��D����S)Nc3��K�|]9}t|����������V��:dSr )r�rSr!r"s  �r3r�z(environments_deepdict.<locals>.<genexpr>�sY�����5�5���Q�]�]�s�]�+�+�1�1�3�3�4�4�5�5�5�5�5�5r5r#r%s`  r3�environments_deepdictr)�sE����5�5�5�5�%�d�F�3�3�5�5�5�5�5�5r5r))�
__future__rrrrr�rr�r�r�r�clselect.clselectctlr�clselect.utilsrr	r
rrKr
rrr�
simplejsonr�r�clselect.clselectexceptrr(r+rar�r�r�r��objectrr*rr&r)r�r5r3�<module>r0s���&�%�%�%�%�%�&�&�&�&�&�&�������	�	�	�	�
�
�
�
�
�
�
�
�����
�
�
�
�����������.�.�.�.�.�.�K�K�K�K�K�K�K�K�K�K�K�K�8�8�8�8�8�8�8�8�3�3�3�3�3�3�3�3�����&�&�&�&�&�&�2�2�2�2�2�2���$�
�6����0�
�!��'��l.�l.�l.�l.�l.�&�l.�l.�l.�^F�F�F�F�	�	�	�	�V�V�V�V�5�5�5�5�5�5r5

Hacked By AnonymousFox1.0, Coded By AnonymousFox