%PDF- %PDF-
Mini Shell

Mini Shell

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

�

;�fZ8��,�ddlZddlZejdd�ddlmZmZddlmZddlZddl	Z	ddl
Z
ddlmcm
Z
ddlmZddlmZeed��\ZZeed	��\ZZZZdd
lmZe
j8dk\rd�Zdd
�ZGd�d�Zy)�N�Gtkz3.0)�GObjectr)�gettext)�
MirrorTest)�setup_ui��)�CountryInformation�3c��||kD||kz
S�N�)�a�bs  �E/usr/lib/python3/dist-packages/softwareproperties/gtk/DialogMirror.py�<lambda>r-s���A��!�a�%�(��c� �|j|dddd�\}}}}|j|dddd�\}}	}
}|j|�}|j|�}
|r|
rt||�S|ry|
ry|ry|	ry||
k7rt||
�St||�S)a  sort function for the mirror list:
           - at first show all custom urls
           - secondly the separator
           - show mirrors without a county first (e.g. the automatic mirror url)
           - third the official mirrors. if available
             sort the countries
      r�r����)�get�iter_has_child�cmp)�model�iter1�iter2�data�url1�sep1�custom1�mirror1�url2�sep2�custom2�mirror2�
has_child1�
has_child2s              r�sort_mirrorsr)/s���(-�y�y���1�a��'C�$�t�T�7�G�',�y�y���1�a��'C�$�t�T�7�G��'�'��.�j��'�'��.�j�	�W��T�4��
 �����	
����	�z�	!��z�:�.�.�
��t�_�rc�`�eZdZd�Zd�Zd�Zdd�Zdd�Zdd�Zdd�Z	dd	�Z
d
�Zdd�Zd�Z
d
�Zy)�DialogMirrorc���dd�}||_t�|_t|tj
j
|dd�d��|j|_|jj|�|j|_|jj|j�||_|j|_|j|_|j"|_|j&|_|j*|_|j.|_|j2|_|j6|_|j2|_|j.|_t?j@tBjDtBjD�}|j8jG|�t?jH�}|j8jK|d�|j8jM|dd	�t?jNtBjDtBjPtBjPtBjR�|_*|jjW|d�t?jX|jT�
�|_-||_|jjG|jZ�t?jH�|_.|j\j_d|j`|jT�t?jbd|j\td�
�|_3|jji|jf�i}d}	|jjk�jk�}
tm|j�d	kDrf|jD]C}|
jod|dddg�|jfjM|j\dtp��E|
jodgd��|jjrjtjw�D�]}|jjrjt|}|jx|vr$|
jo||jx|dd|g��Y|jxdk7r�|
jod|jj{|jx�dddg�}|jx|jj|k(r|	dk(r|}	|
jo||dd|g�f|||jx<��|
jod|dd|g���
|	dk7r�|jZj|jZj�|	�d�}
|jj�|
d�|jj�|
dd�|jj�|
dd��|jZj�t�d�y)zQ
    Initialize the dialog that allows to choose a custom or official mirror
    Nc�.�|j|t�Sr
)�	get_value�COLUMN_SEPARATOR)r�iterrs   r�is_separatorz+DialogMirror.__init__.<locals>.is_separatorQs�����t�%5�6�6r�
gtkbuilderzdialog-mirror.uizsoftware-properties)�domainT�markupr)r�edited�URI)�textF�editable)NTFNr��?��	use_align�	row_alignr
)F�custom_mirrorsr
�country_infor�os�path�join�
dialog_mirror�dialog�set_transient_for�dialog_mirror_test�dialog_test�distro�treeview_mirrors�treeview�button_mirror_edit�button_edit�button_mirror_remove�
button_remove�button_mirror_choose�
button_choose�button_test_cancel�
button_cancel�label_test_mirror�
label_test�progressbar_test_mirror�progressbar_test�combobox_mirror_proto�combobox�progress�label_actionr�	ListStorer�TYPE_STRING�	set_model�CellRendererText�
pack_start�
add_attribute�	TreeStore�TYPE_BOOLEAN�
TYPE_PYOBJECTr�set_row_separator_func�
TreeModelSort�
model_sort�renderer_mirror�connect�on_edited_custom_mirror�TreeViewColumn�
COLUMN_URI�
column_mirror�
append_column�	get_model�len�append�
COLUMN_CUSTOM�source_template�
mirror_set�keys�location�get_country_name�code�get_path�convert_child_iter_to_iter�
expand_row�
set_cursor�scroll_to_cell�set_default_sort_funcr))�self�parent�datadirrGr=r1�model_proto�cr�map_loc�patriotr�mirror�hostname�	path_sorts              r�__init__zDialogMirror.__init__Ms���7�)�D��*�,�D���T�2�7�7�<�<���7I�J�Sh�i��$�$�D�K��K�K�!�!�&�)��.�.�D�����&�&�t�{�{�3��D�K��)�)�D�M��.�.�D���2�2�D���2�2�D���0�0�D���,�,�D�O� �8�8�D���.�.�D�M��0�0�D�M��.�.�D���-�-�� 3� 3� '� 3� 3�5�K��M�M���K�(�	�	�	�	�B��M�M���R��&��M�M����H�a�0����w�2�2�&�3�3�&�3�3�&�4�4�6�D�J�	�M�M�(�(��t�<��'�'�d�j�j�9�D�O��D�K��M�M���D�O�O�,��/�/�1�D����� � ��!%�!=�!=�!%���-��+�+�E�,0�,@�,@�1;�=�D��	�M�M���� 2� 2�3��G��G��M�M�#�#�%�/�/�1�E�
�4����!�#��)�)�	<�F��L�L����t�T�:�;����,�,�T�-A�-A�-7�-:�
<�	<�
	���T�4�5��K�K�/�/�:�:�?�?�A�
A�����,�,�7�7��A���?�?�g�%��L�L�����1�"�E�5�&�9�
;�
�_�_��
$��\�\�$�#'�#4�#4�#E�#E�f�o�o�#V�X]�_d�fj�"k�m�F����$�"3�"3�"8�"8�8�W��_� ���L�L��(�E�5�&�!A�B�C�'-�G�F�O�O�$��L�L���%���?�@�
A��$���O�O�,�,�T�_�_�-W�-W�X_�-`�ab�-c�d�	��
�
� � ��E�2��
�
� � ��D�%�8��
�
�$�$�Y�$�#�$�N��O�O�)�)�,��=rc�>�|j|�}|j|�}|dk7r�|j|t|�|dk7r@|j	|t
�s*|j	|t�s|jdgd��|jj|j|��y|j|�|j	|j�t
�r|j|j��|jjd�y)zh Check if the new mirror uri is faild, if yes change it, if not
        remove the mirror from the list �Nr)NTF�r)�get_iter�	iter_next�	set_valuerjr.r/rp�insertrO�
set_sensitive�is_valid_mirror�remove�get_iter_firstrIrz)r}�cellr@�new_textrr0r�s       rrhz$DialogMirror.on_edited_custom_mirror�s����>�>�$��D�����%�I��2�~�
����j�(�3�����O�O�I�'7�8��O�O�I�}�5��L�L��/�0����(�(��)=�)=�h�)G�H��	���T���?�?�5�/�/�1�3C�D��L�L��-�-�/�0��
�
� � ��&�
rc�D�|dk(rytjd|�dk(ryy)z% Check if a given uri is a vaild one NFzG^((ftp)|(http)|(file)|(rsync)|(https))://([a-z]|[A-Z]|[0-9]|:|/|\.|~)+$T)�re�match)r}�uris  rr�zDialogMirror.is_valid_mirror�s(��
�d�{��	���\�^a�	b�fj�	j��rNc�n�|j�\}}|dk(rR|jjd�|jjd�|jjd�y|j�}|j
|�}|j|t�}|jj�}|j�|dk7r�|jjd�g}	|jD]K}
|
j|	vr�|	j|
j�|j|
j���M|jjd�|jjd�y|jj|j|t ��|jj|j|t ��|jj|j#|j|t$���|jjd�y)ze Check if the currently selected row in the mirror list
        contains a mirror and or is editable NFTr)�
get_cursorrMr�rKrOrmr�r.�
COLUMN_MIRRORrW�clear�repositories�protoro�get_info�
set_activerpr�rj)r}rIr�row�columnrr0r��model_protos�seen_protos�repos           r�"on_treeview_mirrors_cursor_changedz/DialogMirror.on_treeview_mirrors_cursor_changed�s����'�'�)�M�S�&�
�d�{����(�(��/����&�&�u�-����(�(��/����� �E��>�>�#��D�
�_�_�T�=�
1�F��=�=�*�*�,�L�����
��~��
�
�#�#�D�)����'�'�	1�D��z�z�[�(�����t�z�z�*�����
�
��0�	1�	
�
�
� � ��#����(�(��.�	
���(�(�����}�)M�N����&�&�u���t�]�'K�L����(�(��)=�)=�e�o�o�d�T^�>_�)`�a��
�
�#�#�E�*rc��|jj�\}}|jj�j|�}|jj�j�}|j	|�|j|j
�t�r|j	|j
��|jjd�y)z& Remove the currently selected mirror r�N)	rIr�rmr�r�r.r�r/rz)r}�buttonrr@r�r0rs       r�on_button_mirror_remove_clickedz,DialogMirror.on_button_mirror_remove_clicked�s����=�=�+�+�-�L�D�&��=�=�"�"�$�-�-�d�3�D��M�M�#�#�%�/�/�1�E�	�L�L������u�+�+�-�/?�@�
���U�)�)�+�,��M�M���T�"rc��|jj�j�}|jdtd�dddg�|jj	�|jjd|jd��y)zI Add a new mirror at the beginning of the list and start
        editing Nz
New mirrorFTr���focus_column�
start_editing)rIrmro�_�
grab_focusrzrk)r}r�rrs    r�on_button_mirror_add_clickedz)DialogMirror.on_button_mirror_add_clicked�so��
�M�M�#�#�%�/�/�1�E�	�L�L���,����d�;�<��M�M�����M�M���T�*.�*<�*<�+/��1rc��|jj�\}}|jj�|jj||d��y)z@ Grab the focus and start editing the currently selected mirror Tr�N)rIr�r�rz)r}r�rr@r�s     r�on_button_mirror_edit_clickedz*DialogMirror.on_button_mirror_edit_clickedsA���=�=�+�+�-�L�D�&��M�M�����M�M���T��d��Krc�&�|jd�y)z< If anybody wants to close the dialog, stop the test before NT)�on_button_cancel_test_clicked)r}rC�eventrs    r�"on_dialog_mirror_test_delete_eventz/DialogMirror.on_dialog_mirror_test_delete_events���&�&�t�,�rc��|jj�}|jj�|jj	�\}}|sy|jj�}|j
|�}|j|t�}|tjjk(r�|dk(r|j|t�S|jj�}|j
|jj��}|j|t�}	|j|t �}
|	�d|j"�d|
��Sy)z= Run the chooser dialog and return the chosen mirror or None Nz://�/)rC�run�hiderIr�rmr�r.r�r�ResponseType�OKrjrW�
get_active�COLUMN_PROTO�
COLUMN_DIRr�)r}�resr�r�rr0r�r��
iter_protor��dirs           rr�zDialogMirror.runs��
�+�+�/�/�
�C��K�K�����M�M�,�,�.�M�S�&����M�M�#�#�%�E��>�>�#��D�
�_�_�T�=�
1�F��c���!�!�!��T�>��?�?�4��4�4��-�-�1�1�3�K�$�-�-�d�m�m�.F�.F�.H�I�J��)�)�*�l�C�E��'�'�
�J�?�C�#(�&�/�/�3�?�?�rc�4�|jjd�|jj�t	j
�|_|jj�t	j
�}tjd�}|j�j�}d|jjj�d|jjjdj�d|�d�}t!t#|jjj$j'��|||j�}|j)�|jj+�r�t-j.�r*t-j0d�t-j.�r�*|j3d	�|j+�r{|j4j7t9d
�|j4d|j4dfz�|j4j;|j4d�|j=�|jj+�r��|jj?�|j@jCd
�|jDdk7r1|jFjI|jJ|jD�ytMjN|jPt9d�t9d��y)zY Perform a test to find the best mirror and select it
        afterwards in the treeview Tzdpkg --print-architecturezdists/r�rz/binary-z/Packages.gzFg�������?zCompleted %s of %s testsrrr�Nz%No suitable download server was foundz&Please check your Internet connection.))rQr�rF�show�	threading�Event�running�setr?�popen�read�striprGrq�name�
componentsr�listrr�values�start�is_setr�events_pending�main_iteration_do�waitrX�set_textr��set_fractionr�r�rS�	set_label�bestre�foreach�
select_mirror�dialogs�show_error_dialogrC)r}r�r�progress_update�pipe�arch�	test_file�tests        r�on_button_test_clickedz#DialogMirror.on_button_test_clicked(s7��	���$�$�T�*��������?�?�$�D�L��L�L�����o�o�'�O�
�8�8�/�0�D��9�9�;����D��+�+�-�-�2�2��+�+�-�-�8�8��;�@�@���I��d�4�;�;�6�6�A�A�H�H�J�K�"�(����'�D�	�J�J�L��,�,�
�
�
�� � �"��!�!�%�(�� � �"�
	���S�!��!�!�#��M�M�"�"�1�%?�#@�$(�M�M�!�$4�d�m�m�A�6F�#G�$H�
I��M�M�&�&�t�}�}�Q�'7�8��!�!�#��,�,�
�
�
�	�������O�O���b�!��y�y�D�������� 2� 2�D�I�I�>��!�!�$�+�+�"#�$K�"L�"#�$L�"M�	Orc��|j|t�|k(rq|jj|�|jj	|dd�|jj|dd��|jj
�yy)z;Select and expand the path to a matching mirror in the listNFTr9r:)r.rjrI�expand_to_pathrzr{r�)r}rr@r0r�s     rr�zDialogMirror.select_mirrorTsn�����t�Z�(�F�2��
�
�$�$�T�*��
�
� � ��t�U�3��
�
�$�$�T�T�S�$�I��
�
� � �"��
3rc���|jj�|jjdt	d�z�|j
j
d�|jjd�y)z# Abort the mirror performance test z	<i>%s</i>zCanceling...FrN)	r�r�rSr�r�rQr�rUr�)r}r�s  rr�z*DialogMirror.on_button_cancel_test_clicked^sV���L�L�����O�O���k�A�n�,=�=�>����$�$�U�+����&�&�q�)rr
)�__name__�
__module__�__qualname__r�rhr�r�r�r�r�r�r�r�r�r�rrrr+r+KsD��\>�|�,�+�B	#�1�L��
�:*O�X�*rr+r
) r?�gi�require_version�
gi.repositoryrrrr�r�r��sys�softwareproperties.gtk.dialogs�gtkr��softwareproperties.MirrorTestr�softwareproperties.gtk.utilsrr��ranger�r�rjr/rpr��%softwareproperties.CountryInformationr
�versionrr)r+rrr�<module>r�s���.
�	�����5�%� �&� ��	�
�0�0�4��
"�%��(�^���z�?C�E�!�H�~�<��
�}�m�D��;�;�#��
(�C��8X*�X*r

Zerion Mini Shell 1.0