%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/hplip/base/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/hplip/base/__pycache__/utils.cpython-312.pyc

�

=	f�@��	�ddlZddlZddlmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddl�ddlZddlmZmZmZmZddlmZmZmZmZmZm Z mZddl!m"Z"ddl#Z#	ddl$m%cm&Z&dZ'	ddl)Z)dZ*	ddl+Z+dd
l+m,Z,m-Z-m.Z.dZ/	ddl0Z0d�Z1ddl�ddl3�dd
l!m4Z4dZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<dZ=dZ>dZ?dZ@ej�dZBej�dZCe4j�e4j�ddddddddddd d!gZFgZGeFD]1ZH	ej�eHej��ZKeGj�eK��3d"�ZNd#�ZOd$�ZPd�d%�ZQed&�ed&�ed&�dfd'�ZRd(�ZSd�d)�ZTd�d*�ZUd�d+�ZVd,�ZWGd-�d.�ZXGd/�d0�ZYGd1�d2�ZZGd3�d4eZ�Z[Gd5�d6�Z\Gd7�d8�Z]d9�Z^d:�Z_d�d;�Z`	ej�Zbd�d=�ZdGd>�d?ee�Zfd@�ZgdA�ZhdB�ZidC�ZjdD�Zk	ddElmlZldL�Zper>eqj�dMdM�Zsesj�esej�j�dN��Zwn/ej�d&d&�Zsesj�esej��ZwdO�ZudP�fdQ�ZxdR�fdS�ZygdT�ZzdUd&d&dVd&dT�Z{dW�Z|d�dX�Z}dY�Z~d�dZ�Zd�d[�Z�Gd\�d]�Z�Gd^�d_�Z�Gd`�da�Z�db�Z�e�j
dckrd�dd�Z�d�de�Z�df�Z�d�dg�Z�n'e��jZ�e��jZ�e��jZ�dh�Z�di�Z�dj�Z�d�dk�Z�dl�Z�dm�Z�d�dn�Z�d�do�Z�dp�Z�dq�Z�Gdr�dsee�Z�dt�Z�duZ�dvZ�dwZ�dxZ�dyZ�dzZ�d{Z�d|Z�d}Z�d~Z�dZ�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�e��jgd�d�d��d�k(rd�Z�d�Z�d�Z�n;e��jgd�d�d��d�k(rd�Z�d�Z�d�Z�ne��jgd�d�d��d�k(rd�Z�d�Z�d�Z�d��Z�d�d��Z�d�d��Z�d�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d�e�fd��Z�d�d��Z�Gd��d��Z�d�d��Z�d��Z�d��Z�d��Z�d��Z�d�d��Z�d�d��Z�d��Z�e;e<fd��Z�d�d��Z�d��Z�d�d��Z�d��Z�d�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d�d��Z�d��Z�y#e($rd	Z'Y���wxYw#e($rd	Z*Y���wxYw#e($rd	Z/Y���wxYw#e($rddl2Z2d�Z1Y���wxYw#eM$reGj�eH�Y���wxYw#ec$rd�d<�ZbY���wxYw#e($r#GdF�dG�ZmGdH�dIen�ZoGdJ�dK�ZlY���wxYw)��N)�Popen�PIPE�)�*)�
html_entities�urllib2_request�
urllib2_parse�
urllib2_error)�PY3�
to_unicode�
to_bytes_utf8�to_string_utf8�BytesIO�StringIO�
subprocess)�os_utilsTF)�	SystemBus�lowlevel�
SessionBusc�H�tj|�j�S�N)�hashlib�sha1�	hexdigest��ss �/usr/share/hplip/base/utils.py�get_checksumrHs���|�|�A��(�(�*�*�c�H�tj|�j�Sr)�sha�newrrs rrrNs���w�w�q�z�#�#�%�%r)�pexpectzrm -rfzrm -fzcom.hplip.StatusServicez/http://hplipopensource.com/hplip-web/index.htmlzhttp://www.hp.comz
www.hp.com��z	Continue?zpasswor[dt]:�kennwortzpassword forzmot de passeucontraseñaz
palavra passeu口令�
wachtwoord�heslou密码u	Lösenordc�b�g}	td�}	tjdj��djdd�jd�}d|vr|jd�|j!�|S#t$r�	dtjt	j
d�j�jk7r?tjt	j
d�j�jgcYSn#t$r|cYcYSwxYwY��
wxYw#t$r|cYSwxYw)Nz/etc/cups/cupsd.conf�rootzSystemGroup [\w* ]*rzSystemGroup �� )�open�IOError�grp�getgrgid�os�stat�st_gid�gr_name�OSError�re�findall�read�replace�split�
IndexError�remove�close)�lis�fps  r�get_cups_systemgroup_listr@�s��
�C���&�'����
�
�1�"�'�'�)�<�a�@�H�H��XZ�[�b�b�cf�g����}��
�
�6���H�H�J��J����	�����b�g�g�.D�&E�&L�&L�M�U�U�U����R�W�W�-C�%D�%K�%K�L�T�T�U�U�V���	��J�	��V������
��sN�A=�AD �=	D�A;D�D�D�D�D�D�D�D� D.�-D.c�>�tjd|jz�	tj|j�tjtjz�y#ttf$r%tjd|jz�YywxYw)NzLocking: %sTzFailed to unlock %s.F)
�log�debug�name�fcntl�flock�fileno�LOCK_EX�LOCK_NBr.r5��fs r�lockrL�sm���I�I�m�a�f�f�$�%��
���A�H�H�J��
�
��
�
� =�>����W����	�	�(�1�6�6�1�2���s�AA(�(1B�Bc��|�utjd|jz�	tj|j�tj�tj|j�yy#ttf$rYywxYw)Nz
Unlocking: %s)rBrCrDrErFrG�LOCK_UNr1r<r.r5rJs r�unlockrO�sg���}��	�	�/�A�F�F�*�+�	��K�K����
�E�M�M�2��I�I�a�f�f��	��
��!�	��	�s�AA9�9B�
Bc���tj}tj�dk(rd}n4tjj|�stj|�tjj|dj|dg��}	t|d�}t|�s|stjd|�d	|�d
��yd|fS#t$r|stjd|z�YywxYw)Nrz/var�.rL�wzUnable to open %s lock file.)FNzUnable to lock z. Is z already running?T)
�prop�user_dirr1�geteuid�path�exists�makedirs�joinr-r.rB�errorrL)�application�suppress_error�dir�	lock_file�lock_file_fs     r�lock_appr`�s���
�-�-�C�	�z�z�|�q����
�W�W�^�^�C�
 �
���C�������S�#�(�(�K��+@�"A�B�I���9�c�*�������I�I�Y�P[�\�]�����������I�I�4�y�@�A���s�C�#C1�0C1r+c�(���t|�dk(r|t|�z}trt}nt}|j	td�td��}|j	||��|�"|j
||j
|������fd�}|S)Nrr+c�(��|j���Sr)�	translate)r�delete�transs ��r�callablezTranslator.<locals>.callable�s����{�{�5�&�)�)r)�lenr�bytes�string�	maketransr
rc)�frm�tord�keep�
data_types�allcharsrfres  `    @r�
Translatorrp�s����
�2�w�!�|�
�#�c�(�]��
��
��
��#�#�M�"�$5�}�R�7H�I�H�� � ��b�)�E����#�#�H�d�n�n�X�v�.N�O��*��Orc���t|�dk(ryt|�dk(rtd|dzdz�St|�dk\r4ddj|�zdzt|j��zdzSy)Nrr+r�"z", "z" and ")rg�strrY�pop)r>s r�list_to_stringru�sp��
�3�x�1�}��
�3�x�1�}��4��A��;�t�#�$�$�
�3�x�1�}��H�M�M�#�&�&�{�2�3�s�w�w�y�>�A�$�F�F�rc��t|t�rB|r@|dj�dvrtd�S|dj�dvrtd�S|S)zD Convert an arbitrary 0/1/T/F/Y/N string to a normalized string 0/1.r��1�t�yrx��0rK�nr|)�
isinstancers�lowerr�r�defaults  r�to_bool_strr��sK���!�S��a��Q�4�:�:�<�?�*��c�?�"�
�q�T�Z�Z�\�_�
,��c�?�"��Nrc��t|t�r0|r.|dj�dvry|dj�dvry|St|t�r|S|S)zG Convert an arbitrary 0/1/T/F/Y/N string to a boolean True/False value.rrwTr{F)r~rsr�boolr�s  r�to_boolr��sU���!�S��a��Q�4�:�:�<�?�*��
�q�T�Z�Z�\�_�
,���N�
�A�t�	����Nrc	#�K�|�|}	tj|�}|xsd}|jd�}|D]�}tjjtjj
||��}	|D]d}
tj||
�s�|s tjj|	�r�<|r|	���C	tjj|	����f|s��tjj|	�s��t|	|||||�D]}|�����y#tj$rYywxYw#t$r|	��Y��wxYw�w)Nr�;)r1�listdirrZr:rV�normpathrY�fnmatch�isdir�basename�
ValueError�	walkFiles)r*�recurse�	abs_paths�return_folders�patternrV�names�pat_listrD�fullname�patrKs            rr�r�s#�����|�����
�
�4� ��
�n��G��}�}�S�!�H�����7�7�#�#�B�G�G�L�L��t�$<�=���		+�C����t�S�)�!������x�)@� �&��+�"$�'�'�"2�"2�8�"<�<�		+��r�w�w�}�}�X�.��x��)�^�W�VZ�[�
����
�%���8�8�����$ *�+�"*�N�+�sd�E
�D�A4E
�!E
�4E
�<!D7�E
�"E
�E
�D4�1E
�3D4�4E
�7
E�E
�E�E
c�\�tjj|�r�tj|�}|tjdz}|dzry|tj
tj�k(r|dzry|tjtj�k(r|dzryy)Ni�r$T��F)	r1rVrWr2�ST_MODE�ST_GID�getgid�ST_UID�getuid)rVr�modes   r�is_path_writabler�(s|��	�w�w�~�~�d���G�G�D�M��������&���#�:��
�t�{�{�^�r�y�y�{�
*�t�d�{��
�t�{�{�^�r�y�y�{�
*�t�e�|��rc�&�eZdZdZdZdZd�Zdd�Zy)�
TextFormatterrrr$c�h�g|_|D]&}|jjtdi|����(y)N�)�columns�append�Column)�self�colspeclist�colspecs   r�__init__zTextFormatter.__init__@s2�����"�	3�G��L�L���� 1�� 1�2�	3rc��d}t|�}t|�t|j�k7rtj	d�yttd�||j��D]5\}}|j
|�t|t|j��}�7dg|z}t|�D]-}|jD]}|||j|�z||<��/|rdj|�dzSdj|�S)Nrz6Formatter: Number of text items does not match columnsc��|Srr���xs r�<lambda>z'TextFormatter.compose.<locals>.<lambda>Ks���rr+�
)�listrgr�rBrZ�map�wrap�max�lines�range�getlinerY)r��textlist�add_newline�numlines�text�column�	complines�lns        r�composezTextFormatter.composeEs�������>���x�=�C����-�-��I�I�N�O�� ��\�8�T�\�\�!J�K�	8�L�D�&��K�K����8�S����%6�7�H�	8��D�8�O�	���/�	C�B��,�,�
C�� )�"�
����r�0B� B�	�"�
�
C�	C���9�9�Y�'�$�.�.��9�9�Y�'�'rN�F)�__name__�
__module__�__qualname__�LEFT�CENTER�RIGHTr�r�r�rrr�r�:s��
�D�
�F�
�E�3�
(rr�c�@�eZdZdejdfd�Zd�Zd�Zd�Zy)r��Nrc�N�t|�|_||_||_g|_yr)�int�width�	alignment�marginr�)r�r�r�r�s    rr�zColumn.__init__Ys"����Z��
�"��������
rc��|jtjk(r|j|j�S|jtj
k(r|j
|j�S|j|j�Sr)r�r�r��centerr�r��rjust�ljust)r��lines  r�alignzColumn.align_s_���>�>�]�1�1�1��;�;�t�z�z�*�*�
�^�^�}�2�2�
2��:�:�d�j�j�)�)��:�:�d�j�j�)�)rc�x�g|_g}|j�D]r}|t|j�kr|j	|��-tdt
|�|j�D]#}|j	||||jz��%�tt
|�sy|jd�}|D]`}dt
|�z}t
|�|z|jkDr-|jj	|j|��|}�Y|dz|z}�b|jj	|j|��y)Nrrr,)	r�r:rsr�r�r�rgrtr�)r�r��words�word�i�current�	increments       rr�zColumn.wrapgs����
����J�J�L�	7�D��s�4�:�:��&����T�"��q�#�d�)�T�Z�Z�8�7�A��L�L��a��$�*�*��!5�6�7�		7��5�z�6��)�)�A�,���	/�D��C��I�
�I��7�|�i�'�$�*�*�4��
�
�!�!�$�*�*�W�"5�6���!�C�-�$�.��
	/�	
�
�
���$�*�*�W�-�.rc��|t|j�krd|jz|j|zSd|j|jzzS)Nr,)rgr�r�r�)r��indexs  rr�zColumn.getline{sF���3�t�z�z�?�"��t�{�{�?�T�Z�Z��%6�6�6��$�+�+��
�
�2�3�3rN)	r�r�r�r�r�r�r�r�r�r�rrr�r�Ws#���=�+=�+=�a��*�/�(4rr�c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�Stackc��g|_yr��stack�r�s rr�zStack.__init__��	����
rc�6�|jj�Sr�r�rtr�s rrtz	Stack.pop�s���z�z�~�~��rc�:�|jj|�yr)r�r��r��values  r�pushz
Stack.push�s���
�
���%� rc��|jSrr�r�s r�as_listz
Stack.as_list�s���z�z�rc��g|_yrr�r�s r�clearzStack.clear�r�rc�,�t|j�Sr)rgr�r�s r�__len__z
Stack.__len__�s���4�:�:��rN)	r�r�r�r�rtr�r�r�r�r�rrr�r��s ��� �!���rr�c��eZdZd�Zd�Zd�Zy)�Queuec�.�tj|�yr)r�r�r�s rr�zQueue.__init__�s��
���t�rc�8�|jjd�S�Nrr�r�s r�getz	Queue.get�s���z�z�~�~�a� � rc�0�tj||�yr)r�r�r�s  r�putz	Queue.put�s��
�
�
�4��rN)r�r�r�r�r�r�r�rrr�r��s���!� rr�c�&�eZdZdd�Zd�Zd�Zd�Zy)�
RingBufferc� �||_g|_yr)r��data)r��size_maxs  rr�zRingBuffer.__init__�s�������	rc��|jj|�t|j�|jk(rd|_t
|_yy)z*append an element at the end of the bufferrN)r�r�rgr��cur�RingBufferFull�	__class__�r�r�s  rr�zRingBuffer.append�s;���	�	������t�y�y�>�T�X�X�%��D�H�+�D�N�&rc�"�||jd<y)z.replace the last element instead off appending���N�r�rs  rr9zRingBuffer.replace�s����	�	�"�
rc��|jS)z8 return a list of elements from the oldest to the newestrr�s rr�zRingBuffer.get�s���y�y�rN)�2�r�r�r�r�r�r9r�r�rrr�r��s���,��rr�c�$�eZdZd�Zd�Zd�Zd�Zy)r�c��yrr�)r�r}s  rr�zRingBufferFull.__init__�s��rc�x�||j|j<|jdz|jz|_y�Nr)r�r�r�rs  rr�zRingBufferFull.append�s,����	�	�$�(�(���H�H�Q�J�$�(�(�*��rc��|jdz
|jz|_||j|j<|jdz|jz|_yr)r�r�r�rs  rr9zRingBufferFull.replace�sD���H�H�Q�J�$�(�(�*�����	�	�$�(�(���H�H�Q�J�$�(�(�*��rc�h�|j|jd|jd|jzSr)r�r�r�s rr�zRingBufferFull.get�s+���y�y�����#�d�i�i�	����&:�:�:rNrr�rrr�r��s��
�+�+�;rr�c���t|j��}|D�cgc]}|d|dg��}}|j�tdt	|��D�cgc]
}||d��c}Scc}wcc}w)z9 Returns the keys of dictionary d sorted by their values rr)r��items�sortr�rg)�dr�v�	backitemsr�s     r�sort_dict_by_valuer�sf��
�q�w�w�y�/�E�$)�*�q��!��Q�q�T�{�*�I�*�
�N�N��%*�1�c�)�n�%=�>��I�a�L��O�>�>��+��>s�A*�A/c�2�tjd|d��S)N�%sT)�grouping)�locale�format)�vals r�commafyr�s���=�=��s�T�2�2rc�"�|dkrdjt|�dg�Sd|cxkrdkrtnnq|r=djtt|dzd��td�t|�dg�Sdjtt|dzd��td	�g�Sd|cxkrd
krtnnq|r=djtt|dzd��td�t|�dg�Sdjtt|dzd��td
�g�S|r=djtt|dzd��td�t|�dg�Sdjtt|dzd��td�g�S)Nir+z Big�@rz KB (�)z KBi@g0Az MB (z MBg�Az GB (z GB)rYrr�round)r�
show_bytess  r�format_bytesr �s^���4�x��w�w���
�D�)�*�*�	
��	�G�	���7�7�J�u�Q�v�X�q�'9�:�Z��=P�SZ�[\�S]�_b�c�d�d��7�7�J�u�Q�v�X�q�'9�:�Z��=N�O�P�P�	�1�	!�z�	!���7�7�J�u�Q�y�[�!�'<�=�z�'�?R�U\�]^�U_�ad�e�f�f��7�7�J�u�Q�y�[�!�'<�=�z�%�?P�Q�R�R���7�7�J�u�Q�|�^�Q�'?�@�*�W�BU�X_�`a�Xb�dg�h�i�i��7�7�J�u�Q�|�^�Q�'?�@�*�U�BS�T�U�Urc���tj|�}tj|tjtj
ztjzd�}tj|d�|fS)Ni�zw+b)�tempfile�mktempr1r-�O_RDWR�O_CREAT�O_EXCL�fdopen)�suffix�prefixr]r�rV�fds      r�make_temp_filer+�sN�����v�&��
�W�W�T�2�9�9�R�Z�Z�/��	�	�9�5�
A�����B��'��/�/rc��g}tjd�}|r|jd�}|jd�|jd�|jd�|jd�|jd�d}|D] }	tj|�}||vs�|}n|r#|r tjj||�Sy|S#t
$rY�UwxYw)	N�PATH�:z/usr/binz/usr/local/binz/sbinz	/usr/sbinz/usr/local/sbinr+)r1�getenvr:r�r�r5rVrY)�command�return_full_pathrV�path_val�
found_path�p�filess       r�whichr6�s���	�D��y�y�� �H���~�~�c�"���K�K�
���K�K� �!��K�K����K�K����K�K�!�"��J�
���	��J�J�q�M�E��%���
������7�7�<�<�
�G�4�4������	��	�s�C�	C�Cc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�UserSettingsc�$�|j�yr)�loadr�s rr�zUserSettings.__init__ s���	�	�rc�T�d|_td�}t|�dkDrd|_nbtd�}t|�dkDrd|_nAtd�}t|�dkDrd|_n td	�}t|�dkDrd
|_d|_td�}t|�dkDrd|_nbtd
�}t|�dkDrd|_nAtd�}t|�dkDrd|_n td�}t|�dkDrd|_td�}t|�rd|_nd|_td�}t|�rd|_nd|_td�}t|�rd|_nd|_td�}t|�rd|_yd|_y)Nr+zhp-printrzhp-print -p%PRINTER%�kprinterz"kprinter -P%PRINTER% --system cups�gtklpzgtklp -P%PRINTER%�xppzxpp -P%PRINTER%zsimple-scanzsimple-scan %SANE_URI%�xsanezxsane -V %SANE_URI%�kooka�
xscanimagez	hp-unloadzhp-unload -d %DEVICE_URI%z'python %HOME%/unload.py -d %DEVICE_URI%z
hp-makecopieszhp-makecopies -d %DEVICE_URI%z+python %HOME%/makecopies.py -d %DEVICE_URI%z
hp-sendfaxzhp-sendfax -d %FAX_URI%z%python %HOME%/sendfax.py -d %FAX_URI%zhp-fabzpython %HOME%/fab.py)�	cmd_printr6rg�cmd_scan�	cmd_pcard�cmd_copy�cmd_fax�cmd_fab)r�rVs  r�loadDefaultszUserSettings.loadDefaults#sq������Z� ���t�9�q�=�3�D�N���$�D��4�y�1�}�!E����W�~���t�9�q�=�%8�D�N� ��<�D��4�y�1�}�):�����
��]�#���t�9�q�=�4�D�M���>�D��4�y�1�}� 5��
��W�~���t�9�q�=�$+�D�M� ��.�D��4�y�1�}�(4��
��[�!���t�9�8�D�N�F�D�N��_�%���t�9�;�D�M�I�D�M��\�"���t�9�4�D�L�B�D�L��X����t�9�#�D�L�1�D�Lrc��|j�tjd�ttjddd��|_	ttjddd��|_	ttjddd��|_
tjd
d|j�|_tjd
d|j�|_tjd
d
|j�|_
tjd
d|j�|_tjd
d|j�|_tjd
d|j �|_ttjddd��|_ttjddd��|_ttjddd��|_t)tjddd��|_|j�y#t$rd|_Y���wxYw#t$rd	|_
Y���wxYw)NzLoading user settings...�refresh�enabler|�rate�30��typer�commands�prnt�scan�pcard�cpy�fax�fab�upgrade�notify_upgrade�last_upgraded_time�pending_upgrade_time�latest_available_versionr+)rHrBrCr��	user_confr��auto_refreshr��auto_refresh_rater��auto_refresh_typerBrCrDrErFrG�upgrade_notify�upgrade_last_update_time�upgrade_pending_update_timersr[r�s rr:zUserSettings.loadis��������	�	�,�-�#�I�M�M�)�X�s�$K�L���	(�%(����y�&�$�)O�%P�D�"�	'�%(����y�&�#�)N�%O�D�"�#���z�6�4�>�>�J���!�
�
�j�&�$�-�-�H��
�"���z�7�D�N�N�K���!�
�
�j�%����G��
� �}�}�Z�����E��� �}�}�Z�����E���$�Y�]�]�9�>N�PS�%T�U���(+�I�M�M�)�DX�Z]�,^�(_��%�*-�i�m�m�I�G]�_b�.c�*d��(�&)�)�-�-�	�C]�^`�*a�&b��%��
�
���'�	(�%'�D�"�	(��
�	'�%&�D�"�	'�s$�%H �2%H7� H4�3H4�7I�
Ic�4�tjd|jz�tjd|jz�tjd|jz�tjd|j
z�tjd|jz�tjd|jz�tjd|jz�tjd|jz�tjd	|jz�tjd
|jz�tjd|jz�tjd|jz�y)
NzPrint command: %szPCard command: %szFax command: %szFAB command: %szCopy command: %s zScan command: %szAuto refresh: %szAuto refresh rate: %szAuto refresh type: %szUpgrade notification:%dzLast Installed time:%dz#Next scheduled installation time:%d)rBrCrBrDrFrGrErCr]r^r_r`rarbr�s rrCzUserSettings.debug�s���	�	�%����6�7��	�	�%����6�7��	�	�#�d�l�l�2�3��	�	�#�d�l�l�2�3��	�	�%��
�
�5�6��	�	�$�t�}�}�4�5��	�	�$�t�'8�'8�8�9��	�	�)�D�,B�,B�B�C��	�	�)�D�,B�,B�B�C��	�	�+�d�.A�.A�A�B��	�	�*�D�,I�,I�I�J��	�	�7�$�:Z�:Z�Z�[rc�f�tjd�tjdd|j�tjdd|j
�tjdd|j�tjdd|j�tjdd|j�tjdd	|j�tjdd
|j�tjdd|j�tjdd
|j�tjdd|j�tjdd|j�tjdd|j�|j�y)NzSaving user settings...rPrQrSrUrRrTrJrKrLrOrWrXrYrZr[)rBrCr\�setrBrDrFrCrEr]r^r_r`rarbr[r�s r�savezUserSettings.save�s���	�	�+�,��
�
�j�&�$�.�.�9��
�
�j�'�4�>�>�:��
�
�j�%����6��
�
�j�&�$�-�-�8��
�
�j�%����7��
�
�i��$�*;�*;�<��
�
�i���)?�)?�@��
�
�i���)?�)?�@��
�
�i�!1�4�3F�3F�G��
�
�i� 4�d�6S�6S�T��
�
�i�!7��9Y�9Y�Z��
�
�i�!;�T�=Z�=Z�[��
�
�rN)r�r�r�r�rHr:rCrfr�rrr8r8s���D2�L�8\�rr8c�6�	ddl}|j�}|j||j|jz|j
|jd�}|j�|j�y#t$rtjd�YywxYw)Nrz`PyQt not installed. GUI not available. Please check that the PyQt package is installed. Exiting.)�gtk�Window�
MessageDialog�DIALOG_MODAL�DIALOG_DESTROY_WITH_PARENT�MESSAGE_WARNING�
BUTTONS_OK�run�destroy�ImportErrorrBrZ)rhrR�dialogs   r�no_qt_message_gtkrs�s���
v���J�J�L���"�"�1�c�&6�&6��9W�9W�&W�#&�#6�#6����$F�G��	�
�
��������v��	�	�t�u�v�s�A4A7�7B�Bc���tjstjd�yt	j
d�stjd�yt
�stjd�yy)N�GUI mode disabled in build.F�DISPLAY�No display found.z Qt/PyQt 3 initialization failed.T)rS�	gui_buildrB�warnr1r/�checkPyQtImportr�rr�canEnterGUIModer{�sN���>�>����.�/��
�Y�Y�y�
!����$�%��
�
����3�4��rc��tjstjd�yt	j
d�stjd�y	t
�y#t$r}tj|�Yd}~yd}~wwxYw)NruFrvrwT)rSrxrBryr1r/�checkPyQtImport45rq)�es r�canEnterGUIMode4r�se���>�>����.�/��
�Y�Y�y�
!����$�%��	���
��	�	��H�H�Q�K���	�s�
A�	B�'B�Bc���	ddl}ddl}t|j�jd�d�}|tkrtjd�y	|j}|jd�dkr|d	z
}|jd�dkr�|jd�\}}}|j!d
�dk\rtj#d�y	t|�}t|�}t|�}|t&ks|t&k(r\|t(krStjd
|||fz�tjdt&t(fz�tjd�yy#t$rLtjd�rtjd�r
t�tjd�YywxYw#t$r|j}Y��nwxYw#t$$r	d\}}}Y��wxYw)Nrrv�STARTED_FROM_MENUz/PyQt not installed. GUI not available. Exiting.FrQzBIncorrect version of Qt installed. Ver. 3.0.0 or greater required.r$z.0�snapshotz3A non-stable snapshot version of PyQt is installed.)rrrz]This program may not function properly with the version of PyQt that is installed (%d.%d.%d).zDIncorrect version of pyQt installed. Ver. %d.%d or greater required.zUThis program will continue, but you may experience errors, crashes or other problems.T)�qt�uirqr1r/rsrBrZr��qVersionr:�MINIMUM_QT_MAJOR_VER�PYQT_VERSION_STR�AttributeError�PYQT_VERSION�count�find�warningr��MINIMUM_PYQT_MAJOR_VER�MINIMUM_PYQT_MINOR_VER)r�r��qtMajor�pyqtVersion�maj_ver�min_ver�pat_vers       rrzrz�s�������"�+�+�-�%�%�c�*�1�-�.�G��%�%��	�	�V�W��&��)�)���
�
�C�
 �1�
$��t����
�
�C�
 �1�
$�#.�"3�"3�C�"8��W�g�w����
�#�q�(����I�J� �	0��'�l�G��'�l�G��'�l�G��+�+�
�.�
.�7�=S�3S��I�I�u�zA�CJ�LS�yT�T�
U��I�I�\�`v�yO�`P�P�
Q��I�I�m�n����W��
�9�9�Y��B�I�I�.A�$B����	�	�C�D����$�&��o�o��&���	0�(/�%�G�W�g�	0�s6�E�F7�!G�AF4�3F4�7G�G�G%�$G%c�n�	ddl}ddl}tjd�y#t$rddl}ddl}YywxYw)NrzgHPLIP is not installed properly or is installed without graphical support. Please reinstall HPLIP againFT)�PyQt4�ui4rBrCrq�PyQt5�ui5)r�r�r�r�s    r�checkPyQtImport4r�s;�����
	�	�	�{�|��������
�s� �4�4)�Templatec��eZdZdZd�Zd�Zy)�	_multimapz�Helper class for combining multiple mappings.

        Used by .{safe_,}substitute() to combine the mapping and keyword
        arguments.
        c� �||_||_yr)�_primary�
_secondary)r��primary�	secondarys   rr�z_multimap.__init__1s��#�D�M�'�D�Orc�^�	|j|S#t$r|j|cYSwxYwr)r��KeyErrorr��r��keys  r�__getitem__z_multimap.__getitem__5s4��
,��}�}�S�)�)���
,����s�+�+�
,�s��,�,N)r�r�r��__doc__r�r�r�rrr�r�+s��	�
	(�	,rr�c�"��eZdZdZ�fd�Z�xZS)�_TemplateMetaclassaK
        %(delim)s(?:
          (?P<escaped>%(delim)s) |   # Escape sequence of two delimiters
          (?P<named>%(id)s)      |   # delimiter and a Python identifier
          {(?P<braced>%(id)s)}   |   # delimiter and a braced identifier
          (?P<invalid>)              # Other ill-formed delimiter exprs
        )
        c�@��tt|�|||�d|vr
|j}n=tjt	j
|j�|jd�z}t	j|tjtjz�|_y)Nr�)�delim�id)�superr�r�r�r6�escape�	delimiter�	idpattern�compile�
IGNORECASE�VERBOSE)�clsrD�bases�dctr�rs     �rr�z_TemplateMetaclass.__init__Fsu����$�c�3�D�%��E��C���+�+��,�4�4� �i�i��
�
�6�!�m�m�8����*�*�W�b�m�m�b�j�j�.H�I�C�Kr)r�r�r�r�r��
__classcell__)rs@rr�r�<s�����		J�		Jrr�c�4�eZdZdZeZdZdZd�Zd�Z	d�Z
d�Zy)	r�z.A string class for supporting $-substitutions.�$z[_a-z][_a-z0-9]*c��||_yr)�template)r�r�s  rr�zTemplate.__init__\s	��$�D�Mrc���|jd�}|jd|jd�}|sd}d}n+|tdj	|dd��z
}t|�}td||fz��)N�invalidTrr+rz.Invalid placeholder in string: line %d, col %d)�startr��
splitlinesrgrYr�)r��mor�r��colno�linenos      r�_invalidzTemplate._invalid`s{������#�A��M�M�"�1�%�0�0��6�E�������C�����c�r�
� 3�4�4���U����M�$�e�_�-�.�
.rc�����t|�dkDrtd��|s|�n|rt||d��n|d���fd�}�jj	|�j
�S)Nr�Too many positional argumentsrc���|jd�xs|jd�}|�
�|}d|zS|jd���jS|jd���j|�td�j��)N�named�bracedr�escapedr��#Unrecognized named group in pattern)�groupr�r�r�r�)r�r�r�mappingr�s   ��r�convertz$Template.substitute.<locals>.convertvs��������)�?�R�X�X�h�-?���$�!�%�.�C� �#�:�%��8�8�I�&�2��>�>�)��8�8�I�&�2��M�M�"�%� �!F�!%���/�/r�rg�	TypeErrorr�r��subr��r��args�kwsr�r�s`   @r�
substitutezTemplate.substitutels`����4�y�1�}�� ?�@�@�����#�C��a��1���q�'��

/��<�<�#�#�G�T�]�]�;�;rc�����t|�dkDrtd��|s|�n|rt||d��n|d���fd�}�jj	|�j
�S)Nrr�rc���|jd�}|�		d�|zS|jd�}|�		d�|zS|jd���jS|jd���jStd�j��#t$r�j|zcYSwxYw#t$r�jdz|zdzcYSwxYw)	Nr�rr��{�}r�r�r�)r�r�r�r�r�)r�r�r�r�r�s   ��rr�z)Template.safe_substitute.<locals>.convert�s��������)���$�6� $�g�e�n�4�4����(�+���%�C�#�g�f�o�5�5��8�8�I�&�2��>�>�)��8�8�I�&�2��>�>�)� �!F�!%���/�/��$�6�#�~�~��5�5�6��$�C�#�~�~��3�f�<�s�B�B�C�s"�B
�B(�
B%�$B%�(C	�C	r�r�s`   @r�safe_substitutezTemplate.safe_substitute�s`����4�y�1�}�� ?�@�@�����#�C��a��1���q�'��
/�*�<�<�#�#�G�T�]�]�;�;rN)r�r�r�r�r��
__metaclass__r�r�r�r�r�r�r�rrr�r�Us(��<�*�
��	�'�	�	%�
	.�	<�6	<rr�c�D�tjd�jj�}d|vr|d=tjd�jj�}d|vr|d=t|�jtjd�jfi|��S)Nrr�)�sys�	_getframe�	f_globals�copy�f_localsr�r�)r�globals�localss   r�catr��s����m�m�A��(�(�-�-�/�G�
����F�O�
�]�]�1�
�
&�
&�
+�
+�
-�F�
����6�N�!�8�A�;�!�!�#�-�-��"2�"<�"<�G��G�Grrzutf-8c�6�|jtt�Sr)rc�identity�unprintablers r�	printabler��s���;�;�x��-�-rc��|Srr�r�s rr�r�����Q�rc�&�|D]}||�s�yy)NTFr���SrKr�s   r�anyr��s��
����Q�4���rc��|Srr�r�s rr�r��r�rc�&�|D]}||�r�yy)NFTr�r�s   r�allr��s��
�"����t�E�"�r)�firefox�mozilla�	konqueror�epiphany�	skipstonez-new-tabz	--new-tabc��trtj�dk(rytd�rytD]}t|�s�|cSy)N�Darwinr-�xdg-open)�platform_avail�platform�systemr6�BROWSERS)�bs r�find_browserr��sA���(�/�/�+�x�7��	�z�	���	�A��Q�x���	�rc��tr2tj�dk(rd|z}tj|�ytd�rd|z}tj|�ytD]E}t|d��}|s�|r|�dt|�d|�d	�}n|�d|�d	�}tj|�ytjd
|z�y)Nr�z	open "%s"r�z
xdg-open "%s"�True)r1r,z "z" &zUnable to open URL: %s)
r�r�r�r�executer6r��BROWSER_OPTSrBry)�url�use_browser_opts�cmdr��bbs     r�openURLr�s����(�/�/�+�x�7��C��������	�z�	���#��������
	5�A��q�6�2�B��#�02�L��O�S�I�C�-/��5�C�� � ��%��
	5�
�H�H�-��3�4rc�v�g}|D�cgc]%}|j|�r�|j|���'c}|Scc}wr)r�r�)�input�tempr�s   r�
uniqueListr�s1��
�D�"�8��$�*�*�Q�-�T�[�[��^�8��K��9s�6�6c���������fd�}n���fd�}tdt���D]"}||�s��|�|dz
c�|dz
<�|<�$y)Nc����|�k(Srr��r��l�ms ��rr�zlist_move_up.<locals>.<lambda>�����a��d�a�i�rc�����|��Srr��r��cmprrs ���rr�zlist_move_up.<locals>.<lambda>�����c�!�A�$��l�rr�r�rg�rrrrKr�s```  r�list_move_upr�sV���
�{���"��
�1�c�!�f�
�(���Q�4��Q�4��1�Q�3��L�A�a��c�F�A�a�D�(rc���������fd�}n���fd�}tt��dz
dd�D]"}||�s��|dz�|c�|<�|dz<�$y)Nc����|�k(Srr�rs ��rr�z list_move_down.<locals>.<lambda>rrc�����|��Srr�rs ���rr�z list_move_down.<locals>.<lambda>	rrr$rrrrs```  r�list_move_downrs\���
�{���"��
�3�q�6�!�8�R��
$�(���Q�4��Q�q�S�6�1�Q�4�L�A�a�D�!�A�a�C�&�(rc�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�XMLToDictParserc�.�g|_i|_d|_y�Nr+)r�r��
last_startr�s rr�zXMLToDictParser.__init__s����
���	���rc��|jjt|�j��t|�j�|_t|�rh|D]b}|jjt|�j��|j
||�|jj��dyyr)r�r�rrr!rg�addDatart)r�rD�attrs�as    r�startElementzXMLToDictParser.startElements����
�
���*�T�*�0�0�2�3�$�T�*�0�0�2����u�:��
!���
�
�!�!�*�Q�-�"5�"5�"7�8����U�1�X�&��
�
��� �
!�rc��|j�|jk(r|jd�|jj	�yr )rr!r#r�rt�r�rDs  r�
endElementzXMLToDictParser.endElement"s0���:�:�<�4�?�?�*��L�L���	
�
�
���rc�x�t|�j�}|r|jr|j|�yyyr)r�stripr�r#)r�r�s  r�charDatazXMLToDictParser.charData)s1���$��%�%�'���D�J�J��L�L����4rc
��d|_	t|�}dj	|j
�}dj	|dg�}	|j||j||j|<||jdj	|dg�<|j|=y#t$rt|�}Y��wxYw#t$r�	|j|d}		|jdj	|t|�g�n9#t$r-||jdj	|t|�g�<YYywxYw|dz
}�j#t$r||j|<YYywxYwwxYw)Nr+�-r|rxr$r)r!r�r�rrYr�r�r�)r�r��	stack_str�stack_str_0�js     rr#zXMLToDictParser.addData/sZ�����	$��t�9�D��H�H�T�Z�Z�(�	��h�h�	�3�/�0��	%��I�I�i� �"&*�Y�Y�y�%9�D�I�I�k�"�48�D�I�I�c�h�h�	�3�/�0�1��	�	�)�$��5�	$��d�#�D�	$���
	�
��	�	�+�&������	�	�#�(�(�I�z�!�}�+E�"F�G��#��JN��	�	�#�(�(�I�z�!�}�+E�"F�G������F�A�
��	�
,�'+��	�	�)�$�
,��
	�se�B�B6�B3�2B3�6	E�D<�E�)C=�<E�=2D3�/E�2D3�3	E�<E�E�E�Ec��tretj�}|j|_|j
|_|j|_|j|d�|jStjd�|jS�NTzRFailed to import expat module , check python-xml/python3-xml package installation.)
�xml_expat_avail�expat�ParserCreater&�StartElementHandlerr)�EndElementHandlerr,�CharacterDataHandler�ParserBrZr�)r�r��parsers   r�parseXMLzXMLToDictParser.parseXMLQsl����'�'�)�F�)-�):�):�F�&�'+���F�$�*.�-�-�F�'��L�L��t�$�
�y�y��
�I�I�j�k��y�y�rN)	r�r�r�r�r&r)r,r#r<r�rrrrs!���
	!���%�D
rrc�<�eZdZd�Zd�Zd�Zd�Zd	d�Zd
d�Zdd�Z	y)�Elementc�<�||_||_d|_g|_yr )rD�
attributes�chardata�children)r�rDr@s   rr�zElement.__init__bs����	�$�����
���
rc�:�|jj|�yr)rBr�)r��elements  r�AddChildzElement.AddChildhs���
�
���W�%rc�8�|jj|�Sr)r@r�r�s  r�getAttributezElement.getAttributeks�����"�"�3�'�'rc��|jSr)rAr�s r�getDatazElement.getDatans���}�}�rNc��|r
|j}n|j}|s|jSg}|D]L}|j|k(r|j|�|j||�}|D]}|j|���N|Sr)rBrDr��getElementsByTagName)r�rD�ElementNode�
Children_list�elementsrD�rec_elementsr%s        rrKzElement.getElementsByTagNameqs����'�0�0�M� �M�M�M���=�=� ��H�(�
'���<�<�4�'��O�O�G�,�#�8�8�$�w�G��%�'�A��O�O�A�&�'�
'��Orc��|s|jSg}|jD]#}|j|k(s�|j|��%|Sr)rBrDr�)r�rDrNrDs    r�getChildElementszElement.getChildElements�sF����=�=� ��H��=�=�
-���<�<�4�'��O�O�G�,�
-��Orc��d|z}|d|jzz
}|jD]}|d|�d|j|�d�z
}�d}|jD]}||j|dz�z
}�|dk(r7|jr$|d|jzd|jzzz
}|S|d	z
}|S|d|zd|jzzz
}|S)
Nr,z<%sz="rrr+r�>z</%s>z/>)rDr@rB�toStringrA)r��level�retval�	attribute�c�childs      rrTzElement.toString�s����u����%�$�)�)�#�#�����	M�I��i�����1K�L�L�F�	M����]�]�	)�E�
�����a��(�(�A�	)���7��}�}��#�d�m�m�+�w����/B�C�C��
�
��$����
�
�c�A�g��4�9�9�!4�5�5�F��
r)r+N)r+�r)
r�r�r�r�rErGrIrKrQrTr�rrr>r>as%���&�(���$�rr>c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�
extendedExpatc� �d|_g|_yr)r*�	nodeStackr�s rr�zextendedExpat.__init__�s����	���rc���t||�}t|j�dkDr!|jd}|j|�n||_|jj|�y)Nrr)r>rgr^rEr*r�)r�rDr@rD�parents     r�StartElement_EEzextendedExpat.StartElement_EE�sR���$�
�+���t�~�~���"��^�^�B�'�F��O�O�G�$��D�I������g�&rc�,�|jdd|_y�Nr)r^r(s  r�
EndElement_EEzextendedExpat.EndElement_EE�s�������,��rc�R�|r%|jd}|xj|z
c_yyrc)r^rA)r�r�rDs   r�charData_EEzextendedExpat.charData_EE�s,����n�n�R�(�G�����$���rc��tretj�}|j|_|j
|_|j|_|j|d�|jStjd�|jSr3)
r4r5r6rar7rdr8rfr9r:rBrZr*)r��	xmlString�Parsers   rr:zextendedExpat.Parse�sp����'�'�)�F�)-�)=�)=�F�&�'+�'9�'9�F�$�*.�*:�*:�F�'��L�L��D�)��y�y��
�I�I�j�k��y�y�rN)r�r�r�r�rardrfr:r�rrr\r\�s���'�-��rr\c�*�djd|dg�S)Nr+rr)rYrs r�dquoterk�s��
�7�7�C��C�=�!�!ri�c
�z�d}t|ttt|����D]\}}||vs�n||dSr�)�zipr�r�rg)r�charsr�rXs    r�xlstripro�sE��
����4��c�!�f�
�.�/�	�D�A�q���~��	����u�rc�>�ttt|�|��Sr��xreversero�rrns  r�xrstriprt�s�������U�3�4�4rc�Z�t|�}|j�dj|�Sr )r��reverserY)rrs  rrrrr�s"����G��	�	�	���w�w�q�z�rc
�R�tttt||��|��Srrqrss  r�xstriprx�s �������E�):� ;�U�C�D�Drc��tr#ttj�ddd�St	j
d�dzS)Nr����Pr%)r�r�r��architecture�struct�calcsizer�rr�
getBitnessr�s9����8�(�(�*�1�-�c�r�2�3�3����s�#�q�(�(rc�t�tr2tj�jdd�j	�Sy)Nr,�_�i686)r�r��machiner9rr�rr�getProcessorr��s-������!�)�)�#�s�3�9�9�;�;�rc�@�tjdk(rtStS)N�big)r��	byteorder�
BIG_ENDIAN�
LITTLE_ENDIANr�rr�	getEndianr��s��
�}�}������rc���ddl}|j�}d}|r�d|vsd|vr�tj�dk7rq|j	�}t
j
d|�d|�d��|dk(r@|j|d�}	|j	�}t
j
d|z�|	dk(ry		tj||�
�}
	d}	|r
t�	|
jt�}
|
jr�|ro|tvrgt
j
d|z�	t!j"|t j$�}tj'|�tj'|�	|j+|
j�|rt
j
|
j�|
dk(rnR|
d
k(r��|
dk(r|
j-d�n3|std��|
j-|j||��|d
z
}��4	|r
t1�	|
j3�|
j4|j7�fS#tj$r
}Yd}~yd}~wwxYw#t$rY���wxYw#t($rtj'|�Y�� wxYw#t$rY��wxYw#t$r"}t
j/d|z�Yd}~��d}~wwxYw#tj$r
}Yd}~��d}~wwxYw)Nrr+�su�sudozcmd = z pwd_prompt_str = [�]zpwd_prompt_str2 = [%s])�r+)�timeout)rr+zAdding %s to EXPECT LISTrr$�YESz.password Object(i.e. passwordObj) is not validz
Exception: %s)�iorr1rU�getPasswordPromptStringrBrC�getPasswordr#�spawnu�ExceptionPexpect�update_spinner�expect�EXPECT_LIST�	Exception�beforer6r��Ir�r��write�sendlinerZ�cleanup_spinnerr=�
exitstatus�getvalue)r�passwordObj�pswd_msg�
log_output�spinnerr�r��output�pwd_prompt_str�passwdrYr~�pswd_queried_cntr�r4s               rroro�s���
�
�[�[�]�F��N�����v��}�"�*�*�,�!�:K�$�<�<�>���	�	�C��H�I��R�� �,�,�X�q�9�F�(�@�@�B�N��I�I�.��?�@���|������s�G�4��.'������ �
��L�L��-���|�|�!�n�K�&G��I�I�8��G�H�;��J�J�~�r�t�t�<��$�*�*�1�-�#�*�*�>�:���L�L����.�!��	�	�%�,�,�/��A�v���a����a�����u�%�#�#�$T�U�U����{�6�6�x�AQ�R�S� �A�%� �S�8�"���
�
���
�
���V�_�_�.�.�.��u�#�#�������
��
��%�;�#�*�*�>�:�;��!�����&�'��	�	�/�A�%�&�&��'���#�#�
���
�s��*H3�J�I�'.J�$I#�:*J�%<J�!AJ�K�3I�I�	I �J�I � J�#J�J�J�J�	J�J�J�J�	K� J=�=K�K"�K"c
��g}|jtd��D�]e}|j�}|jd�}t|�dk(�r!|dj	td��}|dt|�d|d<|dr|dstd|z��|dtd	�k(st|dd�d	k7r|d
z
}nK|D�cgc]
}t|���}}|d|dkDrtd|z��|td�t
|�zz
}|D�cgc]}t|d
���}}|d|dkDrtd|z��t|d|ddz�D]}|j||z����U|j|���httt|�D��cgc]	\}}||f��c}}�j��}|D�cgc]}|s�t|���}}|j�|Scc}wcc}wcc}}wcc}w)z�Credit: Jean Brouwers, comp.lang.python 16-7-2004
       Convert a string representation of a set of ranges into a
       list of ints, e.g.
       u"1-4, 7, 9-12" --> [1,2,3,4,7,9,10,11,12]
    �,r.r$r�
0123456789Nrz
empty range: r|z%dzwide range: z%%0%dd�
zbad range: )r:rr+rg�rstripr�r�r�r�r�r��dict�	enumerate�keysr)�ns�fsr}�r�hr�rRr�s        r�expand_ranger�Ns���
�B�
�X�X�j��o�
&���
�G�G�I��
�G�G�C�L���q�6�Q�;��!����J�|�4�5�A��Q�4��A���=�A�a�D��a�D�Q�q�T� ��1�!4�5�5���t�z�#��&�*�Q�q�T�!�W�*=��*D��T�	��%&�'��S��V�'��'��Q�4�!�A�$�;�#�N�Q�$6�7�7��Z��)�C��F�2�2��%&�'���Q���'�A�'���t�a��d�{��
�� 1�2�2��1�Q�4��1��a��(�
!���	�	�!�a�%� �
!�
�I�I�a�L�1�6
�d�y��}�5�t�q�!�Q��F�5�6�;�;�=�	>�B��	"�Q��#�a�&�	"�B�	"��G�G�I�
�I��'(��
(��6��	"s�	G3�G8�G=�
H�
Hc�D�|syt|d�g|dd}}}|ddD]P}||dzk(rd}nA|r"|jtd�||fz�d}n|jtd�|z�|}�R|r|jtd	�z�dj|�S)
z} Convert a list of integers into a string
        range representation:
        [1,2,3,4,7,9,10,11,12] --> u"1-4,7,9-12"
    r+rFrNTz-%s,%sz,%sz-%s)rsr�rrY)r�rrXr�r�s     r�collapse_ranger�xs���

���1�Q�4�y�k�1�Q�4��!�q�A�
�q�r�U�
����1��:��A������H�-��1��5�6�������E�*�Q�.�/�
��
�	�	����E�"�Q�&�'�
�7�7�1�:�rc��|�tj�}d}t|ddddd��D]`}tjj	|�\}}|j|�s�7||k(s�=	t
|t|�d�}t||�}�btjj|d|||dz|fz�S#t$rY��wxYw�NrFr)r�r�r�r�rVz%s%0*d%sr�r1�getcwdr�rV�splitext�
startswithr�rgr�r�rY�	r��extr]�digitsrrKr�r~r�s	         r�createBBSequencedFilenamer������
�{��i�i�k��	�A�
�s�E�U�5�Z]�dh�
i�	���w�w����"���1��<�<��!�c�Q�h�
���#�h�-�.�)�*����1�I��	��7�7�<�<��Z�8�V�Q�q�S�#�*F�F�G�G���
��
���(B7�7	C�Cc��|�tj�}d}t|ddddd��D]`}tjj	|�\}}|j|�s�7||k(s�=	t
|t|�d�}t||�}�btjj|d|||dz|fz�S#t$rY��wxYwr�r�r�s	         r�createSequencedFilenamer��r�r�c��|�tj�}|S|j�j�}t	t
j
��D]\}}||vs�|Sd}tjd|z�|S)N�en_USz)Unknown lang/locale. Using default of %s.)	r�getSystemLocalerr+r��supported_localesrrBry)�lang�loc�lls   r�validate_languager��s����|��&�&�(���J��z�z�|�!�!�#���-�3�3�5�6�	H�G�C���r�z��
�J�	H��C��H�H�@�3�F�G��Jrc���	ddl}t|j��S#t$rGt	d�}|r7t
jj|d�}tj|�cYSYywxYw)Nr�uuidgenr+)
�uuidrs�uuid4rqr6r1rVrYr�	getoutput)r�r�s  r�gen_random_uuidr��s_��
���4�:�:�<� � �����	�"����g�g�l�l�7�I�6�G��'�'��0�0��
�s��AA/�.A/c� �eZdZdd�Zd�Zd�Zy)�RestTableFormatterNc� �||_g|_yr)�header�rows)r�r�s  rr�zRestTableFormatter.__init__�s�������	rc�:�|jj|�yr)r�r�)r��row_datas  r�addzRestTableFormatter.add�s���	�	����"rc
��|j�r�t|jd�}|jD]*}t|�|k7s�tjd|z�yt|j�|k7rtjd�g}t|j�D]M\}}t|�}|jD]}t
|t||��}�|j|dz��Od}|D]}dj|d|dzzdg�}�dj|dg�}|j|�|jr�d	}t|�D]G\}}dj|d
|j|d
|dzt|j|�z
zd	g�}�Idj|dg�}|j|�d}|D]}dj|d|dzzdg�}�dj|dg�}|j|�t|j�D]�\}	}d	}t|�D]M\}}dj|d
|j|	|d
|dzt|j|	|�z
zd	g�}�Odj|dg�}|j|�d}|D]}dj|d|dzzdg�}�dj|dg�}|j|���ytjd
�y)Nrz"Invalid number of items in row: %sz"Invalid number of items in header.r$�+r+r.r��|r,r�=zNo data rows)
r�rgrBrZr�r�r�r�rYr�)
r�rR�num_colsr��
col_widthsr�rX�	max_widthr�r1s
          rr�zRestTableFormatter.output�s����9�9��4�9�9�Q�<�(�H��Y�Y�
���q�6�X�%��I�I�B�Q�F�G��
�
�4�;�;��8�+��	�	�>�?��J�!�$�+�+�.�
/���1���F�	����:�A� #�I�s�1�Q�4�y� 9�I�:��!�!�)�A�+�.�
/��A��
3���G�G�Q��q��s��S�1�2��
3�����D�	�"�A�
�G�G�A�J��{�{���%�j�1�`�D�A�q�����C����Q����!��C����TU��DW�@W�9X�Z]� ^�_�A�`��G�G�Q��I�&������
���#�7�A�����C�1�Q�3�K�� 5�6�A�7��G�G�Q��I�&������
�"�$�)�)�,�

���1���%�j�1�b�D�A�q�����C����1��a��#��1��S����ST��VW��EY�AY�:Z�\_� `�a�A�b��G�G�Q��I�&������
���#�7�A�����C�1�Q�3�K�� 5�6�A�7��G�G�Q��I�&������
�

� 
�I�I�n�%rr)r�r�r�r�r�r�r�rrr�r��s���#�;&rr�c��ddl}|j�ddj}d|vrtd��|jj�}|j
dd�|j
dd�|j|�y)Nrrr�z(Must call mixin() from within class def.r�)�inspectr�r�r��__dict__r�rt�update)r�r�r�r�s    r�mixinr�sn���
�]�]�_�Q�
��
"�
+�
+�F��6�!��B�C�C��<�<����D��H�H�Y����H�H�\�4� �
�M�M�$�r)z	[OPTIONS]r+�headingF)zSet the logging level:z-l<level> or --logging=<level>�optionF)r+z5<level>: none, info\*, error, warn, debug (\*default)r�F)zRun in debug mode:z-g (same as option: -ldebug)r�F)zOutput plain text only:z-tr�F)z[PRINTER|DEVICE-URI]r+r�F)z	[PRINTER]r+r�F)zTo specify a device-URI:z'-d<device-uri> or --device=<device-uri>r�F)zTo specify a CUPS printer:z"-p<printer> or --printer=<printer>r�F)z'Bus to probe (if device not specified):z-b<bus> or --bus=<bus>r�F)r+zf<bus>: cups\*, usb\*, net, bt, fw, par\* (\*defaults) (Note: bt and fw not supported in this release.)r�F)zThis help information:z-h or --helpr�T)r+r+�spaceF)z	Examples:r+r�F)zNotes:r+r�F)znIf device or printer is not specified, the local device bus is probed and the program enters interactive mode.r+�noteF)z<If -p\* is specified, the default CUPS printer will be used.r+r�F)z	See Also:r+r�F)�Set the language:za--loc=<lang> or --lang=<lang>. Use --loc=? or --lang=? to see a list of available language codes.r�F)r�zF--lang=<lang>. Use --lang=? to see a list of available language codes.r�F)z[MODE]r+r�F)zRun in non-interactive mode:z-n or --non-interactiver�F)zRun in graphical UI mode:z-u or --gui (Default)r�F)zRun in interactive mode:z-i or --interactiver�F�	configurez
ui-toolkit�qt3)�Use Qt3:z--qt3 (Default)r�F)�Use Qt4:z--qt4r�F)�Use Qt5:z--qt5r�F�qt4)r�z--qt3r�F)r�z--qt4 (Default)r�F�qt5)r�z--qt5 (Default)r�Fc�^�tjd�j�d}ddd�}|jd�D]7}|j�}t	|�dk(s�"|d||d<|d||d<�9	t|d�t|d�}}||fS#t$rd	\}}Y||fSwxYw)
Nzstty -ar)r�r�r�r$rr�r�)��P)rr�r�r:rgr�r�)�ln1�vals�phr�r��colss      r�ttysizer�Ts���
�
�
�y�
)�
4�
4�
6�q�
9�C��4�(�D��i�i��n����H�H�J���q�6�Q�;��1��D��1��J��1��D��1��J�	�
���f��&��D��O�(<�d����:������
��d���:���s�8B�B,�+B,c��t�\}}|r|}||z
dz
}nt|dz�dz
}||z
dz
}t|dd�|dd�f�S)N�r%r$)r�r�)r�r�r�)�overrider�r��col1�col2s     r�usage_formatterrdsb����J�D�$�����d�{�Q����4�!�8�}�q� ���d�{�Q����D�Q�7�&*�q�9�<�=�=rc�0�|dk(�r�t�}|D�]m}|\}}}	}
|jdd�}|jdd�}|	dk(r>tjtj	|��tjd��r|	dvr.tj|�|
s��tjd���|	dvr)tjtj	|����|	dvr(tj|j||f|
����|	dk(rP|j
d	�r(tjd
|j�z���;tj|���R|	dk(s��Ytjd���ptjd�yP|dk(�rwd
\}}d
\}
}d
\}}|D]�}|\}}}	}
|	dk(r+tt|�|�}tt|�|�}�:|	dk(r+tt|�|
�}
tt|�|�}�j|	dk(s�ptt|�|�}tt|�|�}��|dz
}|dz
}|
dz
}
|dz
}|dz
}|dz
}||z}|
|z}||z}tjd|�d|�d��|�d|�d|�d�}tj|�tjdt|�z�tjd�g}d}|D�]�}|\}}}	}
|	dk(r|j|�d|z}t|�t|�}}|	dk(r=tjdjd|dg��tjd��~|	dvr@tjd�tj|�tjd���|	dvrItjd�tjd|zdz�tjd�d}��|	dk(�r=|r[tjd�tjd�tjdjdd |zdd |zdg��d}|r@d!|vr<tjdjd"|d#d	||z
d$z
zd%|d	||z
zd%g��nm|r8tjdjd%|d	||z
zd%|d	||z
zd%g��n3tjdjd%d	|zd%|d	||z
zd%g��tjdjdd |zdd |zdg����R|	dk(�r=|r[tjd�tjd�tjdjdd |
zdd |zdg��d}|r@d!|vr<tjdjd"|d#d	|
|z
d$z
zd%|d	||z
zd%g��nm|r8tjdjd%|d	|
|z
zd%|d	||z
zd%g��n3tjdjd%d	|
zd%|d	||z
zd%g��tjdjdd |
zdd |zdg�����|	dk(r!|s���d!|vs���tj|����|	dk(r�|r[tjd�tjd�tjdjdd |zdd |zdg��d}|j
d	�r-tjdjd%d	|d&zzd%g��tjdjd%|d	||z
d&zzd%g��tjdjdd |zdd |zdg�����|	dk(s���tjd����|D].}tjd'|�d(|jd)d��d*���0tjd�yP|d+k(�r�tjd,|�d-|�d.��tjd/|�d0|���|D�]W}|\}}}	}
|jd1d#�}|jd1d#�}t|�t|�}}|	dk(r>tjd2�tjd3|jd4d�z���|	d5k(r|s��tjd6|z���|	d7vr4|rtjd8|�d9|�����tj|���|	d:vrXtjd;|j�jd<d�jd=d�jd>d�z���=|	d?vs��Ctj|���Ztjd@�tjdA�tjdB�tjdC�tjdD�tjdE�tjdF�tjdG�tjdH�tjdI�tjdJ�tjdK�tjdL�tjdM�tjdN�tjdO�tjd�yPyP)Qz�
    Format usage text in multiple formats:
        text: for --help in the console
        rest: for conversion with rst2web for the website
        man: for manpages
    r��\r+�summary)�pararD�seealso)r�r�)r��exampler�r,�	r��rest)rrr�r�zrestindex
page-title: z
crumb: z=
format: rest
file-extension: html
encoding: utf8
/restindex
z: z (ver. rr�Frz`%s`_z**)rrDTz.. class:: borderlessr�r.z`_z| *rr%r�rz
.. _`z`: zhp-z.html
�manz.TH "z" 1 "z" Linux "User Manuals"z
.SH NAME\nz \- z\*z.SH SYNOPSISz.B %szUsage:rDz.SH DESCRIPTION
%s)r�rr�z.IP "z"
)r�r�z.SH %sr.�[r�z
seealso, paraz
.SH AUTHORz+HPLIP (HP Linux Imaging and Printing) is anz=HP developed solution for printing, scanning, and faxing withz,HP inkjet and laser based printers in Linux.z.SH REPORTING BUGSzThe HPLIP Launchpad.net sitez.B https://launchpad.net/hplipz is available to get help, reportz>bugs, make suggestions, discuss the HPLIP project or otherwisezcontact the HPLIP Team.z
.SH COPYRIGHTz2Copyright (c) 2001-18 HP Development Company, L.P.z.LP�0This software comes with ABSOLUTELY NO WARRANTY.�;This is free software, and you are welcome to distribute it�<under certain conditions. See COPYING file for more details.N)
rr9rB�info�boldr�r��lstripr�rgr�rY�upper)�	text_list�typ�title�crumb�version�	formatterr��text1�text2r�trailing_space�
opt_colwidth1�
opt_colwidth2�exmpl_colwidth1�exmpl_colwidth2�note_colwidth1�note_colwidth2�opt_tablewidth�exmpl_tablewidth�note_tablewidthry�links�needs_header�len1�len2rs                          r�format_textr+rs�	���f�}�#�%�	��	�D�37�0�E�5�&�.��M�M�$��+�E��M�M�$��+�E���"�������%��)�������6�6������!��H�H�R�L��0�0�������%��)��0�0�����*�*�E�5�>�>�J�K��6�!��#�#�C�(��H�H�T�E�L�L�N�2�3��H�H�U�O��7�"������=	�@	�����

���'+�$�
�}�+/�(���)-�&����
	A�D�37�0�E�5�&�.��(�"� #�C��J�
� >�
� #�C��J�
� >�
��9�$�"%�c�%�j�/�"B��"%�c�%�j�/�"B���6�!�!$�S��Z��!@��!$�S��Z��!@��
	A�	���
����
��1����1����!����!���&��6��*�_�<��(�>�9��	����%�
!�	"�#(���8�����������S��V�������������L	�D�37�0�E�5�&�.���"����U�#��%����U��S��Z�$�D���"�������$��t�!4�5�6�������+�+�����������������0�0�������������,�-������#���8�#���H�H�4�5��H�H�R�L��H�H�R�W�W�c�3�}�+<�c�3�}�CT�VY�%Z�[�\�#(�L��T��.��H�H�R�W�W�e�U�C��m�D�>P�QR�>R�9S�UX�Z_�ad�fs�tx�fx�ay�{~�%�A�B���H�H�R�W�W�c�5�#�}�T�7I�2J�C�QV�X[�]j�ko�]o�Xp�ru�%v�w�x��H�H�R�W�W�c�3�
�+>��U�C�Q^�_c�Qc�Ld�fi�%j�k�l�������#�s�=�'8�#�s�=�?P�RU�!V�W�X��9�$���H�H�4�5��H�H�R�L��H�H�R�W�W�c�3��+>��S��EX�Z]�%^�_�`�#(�L��T��.��H�H�R�W�W�e�U�C��o�d�>R�ST�>T�9U�WZ�\a�cf�hw�x|�h|�c}�@C�&D�E�F���H�H�R�W�W�c�5�#��t�7K�2L�c�SX�Z]�_n�os�_s�Zt�vy�%z�{�|��H�H�R�W�W�c�3��+@�#�u�c�Sb�cg�Sg�Nh�jm�%n�o�p�������#�s�?�':�C��_�AT�VY�!Z�[�\��9�$��T��.��H�H�U�O��6�!���H�H�4�5��H�H�R�L��H�H�R�W�W�c�3�~�+=�s�C��DV�X[�%\�]�^�#(�L��#�#�C�(��H�H�R�W�W�c�3���0A�+B�C�%H�I�J�������#�u�c�?�4�3G��3I�.J�C�!P�Q�R�������#�s�>�'9�3��N�@R�TW�!X�Y�Z��7�"������YL	�\�	J�A��H�H��1�9�9�U�B�3G�H�I�	J�	�����	������5�'�J�K����%��7�8��	 �D�37�0�E�5�&�.��M�M�%��-�E��M�M�%��-�E��U��S��Z�$�D���"�����(�����5�=�=��2�#>�>�?��6�!���H�H�2�U�:�;��8�8���H�H�u�e�<�=��H�H�U�O��0�0�����E�K�K�M�$9�$9�#�r�$B�$J�$J�3�PR�$S�$[�$[�\_�ac�$d�d�e��O�,������5	 �8	��������>�?����P�Q����?�@����%�&����/�0����1�2����3�4����Q�R����*�+�����!����E�F���������C�D����N�O����O�P������g
rc�L�tjd�|r:tjtjdtjz��n(tjtjd��tjtj|�d|����tjd�tjd�tjd�tjd�tjd�tjd�y)	Nr+z.HP Linux Imaging and Printing System (ver. %s)z$HP Linux Imaging and Printing Systemz ver. z0Copyright (c) 2001-18 HP Development Company, LPrrr)rBrrrSr)�program_namer�show_vers   r�	log_titler/Vs����H�H�R�L��������J�T�\�\�Y�Z�[�������@�A�B��H�H�S�X�X�l�G�<�
=�>��H�H�R�L��H�H�
?�@��H�H�
?�@��H�H�
J�K��H�H�
K�L��H�H�R�Lrc�`�dtj|�z}tj|||�S)Nz(?i))r6r�r�)�old�searchr9�regexs    r�ireplacer4gs(���R�Y�Y�v�&�&�E�
�6�6�%��#�&�&rc�6�d�}tjd||�S)Nc�(�|jd�}|dddk(r8	|dddk(rtt|ddd��Stt|dd��S	ttj
|dd�}|S#t$rY|SwxYw#t$rY|SwxYw)	Nrr$z&#r%z&#xrr�r)r��chrr�r�r�name2codepointr�)rr�s  r�fixupzunescape.<locals>.fixupps����w�w�q�z�����8�t��
����8�u�$��s�4��"�:�r�2�3�3��s�4��"�:��/�/�

��=�7�7��Q�r�
�C�D������
����
���
����
�s(�A4�A4�B�4	B�B�	B�Bz&#?\w+;)r6r�)r�r9s  r�unescaper:os���*�6�6�*�e�T�*�*rc��t|t�st|�}|jdd�}tj
D]7}|dk7s�	|jt
|�dtj
|z�}�9ttd��ttdd��zD] }|jt
|�d|z�}�"|S)	N�&z&amp;�&z&%s;� r��z&#%d;)	r~rsrr9r�codepoint2namer7r�r�)rrXs  rr�r��s����a����q�M��	�	�	�#�w��A�
�
)�
)�L����9��	�	�#�a�&�&�=�+G�+G��+J�"J�K�A�L��%��+�
��e�D�$�&7�!8�
8�+��
�I�I�c�!�f�g��k�*��+�
�Hrc�v�gd�}d}|D]-}t|�s�|dz}tjd|z�|S|S)N)zgnome-terminal�konsolezx-terminal-emulator�xterm�gtktermz -e zAvailable Terminal = %s )r6rBrC)�
terminal_list�terminal_cmdrs   r�get_terminalrG�sN��Y�M��L������:���;�L��I�I�0�,�>�?����
��rc���|dk(s|dk(s
|dk(s|dk(rtjd�y|jd�}|jd�}tjd|�d|���d}d}tjd�}	|t|�k�r�|t|�k�r�d}d	}d}	d	}
|j
||�rPt|j
||�jd
��}|j
||�jd�}nt||�}|j
||�rPt|j
||�jd
��}	|j
||�jd�}
nt||�}	||	krd}n�||	kDrtjd
�y|j�|
j�krd}nZ|j�|
j�kDrtjd
�y|d
z
}|t|�kr|t|�kr���|durt|�t|�krd}|S#tjdtz�YyxYw)Nr+zavailable_version is ''FrQzHPLIP Installed_version=z  Available_version=rz(\d{1,})([a-z]{1,})r,rr$Tz Already new verison is installedz_Failed to get the latest version. Check out %s for manually installing latest version of HPLIP.)rBrCr:r6r�rgr2r�r�rrZ�HPLIP_WEB_SITE)�installed_version�available_version�installed_array�available_array�cnt�Is_olderr��installed_ver_dig�installed_ver_alph�available_ver_dig�available_ver_alphs           r�Is_HPLIP_older_versionrT�sl���B��"3�t�";�?P�TV�?V�Zk�os�Zs��	�	�+�,��%�+�+�C�0�O�%�+�+�C�0�O��I�I�BS�Te�f�g�
�C��H�
�
�
�-�.�C�*��3��'�'�C��_�1E�,E���"����"���z�z�/�#�.�/�$'��
�
�?�3�3G�(H�(N�(N�q�(Q�$R�!�%(�Z�Z���0D�%E�%K�%K�A�%N�"�$'���(<�$=�!��z�z�/�#�.�/�$'��
�
�?�3�3G�(H�(N�(N�q�(Q�$R�!�%(�Z�Z���0D�%E�%K�%K�A�%N�"�$'���(<�$=�!�!�$5�5����#�&7�7��	�	�<�=��'�,�,�.�1C�1I�1I�1K�K�#�H��(�.�.�0�3E�3K�3K�3M�M��I�I�@�A� ��1�H�C�C�3��'�'�C��_�1E�,E�H�u���_�!5��O�8L�!L��H��O��	��	�	�s�uC�C�	D��s �D,I�/AI�
!I�-I�I,c�"�t||zdz|z�}|dk7rtjjd�tjjdtjd|zd�z�tjj
�y)N�drzrz%2d%%r)r�r��stdoutr�rB�color�flush)r��	blockSize�	totalSize�percents    r�downLoad_statusr]�si���%�	�/�#�%�i�/�0�G���z��
�
����"��J�J���T�C�I�I�g�g�o�v�>�?�@��J�J���ri c��|j�rV|j�jd�r7t|j�jd�j��}ntjd�d}d}	|j
|�}|sy|j|�|t|�z
}|r
||d��@)NzContent-LengthzIgnoring progres barrr)	rr�r�r+rBrCr8r�rg)�response�out_fd�
chunk_size�
status_bar�
total_size�bytes_so_far�chunks       r�chunk_writerf�s����m�m�o�(�-�-�/�-�-�.>�?���
�
��+�+�,<�=�C�C�E�F�z�
�y�y�'�(��z��<�	
��m�m�J�'�e�
�	��l�l�5���c�%�j� �l�	�	�L�!�Z�	0�
rc�*�d}|dk(s|�tjd�|dfS|�
t�\}}	|durctd�}|rTtj
j
|d�}t|�d|�d|���\}}|rtjd|z�|dfSd	}|r>	tj|�}t|d
�}	t||	�|	j�tj
j#|�s tjd
t$z�|dfSd|fS#tj$r&}
tjd|z�|dfcYd}
~
Sd}
~
wwxYw#t$r0}
tjd|
j z�|dfcYd}
~
Sd}
~
wwxYw)Nrr+zURL is emptyF�wgetz6 --cache=off --tries=3 --timeout=60 --output-document=r,z0Failed to connect to HPLIP site. Error code = %dT�wbzFailed to open URL: %sz
I/O Error: %sz/Failed to get hplip version/ %s file not found.r)rBrZr+r6r1rVrYror�urlopenr-rfr=r
�URLErrorr.�strerrorrW�hplip_version_file)�weburl�
outputFile�	useURLLIB�retValuer?rh�statusr�r_�file_fdr~s           r�download_from_networkrt
s~���H�
��|�v�~��	�	�.�!���|����'�)���J�������=�D���w�w�|�|�D�&�1��!$�gk�mw�y�&A�"B������I�I�P�RX�X�Y�#�R�<�'� �	��
$�*�2�2�6�:���z�4�0���H�g�.��
�
���7�7�>�>�*�%��	�	�C�DV�V�W���|���j�=���!�)�)�
$��	�	�2�V�;�<���|�#��
$�����	�	�/�A�J�J�.�/���|����sN�A$E�E�=D�E�0E�E�E�E�E�	F�"%F
�F�
Fc�$�eZdZd�Zd�Zd�Zd�Zy)�	Sync_Lockc�H�||_t|jd�|_y)NrR)�
Lock_filenamer-�handler)r��filenames  rr�zSync_Lock.__init__;s��%����D�.�.��4��rc�`�tj|jtj�yr)rErFryrHr�s r�acquirezSync_Lock.acquire@���
���D�L�L�%�-�-�0rc�`�tj|jtj�yr)rErFryrNr�s r�releasezSync_Lock.releaseCr}rc�8�|jj�yr)ryr=r�s r�__del__zSync_Lock.__del__Fs�������rN)r�r�r�r�r|rr�r�rrrvrv:s��5�
1�1�rrvc�0�tstjd�ytjd�|||||||g}tjdt
d��}|j|ddi�t�j|�tjd�y)	NzFailed to import dbus, lowlevelzsend_message() entered�/�Event)rV�	interfacerD�	signature�ssisisszsend_message() returning)	�
dbus_availrBrCr�
SignalMessage�DBUS_SERVICEr�r�send_message)	�
event_code�
device_uri�printer_name�username�job_idr�	pipe_namer��msgs	         r�	sendEventr�Isz����	�	�3�4���I�I�&�'���j�(�F�E�9�U�D�
�
 �
 �c�\��
P�C��C�J�J�T�*��*�
�K���S�!��I�I�(�)rc�b�tj|�}|rdj|�}||fSgdfS)Nr,r+)�globrY)�File_exp�	File_list�
File_list_strs   r�expand_listr�Vs5���y�y��"�9���h�h�y�)�m�
�
�
%�%�
��U�lrc�F�d}d}	|jd�dk7r'|jdd�d}|jd�sn|S�>t|�dkr|S||dk(r|}|S	|t|�kr�d}||dk(s||d	k(s||d
k(r |dz}||dk(r�||d	k(r�||d
k(r� ||d
k7r3||d	k7r+|dzt	||d�z}|dz}||d
k7r	||d	k7r�+|dk(r	|S|||||zdzz}||zdz}|t|�kr��|S#t
$rY|SwxYw)
Nrr+r�

r�HTTP�<r,�
r�r�r$)r�r:r�rgr�r;)�src_datar��dst_data�buf_lens    r�unchunck_xml_datar�`s���
�E�
�H�
��=�=��$��*��~�~�j�!�4�Q�7�H��&�&�v�.���O�
��8�}��������#����&�O�#	���X��&��W��E�?�c�)�X�e�_��-D��QV��[_�H_��a�x�u��E�?�c�)�X�e�_��-D��QV��[_�H_��E�?�d�*�x���$�/F� �"��s�8�E�?�B�'?�?�w��a�x�u��E�?�d�*�x���$�/F��1����O�!�(�5����q��"A�A�X��u�_�q�(�U���X��&� �O���	���O�	�s0�!5D�D� D�):D�$D�,$D�	D �D c�$�d}g}tjd�}|rc|j|�rR|j|�jd�}tjddt|��}|j
d�}n|jd�tjd|z�|jd	�}|j
d
�}|D]}d}|D]}	||	k(r||=�|dz
}��t|�dk(rd}d}
|D]}|
r|
dz
}
|
|z
}
�||
fS)
NFz.*-G(.*)rz\sr+r��lpzRequied groups list =[%s]�
r,rT)r6r�r2r�r�rsr:r�rBrCr�rg)�required_grps_str�avl_grps�result�exp_grp_list�exp_pat�grps�grp_list�g�	grp_indexr4�missing_groups_strr%s            r�check_user_groupsr��s0��
�F��L�
�Z�Z��
'�G��W�^�^�,=�>��~�~�/�0�6�6�q�9���f�f�U�B��D�	�*���z�z�#������D�!��I�I�)�,�6�7����v�&�H��n�n�S�!�H�����	��	�A��A�v� ��+����M�I�		���<��A������
� ����#�%���a��� ��%�%�%rc�P�d}tjj|�stj	d|z�n�tjj|�r tjj
|�}n|}tjj|�stj	d|z�nXtj|�jdzdk7rtj	d|z�ntj	d|z�d}tj	d||fz�|S)	NFz9Either %s file is not present or symbolic link is missingz%s library file is missing.�Hz;%s library file doesn't have user/group execute permission.z%s library file present.Tz%s library status: %d)	r1rVrWrBrC�islink�realpathr2�st_mode)�so_file_path�ret_val�	real_files   r�
check_libraryr��s����G�
�7�7�>�>�,�'��	�	�M�P\�]�^��7�7�>�>�,�'����(�(��6�I�$�I��w�w�~�~�i�(��I�I�3�y�A�B��g�g�l�#�+�+�b�0�R�
7��I�I�S�Wc�d�e��I�I�0�L�A�B��G��I�I�%��w�(?�?�@��Nrc�(�d}td�}|rm|rktjj|d�}|�d|��}|r|dz
}tj|�t
|�\}}tjd|z�|Stjd�|S)Nrrhz8 --cache=off --tries=3 --timeout=60 --output-document=- z --spider -Szwget returned: %dzwget not found�r6r1rVrYrBrCro)�target�headrrrhrr�s      r�download_via_wgetr��s���
�F���=�D�
�$��w�w�|�|�D�&�)��PT�V\�]����>�!�C��	�	�#���S������	�	�%��.�/��M�	�	�	�"�#��Mrc�(�d}td�}|rm|rktjj|d�}|�d|��}|r|dz
}tj|�t
|�\}}tjd|z�|Stjd�|S)Nr�curlz. --output - --connect-timeout 5 --max-time 10 z --headzcurl returned: %dzcurl not foundr�)r�r�rrr�rr�s      r�download_via_curlr��s���
�F���=�D�
�$��w�w�|�|�D�&�)��FJ�F�S����9��C��	�	�#���S������	�	�%��.�/��M�	�	�	�"�#��Mrc��d}td�}|rf|rdtjj|d�}|�d|��}tj|�t
|�\}}tjd|z�|Stjd�|S)Nr�pingz -c1 -W1 -w10 zping returned: %dzping not foundr�)r�rrr�rr�s     r�check_network_via_pingr��sx��
�F���=�D�
�$��w�w�|�|�D�&�)��&*�F�3���	�	�#���S������	�	�%��.�/��M�	�	�	�"�#��Mrc�j�t|d��}|dk7rt|d��}|dk7rt|�}|dk(S)NT)r�r)r�r�r�)r�ping_serverrrs   r�check_network_connectionr��s<��
�s��
.�F��!��"�3�T�2���a�K�+�K�8�F��a�K�rc��g}|D]O}|r|dz|z}d|vr.tj|�}|D]}|j|���?|j|��Q|S)Nr�r)r�r�)�
Files_List�
prefix_dir�Expanded_Files_listrK�f_full�files      r�
expandListr��sr����
�*����C��!�#�A��!�8��Y�Y�q�\�F��
/��!�(�(��.�
/�
 �&�&�q�)�*��rc�v�	tt|�t|��S#t$rt||�cYSwxYwr)r�floatr��r�rzs  r�comparer�		s7����5��8�U�1�X�&�&�����1�a�y���s� �8�8c	��|�btjd|z�|D]E}t|�\}}|dus�|D]+}tjd||�d|�d��|||fccS�Gtjd�y)Nz*Searching for '%s' in running processes...TzFound: z (rz	Not found)rr+)rBrC�Is_Process_Running)�package_mgrsr4rr�process�pids     r�
check_pkg_mgrr�	s������	�	�>��M�N��	3�A�!3�A�!6���w��T�>�&�3���	�	�g�c�l�C�"H�I� #�W�S�\�2�2�3�	3��I�I�k��rc�b�|sdifS	i}tgd�t��}td|g|jt��}tgd�|jt��}|j�d}tjd|z�|r[|j
�D]D}d	|z}tj|�\}}	d
|z}tj|�\}}
|	s�@|
||	<�Fd|fSdifS#t$r@}tjd|z�ttjz	d
|fdifcYd}~Sd}~wwxYw)NF)�ps�-wr��aux)rW�grep)�stdinrW)r�z-vr�rzIs_Process_Running output = %s zecho '%s' | awk {'print $2'}z!echo '%s' | awk {'print $11,$12'}Tz"Execution failed: process Name[%s]zExecution failed:)rrrW�communicaterBrCr�r�getstatusoutputr�rZ�printr��stderr)�process_namer��p1�p2�p3r�r4rrrr��cmdliner~s            rr�r�#	s,����b�y�����
�,�T�
:��
�F�L�)����4�
H��
�)����4�
H�����!�!�$���	�	�3�V�;�<���&�&�(�
+��4�a�7��'�7�7��<�
��s�9�1�<��!+�!;�!;�C�!@���w��#*�G�C�L�

+���=� ��"�9������	�	�6��D�E�
��
�
��/��2��b�y����s*�C
C%�
C%�!C%�%	D.�.5D)�#D.�)D.c���tdz|z}|r|r|j�|z}tjd|�d|�d��t	||�\}}d|k7rtjd|z�yy)Nr,z	Removing z cmd = rzFailed to remove=%s )�RMDIR�
getAuthCmdrBrCro)rVr��cksudorrrr�s      rr<r<B	sg��	���t�	�C�
�+�
�
#�
#�
%�s�
*���I�I��c�2�3���k�*�N�F�F��F�{��	�	�(��-�.�rc�*��G�fd�dt�}|S)z,Convert a cmp= function into a key= functionc�P��eZdZd�Z�fd�Z�fd�Z�fd�Z�fd�Z�fd�Z�fd�Z	y)	�cmp_to_key.<locals>.Kc��||_yr��obj)r�r�r�s   rr�zcmp_to_key.<locals>.K.__init__P	s	���D�Hrc�D���|j|j�dkSr�r��r��other�mycmps  �r�__lt__zcmp_to_key.<locals>.K.__lt__R	��������5�9�9�-��1�1rc�D���|j|j�dkDSr�r�r�s  �r�__gt__zcmp_to_key.<locals>.K.__gt__T	r�rc�D���|j|j�dk(Sr�r�r�s  �r�__eq__zcmp_to_key.<locals>.K.__eq__V	��������5�9�9�-��2�2rc�D���|j|j�dkSr�r�r�s  �r�__le__zcmp_to_key.<locals>.K.__le__X	r�rc�D���|j|j�dk\Sr�r�r�s  �r�__ge__zcmp_to_key.<locals>.K.__ge__Z	r�rc�D���|j|j�dk7Sr�r�r�s  �r�__ne__zcmp_to_key.<locals>.K.__ne__\	r�rN)
r�r�r�r�r�r�r�r�rr)r�s�r�Kr�O	s&���	�	2�	2�	3�	3�	3�	3rr)�object)r�rs` r�
cmp_to_keyrM	s���3�F�3�
�Hrc�b�|d|dkD|d|dkz
xs|d|dkD|d|dkz
S)Nrr%r�r�s  r�	levelsCmpra	sG��
�a�D�1�Q�4�K�A�a�D�1�Q�4�K�(�I�Q�q�T�A�a�D�[�Q�q�T�A�a�D�[�,I�Irc��tdtt�dztt�zz�r%dtt�dztt�zzStdtt�z�rdtt�zStdtt�z�rdtt�zStdtt�dztt�zz�r%dtt�dztt�zzStdtt�z�rdtt�zStd�rytjdtz�y)zfDetermine the pip command syntax available for a particular distro.
    since it varies across distroszpip-%srQzpip%szpip-python%sz
pip-pythonzEpython pip command not found. Please install '%s' package(s) manuallyN)r6rs�MAJ_VER�MIN_VERrBrZ�depends_to_install_using_pipr�rr�find_pipre	s���
�X�s�7�|�C�'��G��4�
5�6���W��c�)�#�g�,�6�7�7�	�x��G��$�	%���G��$�$�	�w�s�7�|�#�	$��s�7�|�#�#�	�w��G��S�(��W��5�6�	7���G��S�(��W��5�6�6�	�~�c�'�l�*�	+��c�'�l�*�*�	�|�	���	�	�Y�Zv�v�wrc���	tjtjtj�}|jd�|j	�y#tj
$rYywxYw)N)z1.2.3.4�8TF)�socket�AF_INET�
SOCK_DGRAM�connectr=rZr�s r�	check_lanry	sO����M�M�&�.�.�&�*;�*;�<��	�	�	�/�"�	���	����<�<����s�AA�A,�+A,c��|jd�r|jd�}||dzd}|dddk7rVd}d}|rN|jd�}t|d|dzd	�}|||d
z|d
z|zz}||d
z|zd
zt|�}|r�N|}|S)Nr�rrrr�rr+r�r�r$)r�r�rg)r�r��sizer
s    r�extract_xml_chunkr�	s����y�y����	�	�*�%���E�!�G�H�~���A�a�y�C��������I�I�f�%�E��t�A�e�A�g���+�D��$�u�Q�w�u�Q�w�t�|�4�4�D���a����Q��s�4�y�1�D�	�
���Krc���	ddl}y#t$r}tj|�Yd}~nd}~wwxYw	ddl}y#t$r)}tj|�Yd}~td��d}~wwxYw)Nrr�r�z-GUI Modules PyQt4 and PyQt5 are not installed)r�rqrBrCr�)r�r~r�s   rr}r}�	s^���������	�	�!�������������	�	�!���
�E�
F�F���s%��	/�*�/�8�	A*�A%�%A*c��d}	t�}tjd|z�|S#t$r}tj	|�Yd}~yd}~wwxYw)Nr+zUsing GUI Module %s)r}rBr�rqrZ)�
_ui_statusr~s  r�	ui_statusr�	sI���J��&�(�
����&��3�4�������	�	�!�����s�#(�	A�A�Ac��|dk(r 	ddlm}tjd�|dfS|dk(r 	ddlm}tjd�|d	fSy#t$r4}tj|�t
jd�Yd}~yd}~wwxYw#t$r4}tj|�t
jd�Yd}~yd}~wwxYw)
Nr�r)�QApplicationzUsing PyQt4r�rr�zUsing PyQt5r�)	�PyQt4.QtGuirrBrCrqrZr��exit�PyQt5.QtWidgets)�
ui_toolkitrr~s   r�
import_dialogr!�	s����U��	�0��I�I�m�$�!�5�)�)�
�u�	�		�4��I�I�m�$� �%�(�(�	
���	��I�I�a�L��H�H�Q�K�K��	���	��I�I�a�L��H�H�Q�K�K��	�s.�A�B�	B	�*B�B	�	C	�*C�C	c�j�|jd�}t|�}|ddD]}t||�}�|S)NrQr)r:�
__import__�getattr)�mod_name_as_str�
components�mod�comps    r�dyn_import_modr)�	sB�� �&�&�s�+�J�
�_�
%�C��1�2��!���c�4� ��!��Jrc���	tj|�S#t$rJddl}tj
j
|jd��tj|�cYSwxYw)Nr�platlib)�	importlib�
import_modulerq�	sysconfigr�rVr��get_path)�ext_namer.s  r�
import_extr1�	sV��1��&�&�x�0�0���1�������	�*�*�9�5�6��&�&�x�0�0�1�s��AA*�)A*c�*�tjd�d\}}d}t�}	ddl}	|j�dj�}|j�d}|sd}tjd�nd}tjd	�|r
|dk(s|dk(rotd
d�}|ratjd�t|dz|�\}}|s8|r6t|dz|�\}}|s"|r |j�j�}d}|s�	tdd�j�j�j�}d}|j!�D]7}	|	}
d|	vr#dj#|	j!d�dd�}
	t%|
�}�9	d|vrd}|s}	tdd�}|D]j}|j�j-d�r|j!d�d}|j�j-d�r|j!d�d}d}�l	|r�|j�j�}tjd|z�|j/d�dkDs|j/d�dkDrd}tjd|z�|dk(r|dd k(r|ddk(rd!}n|dk(r|dd"k(r
|ddk(rd#}d$|vrd%}|d&d'}d(|j�vr:|j!d�}
|
ddz|
dz}ntj1d)�d*\}}tjd+t|��d,t|����||fS#t$rMddl}|j�dj�}|j�d}|jd�}Y��=wxYw#t$rd}tjd
�Y��3wxYw#t&$r"	t)|
�}n#t&$rd}YnwxYwY���wxYw#t*$rd}Y��rwxYw#d}Y���xYw)-NzDetermining distro...)r+�0.0FrrrDzNot able to detect distroTzAble to detect distroz&Not able to detect distro using python�redhat�arch�lsb_releasez/Using 'lsb_release -is/-rs' to determine distroz -isz -rsz
/etc/issuer�rQr$r3�welcomez/etc/os-releasezname=rrzversion=zDistro name=%s�redhatenterpriser�rhelzDistro version=%s�5z5.0�6z6.0�MX�mxlinuxr%��manjaroz%Failed to get the distro information.)rr3zdistro=z, distro_version=)rBrCrsr��distrr��distro�linux_distribution�distro_release_attrrqr6ror+r-r8r:rYr�r�r�r.r�r�ry)r�rD�ver�found�distro_release_namer�rA�lsb_relrrr}r�
os_releaser�rs              r�get_distro_namerI�	s���I�I�%�&��I�D�#��E��%��<��	E� �8�=�=�?�1�%�+�+�-�D��(�-�-�/�!�$�C���E��I�I�1�2��E��I�I�-�.��D�H�$�����
�t�,����I�I�G�H��w��/��=�L�F�D��d�!�'�F�"2�K�@�����#��)�)�+�+�+�-�C� �E��	$���c�*�/�/�1�7�7�9�?�?�A�D�
�E��Z�Z�\�
$�����!�8���������b�q�!1�2�A�$���(�C�

$��D�����		��/��5�J�"�
���:�:�<�*�*�7�3��:�:�c�?�1�-�D��:�:�<�*�*�:�6��*�*�S�/�!�,�C���
�
��z�z�|�!�!�#���	�	�"�T�)�*��9�9�'�(�2�-����8�1D�r�1I��D��	�	�%��+�,��6�>�c�!�f��m��A��#�
��C�
�V�^��A��#�
�#�a�&�C�-��C��&�&��D�%�a��*�C���
�
��$��i�i��n�G��!�*�c�/�'�!�*�,�C�	���8�9��	��c��I�I�s�4�y��S��B�C���:���q�	E���,�,�.�q�1�7�7�9�D��+�+�-�a�0�C�"(�"<�"<�V�"D��		E���<����	�	�:�;�<��D"�$�$�!�!�f���%�$�#��$��$���	��E�	��8	��E�s��N$�6M�#1N$�6O9�O�A;P�AN!�N$� N!�!N$�$ O�O�	O6�O!� O6�!O/�,O6�.O/�/O6�5O6�9P�P�Pc�@�	ddl}ddlm}d}|jd�}	|d�j}||vrd}|Sd}	|S#t
$r7	|d�j}n #tjd�|cYcYSxYwY�LwxYw#tjd�YSxYw)	Nr)�getgrnamr��USER�wheelr�z can not get user group zunable to determine auth_type )r1r/rKr/�gr_memr�rBry)r1rK�authType�user�memberss     r�readAuthTyperR6
s���3�� ����r�y�y�� ��	 ��w�'�.�.�G��7�?��H�
�O��H��O���	 �
 �"�6�*�1�1���
 ����3�5�����	 ��3����1�2��O�sV�B�A�B�B�	B�
A�B�A:�6B�8B�:B�=B�?B�B�Br�)r|)TFFrN)r+r+r+F)Tr)r,)Nr+TTr)Nr%rZ)r�r+r+r+)NF)r+rr+r+)�r�r1rrrr/r�r"rr}�select�timerE�errnor2rir�r6�datetimer�r�sixext.movesrrr	r
�sixextrrr
rrrr+rr,�xml.parsers.expat�parsersr5r4rqr�r��dbusrrrr�rrr!�codesr#r�r�r��RMr�rI�HTTP_CHECK_TARGET�PING_CHECK_TARGET�
ERROR_NONE�ERROR_FILE_CHECKSUM�ERROR_UNABLE_TO_RECV_KEYS�ERROR_DIGITAL_SIGN_BAD�version_infor	r
�EOF�TIMEOUT�EXPECT_WORD_LISTr�rr�r�r4r�r�r@rLrOr`rprur�r�r�r�r�r�r�r�r�r�rrr �mkstempr+r�r6rr8rsr{rrzr�r�r�rOr�r�rhrjr�rcr��encoder�r�r�r�rr�rrrrrr>r\rk�
hexversionrortrrrxrsrr�r+rr�r�ror�r�r�r�r�r�r�r��
USAGE_OPTIONS�USAGE_LOGGING1�USAGE_LOGGING2�USAGE_LOGGING3�USAGE_LOGGING_PLAIN�
USAGE_ARGS�USAGE_ARGS2�USAGE_DEVICE�
USAGE_PRINTER�
USAGE_BUS1�
USAGE_BUS2�
USAGE_HELP�USAGE_SPACE�USAGE_EXAMPLES�USAGE_NOTES�USAGE_STD_NOTES1�USAGE_STD_NOTES2�
USAGE_SEEALSO�USAGE_LANGUAGE�USAGE_LANGUAGE2�
USAGE_MODE�USAGE_NON_INTERACTIVE_MODE�USAGE_GUI_MODE�USAGE_INTERACTIVE_MODE�sys_confr��
USAGE_USE_QT3�
USAGE_USE_QT4�
USAGE_USE_QT5r�rr+r/r4r:r�rGrTr]rfrtrvr�r�r�r�r�r�r�r�r�r�r�r�r�r<rrrrrr}rr!r)r1rIrRr�rr�<module>r�so��6�	�"�
���
�
�
�����
��	���
�V�V�a�a�a����%�%��O����N���4�4��J�
&��+�����
��
���
��
&��A��'�� ��
�
�������

�
�
�1�
��

�
�
�1�
���K�K��O�O��������
���
����$��	��A���B�J�J�q�"�$�$���	���1��
��*���:!��$��r�):�=�QS�CT�[_��*G��
� �F�$(�(�:(4�(4�X��* �E� � ��,;�;�*?�3�V�*0��%�%�N��BD�6�D�Pv�
� �,0�f
�.A<��L	H�����s�C�(�H��$�$�X�v�/?�/?�/F�/F�w�/O�P�K��v����2�&�H��$�$�X�v�/?�/?�@�K�.�
��
��
H��%�"�2�S^�mo�p��
�5�*�(�(�M�M�`;�;�z$�$�P"�
�>�>�J���5��
E��j�j�G��j�j�G�
�Y�Y�F�)���K/�^'�T�6H�&H�$��C&��C&�L�&4�
�^��`��X��H��
;�
�1��g��e�
�
c�
�N�
�
G�
�&��4��.��Y��g��3�
�]��C��
,�
�i��X��]���<�<��\�5�1�U�:�G�M�=�M�=�M�
�\�\�+�|�U�3�u�<�=�M�G�M�=�M�
�\�\�+�|�U�3�u�<�=�M�=�M�G�M�
� =�a�H�"'�+�6

�(	� 9�x�/3��1�2*�`
�
�*��$�`&�B�.
�
��"3�@Q�����&�>/�
�(J�x�(�
� 
G� ��,�1�c�J��CP���O������N������J����&��&�&��r�����1����d�0�0�0��b	�<�,�,�"J�T�J�2Q<�Q<�]<�s~�;Q�Q�Q#�Q1�R�	R!�4R1�Q�Q�Q �Q �#Q.�-Q.�1R�R�R�R�!	R.�-R.�1$S�S

Zerion Mini Shell 1.0