Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/pyvirtualdisplay/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/pyvirtualdisplay/__pycache__/abstractdisplay.cpython-311.pyc

�

�܋f'1��"�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
eje��Ze��Ze��ZdZgZdZdZdZGd�d	e��ZGd
�de��Zd�Zd
�ZGd�de��ZdS)�N)�Lock)�xauth)�get_helptext�platform_is_osxi��
皙�����?c��eZdZdS)�XStartTimeoutErrorN��__name__�
__module__�__qualname__���q/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pyvirtualdisplay/abstractdisplay.pyr
r
 ��������Drr
c��eZdZdS)�XStartErrorNrrrrrr$rrrc����d�	tj���}n,#t$rt�d��gcYSwxYwd}tj||��}�fd�|D��}d�|D��}|S)Nz/tmpzmissing /tmpz.X*-lockc�P��g|]"}tj��|����#Sr)�os�path�join)�.0�child�tmpdirs  �r�
<listcomp>z_lock_files.<locals>.<listcomp>1s)���	9�	9�	9�%�"�'�,�,�v�u�
%�
%�	9�	9�	9rc�P�g|]#}tj�|���!|��$Sr)rr�isfile)r�ps  rrz_lock_files.<locals>.<listcomp>2s+��	-�	-�	-��2�7�>�>�!�,�,�	-�!�	-�	-�	-r)r�listdir�FileNotFoundError�log�warning�fnmatch�filter)�ls�pattern�namesrs   @r�_lock_filesr*(s����
�F��
�Z��
�
�����������N�#�#�#��	�	�	������G��N�2�w�'�'�E�	9�	9�	9�	9�5�	9�	9�	9�B�	-�	-�R�	-�	-�	-�B�
�Is��&A�Ac���ttd�t������}t|��r&t	t
t	|��dz��}nt
}|S)Nc��t|�d��d�d��d��S)N�X��-r)�int�split)�xs r�<lambda>z%_search_for_display.<locals>.<lambda>8s/��C�������Q�� 5� 5�c� :� :�1� =�>�>�r�)�list�mapr*�len�max�_MIN_DISPLAY_NR)r'�displays  r�_search_for_displayr;6sT��	
�c�>�>��
�
�N�N�	O�	O�B�
�2�w�w�"��o�s�2�w�w��{�3�3���!���Nrc��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zed���ZdS)�AbstractDisplayz8
    Common parent for X servers (Xvfb,Xephyr,Xvnc)
    c��||_||_||_d|_d|_d|_d|_d|_d|_||_	d|_
d|_d|_t|��}d|v|_|jst�d��t"j�d��}|r=t�d|��t)t+|����|_nt-��rd|_|�|��|r&t1j��st1j���||_d|_d|_dS)NFrz
-displayfdz-displayfd flag is missing.�PYVIRTUALDISPLAY_DISPLAYFDzPYVIRTUALDISPLAY_DISPLAYFD=%s)�_extra_args�_retries�_program�stdout�stderr�old_display_var�_subprocr:�_is_started�_manage_global_env�_reset_global_env�	_pipe_wfd�_retries_currentr�_has_displayfdr#�debugr�environ�get�boolr0r�_check_flagsr�is_installed�
NotFoundError�
_use_xauth�
_old_xauth�_xauth_filename)�self�program�	use_xauth�retries�
extra_args�manage_global_env�helptextr?s        r�__init__zAbstractDisplay.__init__FsY��%�����
���
�������#�����
���� ���"3���!&������ !�����(�(��*�h�6����"�	5��I�I�3�4�4�4�%'�Z�^�^�4P�%Q�%Q�"�%�	,��I�I�5�7Q�R�R�R�"&�s�+E�'F�'F�"G�"G�D���� � �
,�&+��#����(�#�#�#��	(�U�/�1�1�	(��%�'�'�'�#������#����rc��dS�Nr)rWr]s  rrQzAbstractDisplay._check_flagsls���rc��t���r`)�NotImplementedError�rWs r�_cmdzAbstractDisplay._cmdos��!�#�#�#rc�(�|r|jn|j}|�Ut�d��	tjd=dS#t$rt�d��YdSwxYwt�d|��|tjd<dS)z�
        on:
         * True -> set $DISPLAY to virtual screen
         * False -> set $DISPLAY to original screen

        :param on: bool
        Nzunset $DISPLAY�DISPLAYz$DISPLAY was already unset.zset $DISPLAY=%s)�new_display_varrEr#rMrrN�KeyErrorr$)rW�on�ds   r�_redirect_displayz!AbstractDisplay._redirect_displayrs���%'�@�D� � �D�,@���9��I�I�&�'�'�'�
;��J�y�)�)�)���
;�
;�
;����9�:�:�:�:�:�:�
;����
�I�I�'��+�+�+�$%�B�J�y�!�!�!s�
=�$A%�$A%c�V�tj���}|j|d<|S)Nrf)rrN�copyrg)rW�envs  r�_envzAbstractDisplay._env�s$���j�o�o�����-��I���
rc���|jrt|d���d|_|jr|���n�d}	|dz|_	|���nr#t$rdt�d|dz��tj	d��|dz
}||j
krtd|j
�d|j�����YnwxYw��|jr|�
d��d|_d	Sd	S)
z5
        start display

        :rtype: self
        zDisplay was started twice.Trr.zstart failed %s皙�����?zNo success after z retries. Last stderr: N)rGrrL�_start1_has_displayfdrK�_start1r#r$�time�sleeprArDrHrkrI)rW�is  r�startzAbstractDisplay.start�s<����	B��d�$@�A�A�A������	��&�&�(�(�(�(��A�

�()�A���%���L�L�N�N�N���"�����K�K� 1�1�q�5�9�9�9��J�t�$�$�$���F�A��D�M�)�)�)�k�#�}�}�}�d�k�k�;����*�)�	����

��"�	*��"�"�4�(�(�(�%)�D�"�"�"�	*�	*s�	A�A+C�Cc�2�t5|r>tj|j|jgtjtjd���|_n6tj|jtjtjd���|_ddd��dS#1swxYwYdS)NF)�pass_fdsrCrD�shell)rCrDrz)�_mutex_popen�
subprocess�Popen�_commandrJ�PIPErF)rW�use_pass_fdss  r�_popenzAbstractDisplay._popen�s���
�	�	��
� *� 0��M�"�n�-�%�?�%�?��!�!�!��
�
�!+� 0��M�%�?�%�?��	!�!�!��
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A7B�B�Bc�J�tj��\}|_|���|jz|_t�d|j��|�d���t|�
|����|_tj|��tj|j��dt|j��z|_
|jr|���tj�dd��|_dS)N�command: %sT�r��:%srf)r�piperJrdr@r~r#rMr�r0�_wait_for_pipe_textr:�closergrT�_setup_xauthrNrOrE)rW�rfds  rrrz%AbstractDisplay._start1_has_displayfd�s��� �g�i�i���T�^��	�	���d�&6�6��
��	�	�-���/�/�/������&�&�&��4�3�3�C�8�8�9�9���
���
�
�
�
���� � � �$�s�4�<�'8�'8�8����?�	 ������� "�z�~�~�i��>�>����rc��t5t��|_|jtvr|xjdz
c_|jtv�dt	|j��z|_t�|j��ddd��n#1swxYwY|���|jz|_	t�d|j	��|�d���dt	|j��z|_|j
r|���tj�dd��|_t'j��}|j}d}t'jd��	|���s�n	t-jd	g|���t,jt,jd�
��}|���\}}|j}nE#t8$r8t�d��t'jt<��d}YndwxYw|dkrnt�d
|��d}n;t'j��|z
t@krnt'jtB����|���s4t�d|j"��d}tG||z���|sd}tI|||j"fz���dS)Nr.r�r�Fr�rfrqT�xdpyinfo)rnrCrDrzzLxdpyinfo was not found, X start can not be checked! Please install xdpyinfo!rz)Successfully started X with display "%s".zprocess exited early. stderr:%szFailed to start process: %szGFailed to start X on display "%s" (xdpyinfo check failed, stderr:[%s]).)%�_mutexr;r:�_USED_DISPLAY_NR_LISTr0rg�appendrdr@r~r#rMr�rTr�rrNrOrErtru�is_aliver|r}ror�communicate�
returncoder"r$�
_X_START_WAIT�info�_X_START_TIMEOUT�_X_START_TIME_STEPrDrr
)rW�
start_timerj�okr��_�	exit_code�msgs        rrszAbstractDisplay._start1�s��
�	7�	7�.�0�0�D�L��,�"7�7�7�����!����,�"7�7�7�#(�3�t�|�+<�+<�#<�D� �!�(�(���6�6�6�
	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7��	�	���d�&6�6��
��	�	�-���/�/�/������'�'�'�$�s�4�<�'8�'8�8����?�	 ������� "�z�~�~�i��>�>����Y�[�[�
�� ��
���
�4����+	+��=�=�?�?�
��
�%�+��L��	�	���%�?�%�?������ �+�+�-�-���1�$�/�	�	��$�
�
�
����b�����
�=�)�)�)�����

����(�A�~�~�����D�a�H�H�H�����y�{�{�Z�'�+;�;�;���J�)�*�*�*�W+	+�X�}�}���	*��K�K�9�4�;�G�G�G�/�C��c�D�j�)�)�)��	A�[�C�$�S�A�x��+?�%?�@�@�@�	A�	As%�A;B�B�B�AG4�4?H6�5H6c���d}tj��}	tj|gggd��\}}}|���s&t|j�d|j�d|j�����||vr4tj|d��}|dkrnR||�	d��z
}tj��|z
d	krtd
|j�d|j�������|S)N�Trz program closed. command: z	 stderr: r.�
�asciiiXzNo reply from program z
. command:)rt�selectr�rrBr~rDr�read�decoder
)rWr��sr��rfd_changed_lsr��cs       rr�z#AbstractDisplay._wait_for_pipe_text#s�����Y�[�[�
�	�%+�]�C�5�"�b�#�%F�%F�"�^�Q���=�=�?�?�
�!��}�}�}�d�m�m�m�T�[�[�B�����n�$�$��G�C��O�O����:�:���Q�X�X�g�&�&�&���y�{�{�Z�'�3�.�.�(�(��
�
�
��
�
�����	�,�rc��|jstd���|jr|�d��|���rz	|j���n2#t$r%}t�	d|��Yd}~nd}~wwxYw|j�
��|���|jr|�
��|S)z4
        stop display

        :rtype: self
        z stop() is called before start().Fzexception in terminate:%sN)rGrrIrkr�rF�kill�OSErrorr#rM�wait�_read_stdout_stderrrT�_clear_xauth)rW�oserrors  r�stopzAbstractDisplay.stop>s�����	B��@�A�A�A��!�	*��"�"�5�)�)�)��=�=�?�?�	'�
@��
�"�"�$�$�$�$���
@�
@�
@��	�	�5�w�?�?�?�?�?�?�?�?�����
@����
�M��� � � ��$�$�&�&�&��?�	 ��������s�A"�"
B�,B�Bc���|j�h|j���\|_|_t�d|j��t�d|j��dSdS)Nz	stdout=%sz	stderr=%s)rCrFr�rDr#rMrcs rr�z#AbstractDisplay._read_stdout_stderrVs`���;��)-��)B�)B�)D�)D�&�T�[�$�+��I�I�k�4�;�/�/�/��I�I�k�4�;�/�/�/�/�/�	�rc��tjdd���\}}||_tj|��i|_tjd��|jd<tjd��|jd<|xtjd<tjd<tj	��}tj
d|jd|��dS)	zU
        Set up the Xauthority file and the XAUTHORITY environment variable.
        zPyVirtualDisplay.z.Xauthority)�prefix�suffix�AUTHFILE�
XAUTHORITY�add�.N)�tempfile�mkstemprVrr�rU�getenvrNr�generate_mcookie�callrg)rW�handle�filename�cookies    rr�zAbstractDisplay._setup_xauth]s���$�+�&�}�
�
�
���� (���
���������&(�i�
�&;�&;���
�#�(*�	�,�(?�(?����%�<D�D��
�:����L�!9��'�)�)��
�
�5�$�.��V�<�<�<�<�<rc��tj|j��dD]7}|j|�tj|=�|j|tj|<�8d|_dS)zR
        Clear the Xauthority file and restore the environment variables.
        )r�r�N)r�removerVrUrN)rW�varnames  rr�zAbstractDisplay._clear_xauthosa��	�	�$�&�'�'�'�1�	?�	?�G���w�'�/��J�w�'�'�&*�o�g�&>��
�7�#�#�����rc�.�|���|S)�%used by the :keyword:`with` statement)rwrcs r�	__enter__zAbstractDisplay.__enter__{s���
�
�����rc�.�|���dS)r�N)r�)rW�exc_infos  r�__exit__zAbstractDisplay.__exit__�s���	�	�����rc�z�|jsdS|j���}|�|���|duS)NF)rF�pollr�)rW�rcs  rr�zAbstractDisplay.is_alive�sE���}�	��5�
�]�
�
�
!�
!��
�>��$�$�&�&�&��T�z�rc�,�|jr|jjSdS)zI
        PID (:attr:`subprocess.Popen.pid`)

        :rtype: int
        N)rF�pidrcs rr�zAbstractDisplay.pid�s#���=�	%��=�$�$�	%�	%rN)rr
r�__doc__r^rQrdrkrorwr�rrrsr�r�r�r�r�r�r�r��propertyr�rrrr=r=AsA��������$$�$$�$$�L
�
�
�$�$�$�&�&�&�&���
*�*�*�@���$?�?�?�,OA�OA�OA�b���6���00�0�0�=�=�=�$
�
�
����
������(�%�%��X�%�%�%rr=)r%�loggingrr�r|r�rt�	threadingr�pyvirtualdisplayr�pyvirtualdisplay.utilrr�	getLoggerrr#r�r{r9r�r�r�r��	Exceptionr
rr*r;�objectr=rrr�<module>r�s{����������	�	�	�	�
�
�
�
�������������������"�"�"�"�"�"�?�?�?�?�?�?�?�?��g���!�!��
������t�v�v�����������
�	�	�	�	�	��	�	�	�	�	�	�	�	�)�	�	�	�������_%�_%�_%�_%�_%�f�_%�_%�_%�_%�_%r

Hacked By AnonymousFox1.0, Coded By AnonymousFox