Hacked By AnonymousFox

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

�

m4�f�*���ddlmZddlmZddlmZddlZddlZddlZddlZddlZddl	Z
ddlmZm
Z
ddlmZddlmZmZmZdd	lmZdd
lmZddlmZdZGd
�de��ZGd�deee����ZdS)�)�print_function)�division)�absolute_importN)�ABCMeta�abstractmethod)�time�)�INSTALLING_STATUS�REMOVING_STATUS�AcquireInterpreterLockError)�with_metaclass)�is_testing_enabled_repo)�GroupInfoReaderi�Qc��eZdZdS)�PkgManagerErrorN)�__name__�
__module__�__qualname__���W/opt/cloudlinux/venv/lib64/python3.11/site-packages/clselect/baseclselect/pkgmanager.pyrr"s�������Drrc��eZdZdZdZdZdZdZdZdZ	dZ
dZed���Z
ed���Zed���Zd�Zd�Zed���Zed	���Zd
�Zed���Zed���Zdd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z e!j"d���Z#e$d���Z%e$d���Z&e$d���Z'd�Z(e$d���Z)d�Z*e$d���Z+dS)�BasePkgManagerz�
    Class responsible for all interactions with Yum, interpreter versions
    installation/removal and gathering info about already installed versions
    Nc�j�ttjd��}tj||||dd���S)N�wTz	/bin/bash)�stdin�stdout�stderr�shell�
executable)�open�os�devnull�
subprocess�Popen)�cls�command�fnulls   r�run_backgroundzBasePkgManager.run_background6s?���R�Z��%�%���������"�

�
�
�	
rc�L�|j�|jSt��}||_|S�N)�_testing_repo_enabled_cacher)�self�ress  r�_testing_enabledzBasePkgManager._testing_enabledBs,���+�7��3�3�%�'�'��+.��(��
rc��|jr%tj�|jd��Stj�|jd��S)Nzyum_cache.dat.testing_enabledz
yum_cache.dat)r/r"�path�join�_config_dir�r-s r�_yum_cache_filezBasePkgManager._yum_cache_fileKsA��� �	S��7�<�<�� 0�2Q�R�R�R��w�|�|�D�,�o�>�>�>rc��tj|j��}t|�����}t|jd��5}|D]}|�|�d����	ddd��dS#1swxYwYdS)Nr�
)r�get_group_info�
_alt_names�list�keysr!r5�write)r-�groups�f�groups    r�update_yum_cachezBasePkgManager.update_yum_cacheQs��� �/���@�@���f�k�k�m�m�$�$��
�$�&��
,�
,�	&���
&�
&�����5����%�%�%�%�
&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�	&�	&s�A<�<B�Bc���	tj|j��}n#t$rYdSwxYwt	��|jz
tkrdSt|j�����S)z;Return data from file or None if file is absent or outdatedN)	r"�statr5�OSErrorr�st_mtime�MAX_CACHE_AGE_SECr!�read)r-rBs  r�_read_yum_cachezBasePkgManager._read_yum_cacheXsx��	��7�4�/�0�0�D�D���	�	�	��4�4�	����
�F�F�T�]�"�&7�7�7��4��D�(�)�)�.�.�0�0�0s��
*�*c�`�	tj|��dS#ttf$rYdSwxYw)z* Silently remove file ignoring all errors N)r"�removerC�IOError)r>s r�_remove_silentzBasePkgManager._remove_silentds?��	��I�a�L�L�L�L�L����!�	�	�	��D�D�	���s��-�-c��|j�|���|_t|j�����S)z�
        Returns list of installed interpreter versions by scanning alt_node_dir
        and cache result. Cache also can be pre-filled at init time for
        testing/debugging purposes
        )�_versions_info�_scan_interpreter_versionsr:r;r4s r�installed_versionsz!BasePkgManager.installed_versionsls>����&�"&�"A�"A�"C�"C�D���D�'�,�,�.�.�/�/�/rc��|j�|���|_	|j|dS#t$r|cYSwxYw)a�
        Should return full interpreter version for a particular major version or
        just fallback to given version if info is not available for any reason.
        This information is taken from the hash map populated during
        installed_packages scan.

        :param maj: Major interpreter version
        :return: Full interpreter version or Major if info is not available
        N�full_version)rMrN�KeyError)r-�majs  r�get_full_versionzBasePkgManager.get_full_versionws]����&�"&�"A�"A�"C�"C�D��	��&�s�+�N�;�;���	�	�	��J�J�J�	���s�5�A�Ac�L�tj�|jd��S)Nzyum.pid.lock�r"r1r2r3r4s r�_pid_lock_filezBasePkgManager._pid_lock_file�s���w�|�|�D�,�n�=�=�=rc�L�tj�|jd��S)Nzyum_cache.pid.lockrVr4s r�_cache_lock_filezBasePkgManager._cache_lock_file�s���w�|�|�D�,�.B�C�C�Crc	��tj�|j��s|���tj|t|��|tt����d�t|jd����dS)z�
        :param pid: pid of Yum process
        :param version: interpreter version or None for "cache update" case
        :param status: what yum is currently doing(few predefined statuses)
        :return: None
        )�pid�version�statusrrN)r"r1�existsr3�_create_config_dirs�json�dump�str�floatrr!rW)r-r[r\r]s    r�_write_yum_statusz BasePkgManager._write_yum_status�s����w�~�~�d�.�/�/�	'��$�$�&�&�&��	���7�|�|���$�&�&�M�M�	
�
�
��#�S�)�)�	+�	+�	+�	+�	+rc�v�|���}|�"d�|d|d��SdS)Nz>{} of version '{}' is in progress. Please, wait till it's doner]r\)�_read_yum_status�format�r-�ongoing_yums  r�_check_yum_in_progressz%BasePkgManager._check_yum_in_progress�sE���+�+�-�-���"�1����H�-�{�9�/E�F�F�
G�#�"rc��|j�t���	tjt	|j����}n+#t
$r|�|j��YdSwxYwtj|�	d����s|�|j��dS	tj|dtj��\}}n#t$r|cYSwxYw|dkr|S|�|j��dS)a�
        Result "None" - means installing/removing of our packages is not
        currently in progress. However, it doesn't mean that any other yum
        instance is not running at the same time, but we ok with this
        because our yum process will start processing automatically once
        standard /var/run/yum.pid lock is removed by other process
        :return: None or dict
        Nr[r)rW�NotImplementedErrorr`�loadr!�	ExceptionrK�psutil�
pid_exists�getr"�waitpid�WNOHANGrC)r-�datar[�_s    rrfzBasePkgManager._read_yum_status�s"����&�%�'�'�'�	��9�T�$�"5�6�6�7�7�D�D���	�	�	����� 3�4�4�4��4�4�	����
� ����%���1�1�	����� 3�4�4�4��4�	��Z��U��R�Z�8�8�F�C�����	�	�	��K�K�K�	����
�!�8�8��K����D�/�0�0�0��ts!�&>�$A&�%A&�-(C�C%�$C%c�6�|j�|��S)z�
        Formatting cmd string for installing package
        :return: formatted cmd string
        :param version: version of interpreter for installing
        :rtype: str
        )�_install_cmdrg�r-r\s  r� format_cmd_string_for_installingz/BasePkgManager.format_cmd_string_for_installing�s��� �'�'��0�0�0rc�6�|j�|��S)z�
        Formatting cmd string for removing package
        :return: formatted cmd string
        :param version: version of interpreter for removing
        :rtype: str
        )�_remove_cmdrgrxs  r�format_cmd_string_for_removingz-BasePkgManager.format_cmd_string_for_removing�s����&�&�w�/�/�/rc�l�|�|��}|r|S||jvrd�|��S|���}|�dS||vrd�|��S|�|��}|�|��}|�|j|t��dS)�Return None or Error stringz!Version "{}" is already installedNz^Updating available versions cache is currently in progress. Please, try again in a few minuteszGVersion "{}" is not available. Please, make sure you typed it correctly)	�_verify_actionrOrg�checkout_availableryr)rdr[r
)r-r\�err�	available�
cmd_string�ps      r�install_versionzBasePkgManager.install_version�s����!�!�'�*�*���	��J��d�-�-�-�6�=�=�g�F�F�F��+�+�-�-�	���F�F��)�#�#�?�?E�v�g���
P��:�:�7�C�C�
����
�+�+�����q�u�g�/@�A�A�A�A�Arc�f�|�|��}|r|S||jvrd�|��S|�|��rdS|�|��rdS|�|��}|�|��}|�|j|t��dS)r~zVersion "{}" is not installedzeThis version is currently in use by another operation. Please, wait until it's complete and try againzPIt's not possible to uninstall version which is currently in use by applicationsN)
rrOrg�is_interpreter_locked�_is_version_in_user|r)rdr[r)r-r\r�r�r�s     r�remove_versionzBasePkgManager.remove_version�s����!�!�'�*�*���	��J��$�1�1�1�2�9�9�'�B�B�B��%�%�g�.�.�	D�D�D��"�"�7�+�+�	6�6�6��8�8��A�A�
����
�+�+�����q�u�g��?�?�?�?�?rc��|���}|�)|dttfvr|d|ddd�iSdS)zr
        Should return version and it's status for versions that is
        currently installing|removing
        Nr]r\�)r]�base_dir)rfr
rrhs  r�in_progresszBasePkgManager.in_progresss_��
�+�+�-�-���"��H�%�*;�_�)N�N�N��I�&�)�(�3� "�)�)��
��trc#�rK�|�|��}	t|d��}n#t$rt|���wxYw	t	j|tjtjz��n#t$rYnwxYw	dV�|���dS#|���wxYw)Nr)	�_get_lock_file_pathr!rJr�fcntl�flock�LOCK_EX�LOCK_NB�close�r-�interpreter_version�	lock_name�lfs    r�acquire_interpreter_lockz'BasePkgManager.acquire_interpreter_locks������,�,�-@�A�A�	�	C��i��%�%�B�B���	C�	C�	C�-�.A�B�B�B�	C����	��K��E�M�E�M�9�:�:�:�:���	�	�	�

�D�	����	��E�E�E��H�H�J�J�J�J�J��B�H�H�J�J�J�J���s'�*�A�,A5�5
B�B�B � B6c��t���r+�rlr4s rr�z!BasePkgManager.checkout_available2���!�#�#�#rc��t���r+r�r4s rrNz)BasePkgManager._scan_interpreter_versions6r�rc��t���r+r�r4s rr_z"BasePkgManager._create_config_dirs:r�rc��|�|��}tj�|��sdSt	|d��}	tj|t
jt
jz��n%#t$rY|�
��dSwxYw	|�
��n#|�
��wxYwdS)NFrT)r�r"r1�isfiler!r�r�r�r�rJr�r�s    rr�z$BasePkgManager.is_interpreter_locked>s����,�,�-@�A�A�	��w�~�~�i�(�(�	��5�
�)�S�
!�
!��	��K��E�M�E�M�9�:�:�:�:���	�	�	���H�H�J�J�J�J�J�	����
;�
�H�H�J�J�J�J��B�H�H�J�J�J�J�����us*�,A5�4B0�5
B�?B0�B�B0�0Cc��t���r+r�rxs  rrzBasePkgManager._verify_actionKr�rc��t���r+r�rxs  rr�z"BasePkgManager._get_lock_file_pathOs��!�#�#�#rc��t���r+r�rxs  rr�z!BasePkgManager._is_version_in_useRr�r)NN),rrr�__doc__r,r3rM�_yum_cmdr9�
_redirect_logrwr{�classmethodr)�propertyr/r5r@rG�staticmethodrKrOrTrWrYrdrjrfryr|r�r�r��
contextlib�contextmanagerr�rr�rNr_r�rr�r�rrrrr&s��������
#'���K��N��H��J��M��L��K��	
�	
��[�	
�����X���?�?��X�?�
&�&�&�
1�
1�
1�����\���0�0��X�0����"�>�>��X�>��D�D��X�D�+�+�+�+� G�G�G�#�#�#�J1�1�1�0�0�0�B�B�B�,@�@�@�*��� �������,�$�$��^�$��$�$��^�$��$�$��^�$�����$�$��^�$�$�$�$��$�$��^�$�$�$rr)�
__future__rrrr�r"r�ror$�
simplejsonr`�abcrrrr�r
rr�future.utilsr
�clcommon.utilsr�clcommon.group_info_readerrrErnr�objectrrrr�<module>r�s���&�%�%�%�%�%�������&�&�&�&�&�&�����	�	�	�	�����
�
�
�
���������'�'�'�'�'�'�'�'�����������������
(�'�'�'�'�'�2�2�2�2�2�2�6�6�6�6�6�6���	�	�	�	�	�i�	�	�	�n$�n$�n$�n$�n$�^�^�G�V�4�4�n$�n$�n$�n$�n$r

Hacked By AnonymousFox1.0, Coded By AnonymousFox