%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/softwareproperties/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/softwareproperties/__pycache__/MirrorTest.cpython-312.pyc

�

���c��6�ddlZ	ddlmZmZddlZddlZddlZddlZddl	Z
ddlZ
	ddlm
Z
ddlZGd�dej �Zedk(�r(e
j&j)�Zej+e
j,j/��ej0d�Zej5�j7�Zej:�Zej?�dej@jB�d	ej@jDdjB�d
e�d�Z#ee$ej@jJjM��e#ej:�e�Z'e'jQ�yy#e$rddlmZmZY��wwxYw#e$r
ddlm
Z
Y��jwxYw)�N)�Empty�Queue)�urlopenc�p�eZdZdZGd�dej
�Zdd�Zd�Zd
d�Z	d�Z
dd	�Z		dd
�Zd�Z
y)�
MirrorTestz@Determines the best mirrors by perfoming ping and download test.c��eZdZdZdd�Zd�Zy)�MirrorTest.PingWorkerz�Use the command line command ping to determine the server's
           response time. Using multiple threads allows to run several
           test simultaneously.c���||_||_||_||_||_||_t
jd�|_tjj|�y)Nz^rtt .* = [\.\d]+/([\.\d]+)/.*)�borders�mod�parent�id�jobs�results�re�compile�match_result�	threading�Thread�__init__)�selfrrrr
rrs       �?/usr/lib/python3/dist-packages/softwareproperties/MirrorTest.pyrzMirrorTest.PingWorker.__init__sR��"�D�L��D�H� �D�K��D�G��D�I�"�D�L� "�
�
�+L� M�D�����%�%�d�+�c��d}|jj��s�|jjj	��r�	|jjd�}|j}|jjd|z�tjddddd|gtjtjd�	�j}	|j�}|sn!tj|j |�}�4	t$j&j)�t$xj*dz
c_|jj-t$j*t$j.|j0|j2�|r*|j4j7t9|d�|g�t$j&j;�|jj�s'|jjj	�r���yyyy#t"$rYy|jjd
z�Y��@xYw)
NFz
Pinging %s...�pingz-qz-c 2z-W 1z-i 0.5T)�stdout�stderr�universal_newlineszSkipping %s�r)r�emptyr
�running�isSet�get�hostname�
report_action�
subprocess�Popen�PIPE�STDOUTr�readliner�findallrrr�completed_lock�acquire�	completed�report_progress�todorrr�append�float�release)r�result�mirror�host�commando�lines      r�runzMirrorTest.PingWorker.run#s����F��i�i�o�o�'�D�K�K�,?�,?�,E�,E�,G�D�!�Y�Y�]�]�5�1�F�!�?�?�D��K�K�-�-�o��.D�E�)�/�/���v�v�x�Y]�0^�7A���7A�7H�7H�CG� I�JP����'�0�0�2��#�!�!#���D�,=�,=�t�!D��	�"��)�)�1�1�3��$�$��)�$����+�+�J�,@�,@�,6�O�O�,0�L�L�,0�H�H�6���L�L�'�'��v�a�y�)9�4��(H�I��)�)�1�1�3�9�i�i�o�o�'�D�K�K�,?�,?�,E�,E�,G�'�,G�'�����D��K�K�-�-�m�d�.B�C�s�B?H�	I�"IN)�rr�rr)�__name__�
__module__�__qualname__�__doc__rr9�rr�
PingWorkerr	s��	#�	,�	4rrANc�b�tjj|�d|_d|_||_d|_||_g|_dt_
tj�t_t|�t_||_|stj �|_y||_y)N�)rrgr)rrr�action�progress�event�best�	test_file�threadsrr.�Lockr,�lenr0�mirrors�Eventr!)rrLrHrFr!s     rrzMirrorTest.__init__Cs������!�!�$�'����#��
���
���	�"������ �
��$-�N�N�$4�
�!��g�,�
������$�?�?�,�D�L�"�D�Lrc�`�||_|jr|jj�yy�N)rDrF�set)r�texts  rr%zMirrorTest.report_actionTs#������:�:��J�J�N�N��rc��||dz||dz|d|d|dz
|z|zzf|_|jr|jj�yy)zTSubclasses should override this method to receive
           progress status updatesrrN)rErFrP)r�current�maxrrs     rr/zMirrorTest.report_progressYsd��!�3�q�6�)��s�1�v�� ���w�q�z�G�A�J�'>�#�&E��&O�O�Q��
��:�:��J�J�N�N��rc
�b�|jddd��}t|j�}|dkDrp|jdd|jt	j
d|dz
�g�|jdd|jt	j
d|dz
�g�|j
|D�cgc]}|d��	c}dtjtjf�	�}|D] \}}td
|j�d|����"|sy|ddj}td|z�|Scc}w)
N�)r��?)r�)rTrr�rr�rWr)rrzmirror: z	 - time: zand the winner is: %s)�
run_ping_testrKrLr1�random�randint�run_download_testrr0�printr$)r�results_ping�size�rr�t�h�winners        r�
run_full_testzMirrorTest.run_full_testbs���)�)�a��u�)�M���4�<�<� ���!�8�����A�t�|�|�F�N�N�1�d�1�f�4M�'N� O�P�����A�t�|�|�F�N�N�1�d�1�f�4M�'N� O�P��(�(��)E�1�!�A�$�)E�19�.8�o�o�.8�o�o�.?�)�@���	=�F�Q���Q�Z�Z��;�<�	=����Q�Z��]�+�+�F��)�F�2�3��M��*Fs�.D,c	��|dk(r|j}t�}|D]}|j|��g}td�D]G}tj||||||�}	|jj|	�|	j��I|jD]}	|	j��|j�|d|S)z�Performs ping tests of the given mirrors and returns the
           best results (specified by max).
           Mod and borders could be used to tweak the reported result if
           the download test is only a part of a whole series of tests.N�r)rLr�put�rangerrArIr1�start�join�sort)
rrLrTrrr�mr�ircs
          rr[zMirrorTest.run_ping_testws���
�d�?��l�l�G��w���	�A��H�H�Q�K�	����r��	�A��%�%�d�G�Q��g�s�K�A��L�L����"�
�G�G�I�	�
���	�A�
�F�F�H�	�	�����q��~�rc�B���fd�}|dk(r�j}g}|D]m}�jj�snQ||�}|dkDr|j||g��j	|j|�dzt
|�d|��o|j�|d|S)z�Performs download tests of the given mirrors and returns the
           best results (specified by max).
           Mod and borders could be used to tweak the reported result if
           the download test is only a part of a whole series of tests.c���|j�d�d�j��}�jd|z�tj�}	t	|d��jd�tj�|z
S#YyxYw)Nr�/zDownloading %s...rY)�timeouti�)�
get_repo_urlsrHr%�timer�read)r5�urlrkrs   �r�test_download_speedz9MirrorTest.run_download_test.<locals>.test_download_speed�sv���#�1�1�3�A�6�!�^�^�-�C����2�S�8�9��I�I�K�E�
���Q�'�,�,�V�4��y�y�{�U�*�*��
��s�
2B�BNrrrZ)rLr!r"r1r/�indexrKrm)	rrLrTrrrxrrn�
download_times	`        rr^zMirrorTest.run_download_test�s����		��d�?��l�l�G����	T�A��<�<�%�%�'��/��2�M��q� ����
�q�1�2�� � ����q�!1�A�!5�s�7�|�X�s�S�
	T�	�����q��~�rc�b�|j�|_|jj�y)z/Complete test exercise, set self.best when doneN)rfrGr!�clear)rs rr9zMirrorTest.run�s"���&�&�(��	������rrO))r�dr;)NNr:r;)r<r=r>r?rrrArr%r/rfr[r^r9r@rrrrsE��J�+4�Y�%�%�+4�Z#�"�
��*�.AF�#��<rr�__main__zdpkg --print-architecturezdists/rrz/binary-z/Packages.gz))r�queuerr�ImportErrorrurr&�os�aptsources.distro�
aptsources�aptsources.sourceslist�urllib.requestr�urllib2r\rrr<�distro�
get_distro�get_sources�sourceslist�SourcesList�popen�piperv�strip�archrMr!rP�source_template�name�
componentsrH�list�
mirror_set�values�apprfr@rr�<module>r�si���#�"��	��	��� �&��[��!�!�[�z�z��
�
�
�
)�
)�
+�F�
���z�-�-�9�9�;�<��2�8�8�/�0�D��9�9�;����D��i�o�o��G��K�K�M��'�'�,�,��'�'�2�2�1�5�:�:���I��T�&�0�0�;�;�B�B�D�E���	��� 1�7�<�C�������W�#�"�"�#��� ��� �s"�E5�F	�5
F�F�	F�F

Zerion Mini Shell 1.0