%PDF- %PDF-
Mini Shell

Mini Shell

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

�

=	ḟ��<�ddlZddlZddlZddlZddlZddlmZmZm	Z	ddl
Z
ddl
mZddlmZddl
Z
ddlZddlZddl�ddl�ddlmZddlmZdd	lmZdd
lmZddlmZdd
lmZddlmZmZmZdd
lmZmZmZmZddl�ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ejNdejP�Z)dZ*dZ+	ejXd�Z-	e-j\Z/da7da8	ddl9Z9ddl9m:Z:m;Z;da7ddl=Z=e=j|de?�gd�Z@dZAdZBdZCdZDdZEejNd ej��ZGejNd!ej��ZHejNd"ej��ZIejNd#ej��ZJej��ZLejNd$ej��ZMejNd%ej��ZNejNd&ej��ZOGd'�d(eP�ZQGd)�d*eQ�ZRGd+�d,eQ�ZSdvd-�ZTdwd.�ZUd/�ZVd0�ZWe@d1d2eCd3d4dfd5�ZXd6geCfd7�ZYd6geCfd8�ZZd6geCfd9�Z[dxd:�Z\d;�Z]dyd<�Z^d=�Z_d>�Z`d?�Zad@�ZbdydA�ZcdB�ZdieedC�efdD�egdD�ehdE�eidF�ejdG�ekdH�eldI�emdJ�endK�eodL�epdM�eqdN�erdO�esdP�etdQ�eudR�evdSewdMexdTeydUezdVe{dWe|dXi�Z}e~dCedYe�dZe�d[e�d\e�d]e�d^e�d_e�d`e�dae�dbiZ�e�dce�dde�dee�dfe�dge�dhe�die�dbiZ�e�dje�dje�dkiZ�iZ�Gdl�dmeP�Z�Gdn�doe�j2�Z�Gdp�dqe�j2�Z�Gdr�dse�j2�Z�Gdt�due�j2�Z�y#e0$rdZ/Y��hwxYw#e1$r8ejdd�s"e3jid�e5jmd�Y���wxYw#e1$re3jyd�Y���wxYw)z�N�)�urllib_request�urllib_parse�urllib_error)�BytesIO)�http_client)�*)�utils)�services)�os_utils)�status)�pml)�pcl�ldl�cups)�models�mdns�slp�avahi)�PY3�
to_bytes_utf8�
to_unicode�to_string_latin�to_string_utf8�	xStringIOzHTTP/\d.\d\s(\d+)��i��hpmudext� �HPLIP_BUILDz>HPMUDEXT could not be loaded. Please check HPLIP installation.F)�lowlevel�
SessionBusTzpython-dbus not installed.�ignore)�usb�parr)r$�netrr#)r$r%r#)�print�scan�fax�pcard�copy)�hpz�(.*):/(.*?)/(\S*?)\?(?:serial=(\S*)|device=(\S*)|ip=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}[^&]*)|zc=(\S+)|hostname=(\S+))(?:&port=(\d))?z6/(.*?)/(\S*?)\?(?:serial=(\S*)|device=(\S*))&loc=(\S*)z$direct (.*?) "(.*?)" "(.*?)" "(.*?)"zCTR:\d*\s.*;z]\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\bz/dev/.+z(\d+):(\d+)c�^�eZdZejdddfd�Zd�Zd�Zdd�Zd
d�Z	d�Z
d	�Zd
�Zy)�Eventr�c�8�t|�|_t|�|_t|�|_t|�|_t|�|_t|�|_|rt|�|_	ntj�|_	d|_d|_y)N�80s80sI32sI80sf�ssisisd)
r�
device_uri�printer_name�int�
event_code�username�job_id�title�float�timedate�time�pipe_fmt�dbus_fmt)�selfr2r3r5r6r7r8r:s        �/usr/share/hplip/base/device.py�__init__zEvent.__init__jst��%�Z�0���&�|�4����j�/���"�8�,��
��&�k�����&��
��!�(�O�D�M� �I�I�K�D�M�)��
�!��
�c���tjd|jz�tjd|jz�tjd|jz�tjd|j
z�tjd|jz�tjd|jz�tjd|jz�y)Nz    device_uri=%sz    printer_name=%sz    event_code=%dz    username=%sz
    job_id=%dz    title=%sz    timedate=%s)	�log�debugr2r3r5r6r7r8r:�r>s r?rDzEvent.debug~s����	�	�%����7�8��	�	�'�$�*;�*;�;�<��	�	�%����7�8��	�	�#�d�m�m�3�4��	�	�/�D�K�K�/�0��	�	�.�4�:�:�-�.��	�	�#�d�m�m�3�4rAc�R�tj|j|jj	d�|j
j	d�|j|jj	d�|j|jj	d�|j�S)N�utf-8)�struct�packr<r2�encoder3r5r6r7r8r:rEs r?�
pack_for_pipezEvent.pack_for_pipe�su���{�{�4�=�=�$�/�/�*@�*@��*I�4�K\�K\�Kc�Kc�dk�Kl�������!5�!5�g�!>����T�Z�Z�M^�M^�_f�Mg��
�
��	rAc���|�Ktjd|j||fz�	tj||j��yy#t$rtjd�YywxYw)Nz'Sending event %d to %s (via pipe %d)...TzFailed.F)rCrDr5�os�writerK�OSError)r>�fd�	recipients   r?�
send_via_pipezEvent.send_via_pipe�sj��
�>��I�I�?�4�?�?�T]�_a�Bb�b�c�
�����T�/�/�1�2��	��
�
��	�	�)�$��
�s�$A�A0�/A0c��|�~trwtjd|j|fz�t	j
d|d�}|j|j�d|ji�|j|�yyy)Nz$Sending event %d to %s (via dbus)...�/r-�	signature)
�
dbus_availrCrDr5r �
SignalMessage�append�as_tupler=�send_message)r>�session_bus�	interface�msgs    r?�
send_via_dbuszEvent.send_via_dbus�sm���"�z��I�I�<����QZ�?[�[�\��(�(��i��A�C��C�J�J�����A����A��$�$�S�)�	(2�"rAc�.�t|j��S�N)r-rYrEs r?r*z
Event.copy�s���d�m�m�o�&�&rAc�(�d|j�zS)Nz+<Event('%s', '%s', %d, '%s', %d, '%s', %f)>�rYrEs r?�__str__z
Event.__str__�s��<�t�}�}��N�NrAc��|j|j|j|j|j|j
|jfSr`)r2r3r5r6r7r8r:rEs r?rYzEvent.as_tuple�s<������!2�!2�D�O�O�
�]�]�D�K�K����T�]�]�D�	DrAN)�hpssd)�com.hplip.StatusService)
�__name__�
__module__�__qualname__�propr6r@rDrKrRr^r*rcrY�rAr?r-r-is:���-�-����"�(5���*�'�O�DrAr-c�$�eZdZd�Zd�Zd�Zd�Zy)�FaxEventc�v�tj|g|j����||_d|_d|_y)N�80s80sI32sI80sfs�ssisisfs)r-r@rY�	temp_filer<r=)r>rq�events   r?r@zFaxEvent.__init__�s/��
���t�/�e�n�n�.�/�"���*��
�"��
rAc��tjd�tj|�tjd|jz�y)NzFAX:z    temp_file=%s)rCrDr-rqrEs r?rDzFaxEvent.debug�s0���	�	�&��
���D���	�	�$�t�~�~�5�6rAc�(�d|j�zS)Nz4<FaxEvent('%s', '%s', %d, '%s', %d, '%s', %f, '%s')>rbrEs r?rczFaxEvent.__str__�s��E��
�
��W�WrAc��|j|j|j|j|j|j
|j|jfSr`)r2r3r5r6r7r8r:rqrEs r?rYzFaxEvent.as_tuple�sA������!2�!2�D�O�O�
�]�]�D�K�K����T�]�]�
�^�^��	rAN�rgrhrir@rDrcrYrkrAr?rmrm�s��#�7�X�rArmc�$�eZdZd�Zd�Zd�Zd�Zy)�
DeviceIOEventc�v�tj|g|j����||_d|_d|_y)N�80s80sI32sI80sfI�ssisisfi)r-r@rY�
bytes_writtenr<r=)r>r|rrs   r?r@zDeviceIOEvent.__init__�s0��
���t�/�e�n�n�.�/�*���*��
�"��
rAc��tjd�tj|�tjd|jz�y)NzDEVIO:z    bytes_written=%d)rCrDr-r|rEs r?rDzDeviceIOEvent.debug�s2���	�	�(��
���D���	�	�(�4�+=�+=�=�>rAc�(�d|j�zS)Nz9<DeviceIOEvent('%s', '%s', %d, '%s', %d, '%s', %f, '%d')>rbrEs r?rczDeviceIOEvent.__str__�s��J�T�]�]�_�\�\rAc��|j|j|j|j|j|j
|j|jfSr`)r2r3r5r6r7r8r:r|rEs r?rYzDeviceIOEvent.as_tuple�sC������!2�!2�D�O�O�
�]�]�D�K�K����T�]�]�
�
�
�!�	!rANrvrkrAr?rxrx�s��#�?�]�!rArxc���d}d}tjsdatddfStr�ts�t	j
�dk(r tjd�datddfS	|�tj�}ntj|�}	tjd�|jdd�}d	at||fS#tjj$r]}t	j
�dk7rtjd|z�ntjd|z�datddfcYd}~Sd}~wwxYw#tjj$�r
}	t	jd
tj�n#t $rYnwxYwt#j$d�}|r!tj&j)|d�}ngtj&j)tj*d�}tj&j-|�stj/d
�Yd}~ytjd|z�t	j0tj2|dd�tjd�t5j6d�d}		tjd|z�|jdd�}tjd�d	an}#tjj$r\}tjd�|dz
}|dkDrtj/d�Yd}~Yd}~yt5j6d�Yd}~nd}~wwxYw��Yd}~���d}~wwxYw)NFrz#Not starting dbus: running as root.z*Unable to connect to dbus session bus. %s z=Unable to connect to dbus session bus (running as root?). %s z1Connecting to com.hplip.StatusService (try #1)...rfz/com/hplip/StatusServiceT���z
hp-systrayz
systray.pyzUnable to start hp-systray)FNNz&Running hp-systray: %s --force-startupz--force-startupz"Waiting for hp-systray to start...r�z2Connecting to com.hplip.StatusService (try #%d)...z
Connected.z1Unable to connect to dbus. Is hp-systray running?�)rj�	gui_buildrV�
dbus_disabledrM�getuidrCrD�dbusr!�
exceptions�
DBusException�error�
get_object�waitpid�WNOHANGrOr
�which�path�join�home_dir�exists�warn�spawnlp�P_NOWAITr;�sleep)�	dbus_loop�servicer[�er��ts      r?�	init_dbusr��s����G��K��>�>��
��4�$�&�&��-�
�9�9�;�!���I�I�;�<��J��t�d�*�*�	+�� �"�o�o�/��"�o�o�i�8��-	��I�I�I�J�!�,�,�-F�Hb�c�G��J�X�w��,�,��q���,�,�	+��y�y�{�a���	�	�F�q�H�I��	�	�Y�Z[�[�\��J��t�d�*�*��	+�����,�,�)	�
��
�
�2�r�z�z�*���
��
���;�;�|�,�D���w�w�|�|�D�,�7���w�w�|�|�D�M�M�<�@���w�w�~�~�d�+��H�H�9�:�-��I�I�>��E�F��J�J�r�{�{�D�,�8I�J��I�I�:�;��J�J�q�M��A����I�I�R�UV�V�W�)�4�4�5N�Pj�k�G��I�I�l�+�!%�J������4�4�"��I�I�Q�R���F�A��1�u����!T�U�1�1��J�J�q�M�M��"���$��S)	�s��$,C�)E�D=� AD8�2D=�8D=�M(�$F�M#�	F�
M#�F�BM#�2A+M#�*K �M#� M�=4M�1M#�:M�M#�M�M#�#M(c
��
�d\}}}d}tj|���tjd|z�tj|�\}}|tjk(r+|r)t|�}tjd|z�d}|}�n�tjd��n�tj|���tj|�}|jd�}	|jd�}
tjd	|	�d
|
�d��tj|	|
�\}}|tk(r+|r)t|�}tjd|z�d}|}�n�tjd��n�tj|���tjd|z�tj||�\}}|tjk(r+|r)t|�}tjd|z�d}|}�n:tjd��n#tjd
|z�t|�dkr�tj||�\}}|tjk(r<|r:t|�}|j!dd�}tjd|z�d}|}n�tjd|z�tj||�\}}|tjk(r<|r:t|�}|j!dd�}tjd|z�d}|}ntjd�|�sPtjd|z�t#ddg��}|D�]$}tj|�	t%|�\	}
}}}}}}}}|dk(r�t)|�}tj+||j-dtj.��\}}|tjk(rHtj1|�\}}t3|�j-dd�}tj5|�|j7�|j7�k(rtjd|z�d}|}ntjd���'|ry	t)|�}|j-dt8�t8kDrI|j-dd�r|j!dd�}|j-dd�r|j!dd�}nd\}}}nd!\}}|rt>jAd"d#|�|||fS#t&$rY���wxYw#t&$r2}tj;d |j<z�d\}}}Yd}~�dd}~wwxYw)$N)r.r.r.FzTrying parallel with %sz	Found: %sT�
Not found.rr�zTrying USB with bus=z dev=z...zTrying IP address %szTrying ZC hostname %s�zip=z	hostname=zADevice not found using mDNS hostname. Trying with DNS hostname %szTrying serial number %sr#r$��bus�io-mode�SNr.�support-type�	scan-typer�hp:�hpaio:�fax-type�hpfax:z	Error: %s�r.r.�	last_usedr2)!�dev_pat�searchrCrDr�make_par_uri�
HPMUD_R_OKr�usb_pat�group�make_usb_uri�
ERROR_SUCCESS�ip_pat�make_net_uri�len�make_zc_uri�replace�probeDevices�parseDeviceURI�Error�queryModelByURI�open_device�get�HPMUD_UNI_MODE�
get_device_id�
parseDeviceID�close_device�lower�SUPPORT_TYPE_NONEr�r]�	user_conf�set)�param�port�cups_uri�sane_uri�fax_uri�found�result_code�uri�	match_obj�
usb_bus_id�
usb_dev_id�devices�d�back_end�is_hpr��model�serial�dev_file�host�zc�mq�	device_id�datar��scan_uris                          r?�makeURIr�6s���",��H�h���E��~�~�e��(��	�	�+�e�3�4�#�0�0��7���S��(�-�-�-�#� ��%�C��I�I�k�C�'�(��E��H��I�I�l�#�	����	�	*��N�N�5�)�	��_�_�Q�'�
��_�_�Q�'�
��	�	�
�J�O�P�#�0�0��Z�H���S��-�'�C� ��%�C��I�I�k�C�'�(��E��H��I�I�l�#�	���u�	�	)��	�	�(�5�0�1�#�0�0���=���S��(�-�-�-�#� ��%�C��I�I�k�C�'�(��E��H��I�I�l�#�	�	�	�)�E�1�2�
�%�[�3�
�'�3�3�E�4�@��K���h�1�1�1�c�$�S�)���k�k�%��4���	�	�+��+�,������	�	�]�`e�e�f�#+�#8�#8���#E� ��S��(�"5�"5�5�#�(��-�C��+�+�e�K�8�C��I�I�k�C�/�0� �E�"�H��I�I�l�+���	�	�+�e�3�4��E�5�>�2���	(�A��I�I�a�L�
�"�1�%�N��%��e�V�X�t�R��
�e�|�$�Q�'���(�(��B�F�F�9�h�>U�>U�,V�W�'��Y��(�"5�"5�5�(0�(>�(>�y�(I�%�K��*�4�0�4�4�T�2�>�F��)�)�)�4��|�|�~�����.��	�	�+��/�*�������	�	�,�'�7	(�:
�	9� ��*�B�
�v�v�n�&7�8�;L�L��6�6�+�q�)�'�/�/��x�@�H��6�6�*�a�(�&�.�.�u�h�?�G�/9�+��(�G�#���'���
�
�k�<��:��X�w�&�&��[�
��
��2�	5��I�I�k�A�E�E�)�*�*4�'�H�h���	5�s*�2T�T.�	T+�*T+�.	U)�7(U$�$U)c�Z�tj|�j�}t|Sr`)r�normalizeModelNamer��	model_dat)r�s r?�queryModelByModelr��s&���%�%�e�,�2�2�4�E��U��rAc	�|�	t|�\	}}}}}}}}}	t|�S#t$rtt��wxYwr`)r�r�r��ERROR_INVALID_DEVICE_URI)
r2r�r�r�r�r�r�r�r�r�s
          r?r�r��sS��(�
�:�&�	-��%��e��H�d�B��
!��'�'���.��,�-�-�.�s�"�;�
�r.rc
��di}}|r%	tj|tj�}	|D�]�}
tjd|
z�|
tvrtj	d|
z��=|
dk(�r�|dk(r	tj||�}n4|d	k(r	tj||�}n	tj||�}|D�]�}
t�||
jd
d�}||
jdd�}||
jd
d�}|dkDs�St!|�D�]+}||
jd|dzzd�}|��"|dk7s�(t#|�}t%j&|jdd��}t(j+|
|�\}}|t(j,k(r|rt/|�}n|dk(r	d|�d|
��}nd||
|dzfz}d}t1|�}|stjd�d}nNt3|jdt4��t4k(rtjd�d}n|dvrt7||�}|s��$|||f||<��.�����(|
dv�r�|
dk(rt(j8}nt(j:}t(j=|�\}}|t(j,k(s���|j?�D�]!}t@jC|�}|jEd�xsd}|jEd�xsd}|jEd�xsd}|jEd�xsd} tj|�	tG|�\	}!}"}#}}$}%}&}'}d}|s��|s��|"s��t1|�}|stjd�d}nNt3|jdt4��t4k(rtjd�d}n|dvrt7||�}|s��||| f||<��$���|
d k(s���tIjJ�}(tM|(�}|(D]�})|)jN}tj|�d!|)jP���|dk7s�9	tG|�\	}!}"}*}}$}%}&}'}|"s�Rd}t1|�}|sd}tjd�nNt3|jdt4��t4k(rtjd�d}n|dvrt7||�}|s��||df||<�����i}+|D]c}|dz
}||\}}},d}|rD	jS|�d#|�d#|,�d#|���}-|-�&tj|�d#|�d#|,�d#|�d$|�d%�
�d}|s�\|||+|<�etU�|+S#tj	d�d}Y��JxYw#t$r.}|t_tj	d|z�t�d}~wwxYw#t$r.}|t_tj	d|z�t�d}~wwxYw#t$r.}|t_tj	d|z�t�d}~wwxYw#t$rY��uwxYw#t$rtjd"|z�Y��NwxYw)&Nrz{Invalid search pattern. Search uses standard regular expressions. For more info, see: http://www.amk.ca/python/howto/regex/r.zProbing bus: %szInvalid bus: %sr%rz*An error occured during network probe.[%s]r�hnz	?UNKNOWN?�num_devices�	num_portsrzdevice%d�0�MDLzhp:/net/z?ip=zhp:/net/%s?ip=%s&port=%dTr�Fr��Not supported.�Nr&z
print-type)r#r$r$r��r�rz: zUnrecognized URI: %s� z: Does not match search 'z'.)+�re�compile�
IGNORECASErCr�rD�VALID_BUSESr�detectNetworkDevicesr��socket�ERROR_INTERNALrr�update_spinnerr��ranger�rr�rr�r�rr�r4r��
__checkFilter�HPMUD_BUS_PARALLEL�
HPMUD_BUS_USB�
probe_devices�
splitlines�
direct_pat�matchr�r�r�getPrintersr�r2�namer��cleanup_spinner).r��timeout�ttl�filterr��
net_search�back_end_filterr��ret_devices�
search_pat�b�detected_devices�socket_error�ipr��num_devices_on_jd�num_ports_on_jdr��devr�r�r�r�r2�includer��bnr��x�m�mdl�desc�devidr�r��bbr�r�r�r��
cups_printers�p�bs�probed_devices�devid_or_hnr�s.                                              r?r�r��sa�� !�"��K�
�	����F�B�M�M�:�J�
�TE���	�	�#�a�'�(��K���I�I�'�!�+�,����:��U�"�)�'*�'?�'?��W�'M�$�
�w�&�)�',�'A�'A�#�w�'O�$�)�'+�'@�'@��g�'N�$�'�&
M��� �%�b�)�-�-�d�K�@��$4�R�$8�$<�$<�]�A�$N�!�"2�2�"6�":�":�;��"J��$�q�(� %�o� 6�M��.�r�2�6�6�z�T�!�V�7L�c�R���?�s�c�z�(5�c�(:�I�$*�$=�$=�i�m�m�E�S^�>_�$`�E�/7�/D�/D�R��/X�,�K��*�h�.A�.A�A�c�-;�C�-@�
�#2�a�#7�GL�b�1Q�J�1K�u�VX�[_�bc�[c�Ne�1e�J�&*�G�!2�5�!9�B�#%� #�	�	�,� 7�*/��!$�R�V�V�N�<M�%N�!O�Sd�!d� #�	�	�*:� ;�*/��!'�/L�!L�*7���*C��&�;@�%��:L��J� 7�?M�&
M�P�.�
 ��E�z��0�0���+�+�� (� 6� 6�r� :��K���h�1�1�1����*�#B�A�"�(�(��+�A��'�'�!�*�*��C��'�'�!�*�*��C��7�7�1�:�+��D��G�G�A�J�,�"�E��I�I�c�N�!�*�3�/�U��%��U�F�H�d�B�PT�
#�G��s�u�.�u�5��!��I�I�l�3�&+�G� �����8I�!J�K�O`�`��I�I�&6�7�&+�G�#�+H�H�&3�F�B�&?�G�"�03�T�5�/A�K��,�G#B�J�&�[� �,�,�.�M��M�"�A�"�
E���\�\�
��	�	�j�!�&�&�9�:���#�!�*�:�6�U��%��U�F�H�d�B�PT�!� �"�G�*�5�1�B��"'���	�	�,�/��R�V�V�N�4E�F�G�K\�\��	�	�"2�3�"'���'D�D�"/���";���38�%��2D��J�/�=
E�mTE�l�N��
3���q���"-�c�"2���U�K����"�)�)�3��{�TW�*X�Y�I�� ��	�	��U�T_�ad�fl�m�n����"-�c�"2�N�3��
3������W	��I�I�T�
U��F���)�#/�F�L��I�I�J�<�W�X�(�(��)���)�#/�F�L��I�I�J�<�W�X�(�(��)���)�#/�F�L��I�I�J�<�W�X�(�(��)��H!�!� �!��D!�!��	�	�"8�:�"E�F� �!�sw�$U�7U9�V3�,W-�X'�X7�U6�9	V0�)V+�+V0�3	W*�<)W%�%W*�-	X$�6)X�X$�'	X4�3X4�7!Y�Yr+c
���i}tj�}tj|�|D�]}	t	|j
�\	}}}}}	}
}}}
|dk(s||vsd|vs�2|dk(s�8|s�;|s�>d}t|�}|stjd�d}nNt|jdt��tk(rtjd�d}n|d	vrt||�}|s��d|vr|j
jd
d�}n|j
}	||||j|j���	|S#t$rY��wxYw#t$r|jg||<Y��8wxYw)Nr	�hpaior+Tr�Fr�r�r�r�r�)rrrCrDr�r2r�r�r4r�r�r�r�rXr�KeyError)rrr��printersrr�r�r�r�r�r�r�r�r�rr�r�s                 r?�getSupportedCUPSDevicesr#�sm���G����!�H��I�I�h��
�%.��	��q�|�|�,�
J�H�e�S�%���4��T�
�s�"�h�/�&A�
��
'�H��,<��e��G�"�5�)�B���	�	�,�'����R�V�V�N�,=�>�?�CT�T��	�	�*�+����<�<�'���3����o�-����,�,�U�H�=�A����A�.��A�J��A�J�%�%�a�f�f�-�K%.�N�N��E�	��	��: �*�"#�&�&��G�A�J�*�s#�D:�E
�:	E�E�
E'�&E'c
���g}tj�}|D]�}	t|j�\	}}}}}	}
}}}
|dk(s||vs�-|s�0|s�3d}t|�}|stjd�d}nNt|jdt��tk(rtjd�d}n|dvrt||�}|s��|j|���|S#t$rY��wxYw)Nr	Tr�Fr�r�r�)
rrr�r2r�r�rCrDr4r�r�r�rX)rr�printer_listr"rr�r�r�r�r�r�r�r�r�rr�s                r?�getSupportedCUPSPrintersr&�s����L����!�H�
�'��	��q�|�|�,�
J�H�e�S�%���4��T�
�s�"�h�/�&A�u�QV��G�"�5�)�B���	�	�,�'����R�V�V�N�,=�>�?�CT�T��	�	�*�+����<�<�'���3����#�#�A�&�1'�6���-�	��	�s�C�	C%�$C%c�X�t||�}|D�cgc]}|j��c}Scc}wr`)r&r)rrr"rs    r?�getSupportedCUPSPrinterNamesr(�s&��'���@�H�$�%�q�A�F�F�%�%��%s�'c
�(�|�yd}tj�}|D]d}	t|j�\	}}}}}	}
}}}
|s�&|j
|k(s�6|r|jj
dd�}|S|j}|S|S#t$rY�twxYw)Nr�r�)rrr�r2r�rr�)r3�
scan_uri_flagr2r"rr�r�r�r�r�r�r�r�r�s              r?�getDeviceURIByPrinterNamer+�s�������J����!�H�
�
��	��q�|�|�,�
J�H�e�S�%���4��T��Q�V�V�|�+���\�\�1�1�%��B�
�
����\�\�
����
�����	��	�s�B�	B�Bc�F�i}|j�jd�D�cgc]}|s�|j���}}|D]:}|jd�}	|j|dj�|d��<|jdd�|jdd�d|vr|d|d<|d=d	|vr|d	|d<|d	=nd
|vr|d
|d<|d
=|dj	d�rd|d<|Scc}w#t$r&|j|dj�d�Y��wxYw)N�;�:rrr�r.r��MODEL�SERIAL�SERN�X)�strip�split�
setdefault�
IndexError�
startswith)r�r��yr�zs     r?r�r��s.��	�A�%�O�O�-�3�3�C�8�>�q�A�����>�A�>�
�-��
�G�G�C�L��	-�
�L�L��1�����q��t�,�-��L�L�����L�L�����!�|��W�:��%��
�g�J��1�}��H�+��$��
�h�K�	�1���F�)��$��
�f�I���w���#����$���H��7	?���	-�
�L�L��1�����t�,�	-�s�C,�C,�&C1�1,D �D c�&�|jd�\}}	ttjt	|�d�xsd�}|r,ttjt	|�d�xsd�}||fS#t
$r|rd\}}nd\}}Y||fSwxYw)Nr�r�)rr)rr.)r4r4r
�xlstrip�str�
ValueError)�	ctr_field�convert_to_int�counter�values    r?�parseDynamicCounterrB"s����_�_�S�)�N�G�U�	#��e�m�m�C��L�#�6�=�#�>�����
�
�c�%�j�#�6�=�#�>�E��E�>���
�#��!�N�G�U�"�N�G�U���E�>��
#�s�AA4�4B�Bc�x�tj|�}|�'tjd|z�t	t
��|j
d�j�xsd}|dv}|j
d�j�xsd}|dvr'tjd|z�t	t
��|j
d�xsd}|j
d�xsd}|j
d	�xsd}|j
d
�xsd}|j
d�xsd}	|j
d�xsd}
|
r|
}n|	r|	}|j
d�xsd}|d
k(r	t|�}|dk(rd}tj|�d|�d|�d|�d|�d|�d|�d|�d|	�d|���||||||||	|f	S#ttf$rd}Y�WwxYw)Nz Device URI %s is invalid/unknownrr.)r+�hpfaxr r�)r#r%�bt�fwr$r�r�r����r%rz: back_end:z is_hp:z bus:z model:z serial:z
 dev_file:z host:z zc:z port:)�
pat_deviceurirrCrDr�r�r�r�r4r=�	TypeError)r2rr�r�r�r�r�r�r�r��hostnamer�s            r?r�r�6s������J�'�A��y��	�	�4�z�A�B��,�-�-��w�w�q�z���!�'�R�H�
�1�
1�E�
�'�'�!�*�
�
�
�
"��C�
�3�3��	�	�4�z�A�B��,�-�-�
�G�G�A�J��"�E�
�W�W�Q�Z�
�2�F��w�w�q�z��R�H��7�7�1�:���D�	
�����	�r�B��w�w�q�z��R�H����	����7�7�1�:�?��D�
�e�|�	��t�9�D��1�9��D��I�I�	�X�u�c�5�&�(�D�"�d�T�U��U�C����$��D�H�H���I�&�	��D�	�s�F%�%F9�8F9c�
�|dvS)N)r$r#rFrErkr�s r?�isLocalrNas���,�,�,rAc�
�|dvS)N)r%rkr�s r?�	isNetworkrPes���(�?�rAc�r�t|j��D]\}}|��	|\}}||||�r�yy)NFT)�list�items)rr��fr�op�vals      r?r�r�msC���V�\�\�^�$����1��=��G�B���b��e�S�>��	�rAc�l�|D]/}|rt}nt}||vs�tjd|z�yy)NzInvalid bus name: %sFT)r��VALID_BUSES_WO_CUPSrCr�)r��
allow_cupsr�vbs    r?�validateBusListr[ws?��
�����B�$�B��B�;��I�I�,�a�/�0���rAc�\�|�y|D]$}|tvs�tjd|z�yy)NTz Invalid term '%s' in filter listF)�
VALID_FILTERSrCr�)rrTs  r?�validateFilterListr^�s;��
�~��
����M�!��I�I�8�1�<�=���
rA�invalid�black�cmy�kcm�cyan�magenta�yellow�
photo_cyan�
photo_magenta�photo_yellow�
photo_gray�
photo_blue�kcmy_cm�photo_cyan_and_photo_magenta�light_gray_and_photo_black�
light_gray�medium_gray�cyan_and_magenta�black_and_yellow�photo_black�matte_black�unspecified�head�supply�	cartridge�toner�	maint_kit�adf_kit�drum_kit�transfer_kit�battery�unknown�ok�misinstalled�	incorrect�failed�overtemp�charging�discharging�low�outc���eZdZ		dcd�Zddd�Zd�Zd�Zd�Zded�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �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,d-�Z-dfd.�Z.d/�Z/dfd0�Z0d1�Z1d2�Z2e3jhfd3�Z5d4�Z6dgd6�Z7de8jrdfd7�Z:de8jrdfd8�Z;de8jrdfd9�Z<de8jrdfd:�Z=de8jrd5fd;�Z>de8jrd5fd<�Z?de8jrd5fd=�Z@de8jrd5fd>�ZAde8jrd5fd?�ZBde8jrd5fd@�ZCde8jrd5fdA�ZDdhdB�ZEdhdC�ZFde8jrdfdD�ZGdE�ZHdF�ZIdG�ZJdH�ZKdI�ZLdJ�ZMdK�ZNdL�ZOdM�ZPdN�ZQdO�ZRdP�ZSdidQ�ZTdR�ZUdjdS�ZVdkdT�ZWdjdU�ZXdkdV�ZYdldW�ZZdX�Z[dY�Z\dZ�Z]dmd[�Z^dmd\�Z_dmd]�Z`dmd^�Zadmd_�Zbd`�Zcda�Zddndb�Zey)o�DeviceNFc�d
�tjd|z�tjd|z�|a|s*|�t�\|_|_}nd|_||_nd|_d|_d|_tj�}|�i|�g|D]S}|jj�|j�k(s�/|j}tjd|z�ntt��||_||_||_t |_|j�tt��|jj%d�rt&|_nM|jj%d�rt(|_n&|jj%d�rt*|_	t-|j�\	|_|_|_|_|_|_|_|_|_tjd|j.|j0|j2|j4|j6|j8|j:|j>fz�tGjH|j4�|_%tGjL|j4�|_tjd	|j4�d
|jJ���|j2dk(r|j:|_'nd|_'i|_(i|_)d
|_*g|_+i|_,d|_-d|_.d|_/d|_0tb|_!te|j2�|_3g|_4d|_5|jm�|jjsItjod|j4z�tp|_9|ju|jr�nd|_5|jPjw|j4|jJd��tx|_=t||_?t�|_A|j��|jPj�dt��t�k7rG|jRjwd|jj�dd�j�dd�i�|jPj�dt��t�k7rG|jRjwd|jj�dd�j�dd�i�|jRjwid|j.�d|j0�d|j6�d|j8�d|j:�d|j>�d|jV�d |j��d!d�d"d�d#d$�d%d�d&d�d'|j~�d(|jz�d)|j�d*|jj�dd�j�dd���|j|j|jj�dd�|jj�dd�|jj�dd�|j�t�j�d+�|_Jy#t$rt@|_!ttD��wxYw),NzDevice URI: %szPrinter: %sTFr�r�r�zPURI: backend=%s, is_hp=%s, bus=%s, model=%s, serial=%s, dev=%s, host=%s, port=%dzModel/UI model: rTr%�	localhost�default_printerr�r.zUnsupported model: %s)r�zmodel-uir�zfax-urizhp:/zhpfax:/zhpaio:/r�zscan-urizback-endzis-hpr�zdev-filer�r��
cups-printers�status-code�status-desc�deviceid�panelr�panel-line1�panel-line2�device-state�error-statez
device-urizcups-uri)�URI�
DEVICE_URI�SCAN_URI�SANE_URI�FAX_URI�PRINTER�HOME)KrCrDr�r�rVr��
last_eventrrrr�r2r��ERROR_DEVICE_NOT_FOUNDr3�callback�DEVICE_TYPE_UNKNOWN�device_typer7�DEVICE_TYPE_PRINTER�DEVICE_TYPE_SCANNER�DEVICE_TYPE_FAXr�r�r�r�r�r�r�r�r�r��IO_STATE_NON_HP�io_stater�r�normalizeModelUIName�model_uir��	http_hostr��dq�iconr�channelsr��r_values�deviceID�panel_check�IO_STATE_HP_READYrN�is_local�hist�	supported�
queryModelr��STATUS_DEVICE_UNSUPPORTED�
error_code�	sendEvent�update�ERROR_STATE_ERROR�error_state�DEVICE_STATE_NOT_FOUND�device_state�EVENT_ERROR_DEVICE_NOT_FOUND�status_code�updateCUPSPrintersr��
FAX_TYPE_NONEr��SCAN_TYPE_NONE�first_cups_printerrjr��device_vars)	r>r2r3r�r��disable_dbusr[r"rs	         r?r@zDevice.__init__�s���	�	�	�"�Z�/�0��	�	�-�,�.�/�%�
����>G�k�;������"&���&���#�D�O��D�L�����#�#�%����,�":��
4���6�6�<�<�>�\�%7�%7�%9�9�!"���J��I�I�.��;�<��	
4��2�3�3�$���(��� ��
�.����?�?�"��.�/�/��?�?�%�%�e�,�2�D��
�_�_�
'�
'��
1�2�D��
�_�_�
'�
'��
1�.�D��	2��t���/�
J�D�M�4�:�t�x�����T�]�D�I�t�w��	�	�	�	�d�
�]�]�D�J�J����$�*�*�d�k�k�4�=�=�Z^�Zc�Zc�ei�en�en�o�p�	q��3�3�D�J�J�?��
��.�.�t�z�z�:��
��	�	�T�Z�Z����G�H��8�8�u��!�Y�Y�D�N�(�D�N�
������%��	������
������
���
����)��
�����)��
���	���������~�~��I�I�-��
�
�:�;�7�D�O��N�N�4�?�?�+�!�D�N�	
�����T�Z�Z�%)�]�]�4�	5�-���2���7������!��7�7�;�;�z�=�1�]�B��G�G�N�N�Y����)@�)@���)S�)[�)[�\e�gp�)q�r�s��7�7�;�;�{�N�3�~�E��G�G�N�N�Z�$�/�/�*A�*A�&�)�*T�*\�*\�]f�hq�*r�s�t�����������������
�����
����	�

�����
����
�
��!3�!3��
��!1�!1��
���
���
���
���
���
��!2�!2��
��!1�!1�� 
����!�"
����!8�!8��F�!K�!S�!S�T]�_e�!f�#�	�* �?�?��?�?��?�?�2�2�5�(�C��?�?�2�2�5�(�C��?�?�2�2�5�(�C��2�2��=�=�����_�	2�+�D�M��0�1�1�	2�s
�#AZ�$Z/c�X�|jr_|j�R	tjd|z�|jj	|j
||tj||�yyy#tjj$r}tjd�Yd}~yd}~wwxYw)NzSending event %d to hpssd...z dbus call to SendEvent() failed.)rVr�rCrD�	SendEventr2rjr6r�r�r�)r>r5r3r7r8r�s      r?r�zDevice.sendEventds����?�?�t�|�|�7�
>��	�	�8�:�E�F����&�&�t����j�RV�R_�R_�ag�in�o� 8�?���?�?�0�0�
>��	�	�<�=�=��
>�s�AA-�-B)�
B$�$B)c��yr`rkrEs r?�quitzDevice.quitm���rAc��|jst|j�|_t|j�|_|jr>|jD].}|j||j
|j
dd�<�0yy)N�-�_)r�r�r2�boolr��__dict__r�)r>rs  r?r�zDevice.queryModelqsh���w�w�%�d�o�o�6�D�G��d�g�g�����>�>��W�W�
?��48�G�G�A�J��
�
�a�i�i��C�0�1�
?�rAc��t|�Sr`)�queryString)r>�	string_ids  r?r�zDevice.queryString|s
���9�%�%rAc��|j�rL|jttfv�r2|j}t|_t
|_t|_t|_	d|_
||_|rRtjd|jz�|jj!dt"j$�|_nQtjd|jz�|jj!dt"j$�|_tjd|j&z�t"j)|j|j&�\}|_
|t"j*k7r�t|_|t,z|_|j1|j.�|t"j2k(r#tj5d|jz�n$tj5d||jfz�t7|jd	tt8j:d
d	t=j<��|_tAtB��tjd|jz�tD|_tF|_tjd|jH|j|jJ|jL|jN|jP|jR|jT|jVf	z�|t
k(rtX|_ntZ|_|j]�|j_�|jSyy)
Nr�z!Opening device: %s (for printing)r�z%Opening device: %s (not for printing)�io-mfp-modezI/O mode=%dzDevice busy: %sz/Unable to communicate with device (code=%d): %sr.rzdevice-id=%dz_Opened device: %s (backend=%s, is_hp=%s, bus=%s, model=%s, dev=%s, serial=%s, host=%s, port=%d))0r�r�r��IO_STATE_HP_NOT_AVAILr�r�r�r�r�r�r��open_for_printingrCrDr2r�r�rr��io_moder�r��ERROR_CODE_BASEr�r��HPMUD_R_DEVICE_BUSYr�r-rjr6r;r�r�r��IO_STATE_HP_OPEN�ERROR_STATE_CLEARr�r�r�r�r�r�r�r��DEVICE_STATE_JUST_FOUND�DEVICE_STATE_FOUND�getDeviceID�getSerialNumber)r>r��prev_device_stater�s    r?�openzDevice.open�sc���>�>�d�m�m�0A�CX�/Y�Y� $� 1� 1��1�D�M� 6�D��0�D��;�D���D�N�%6�D�"� ��	�	�=����O�P�#�w�w�{�{�9�h�6M�6M�N����	�	�A�D�O�O�S�T�#�w�w�{�{�=�(�:Q�:Q�R����I�I�m�d�l�l�2�3��$�$�T�_�_�d�l�l�C�
(�K����h�1�1�1�#4�� �"-�o�"=������t���/��(�">�">�>��I�I�/�$�/�/�A�B��I�I�O�S^�`d�`o�`o�Rp�p�q�"'�����=Y��
�
�q�"�d�i�i�k�#;����2�3�3��	�	�.�4�>�>�9�:� 0��
�#4�� ��	�	�{��]�]�D�O�O�T�Z�Z����4�:�:��]�]�D�K�K����D�I�I�G�G�H�%�(>�>�(?�D�%�(:�D�%�� � �"��$�$�&��~�~�%�eZ�>rAc��|jtk(r�tjd�t	|j
�dkDr9t
|j
j��D]}|j|��tj|j�}tjd|z�|j
j�t|_yy)NzClosing device...rzResult-code = %d)r�r�rCrDr�r�rR�keys�_Device__closeChannelrr�r��clearr�)r>�cr�s   r?�closezDevice.close�s����=�=�,�,��I�I�)�*��4�=�=�!�A�%��d�m�m�0�0�2�3�+�A��'�'��*�+�#�/�/����?�K��I�I�(�;�6�7��M�M���!�-�D�M�-rAc��	|jtk(r�|tjk(r.|js"|j�|j
d�nc|tjk7rP|jrD|j�|j
d�n"|j
|tjk(�|jdtk(s�|j�}||jvrdtjd|z�tj|j|�\}}||j|<tjd|z�|S|j|Sy#tjd�YyxYw)NTFzunable to open channelr�r�zOpening %s channel...z
channel-id=%d)r�r�r�HPMUD_S_PRINT_CHANNELr�r�r�rCr�r��IO_MODE_UNI�upperr�rD�open_channelr�)r>�service_namer��
channel_ids    r?�
__openChannelzDevice.__openChannel�s)��	��}�}� 0�0��8�#A�#A�A�$�J`�J`��J�J�L��I�I�d�O�!�X�%C�%C�C��H^�H^��J�J�L��I�I�e�$��	�	�,�(�*H�*H�H�I��w�w�y�!�[�0�'�-�-�/�L��4�=�=�0��	�	�1�L�@�A�*2�*?�*?����P\�*]�'��Z�.8��
�
�l�+��	�	�/�J�6�7�!�!��}�}�\�2�2���#	��I�I�.�/��s�B7E!�!E:c�$�|j|�Sr`)�_Device__openChannel�r>r�s  r?�openChannelzDevice.openChannel�s���!�!�,�/�/rAc�@�|jtj�Sr`)r�rr�rEs r?�	openPrintzDevice.openPrint�s���!�!�(�"@�"@�A�ArAc�@�|jtj�Sr`)r�r�HPMUD_S_FAX_SEND_CHANNELrEs r?�openFaxzDevice.openFax�����!�!�(�"C�"C�D�DrAc�@�|jtj�Sr`)r�r�HPMUD_S_MEMORY_CARD_CHANNELrEs r?�	openPCardzDevice.openPCard�����!�!�(�"F�"F�G�GrAc�@�|jtj�Sr`)r�r�HPMUD_S_EWS_CHANNELrEs r?�openEWSzDevice.openEWS�����!�!�(�">�">�?�?rAc�@�|jtj�Sr`)r�r�HPMUD_S_EWS_LEDM_CHANNELrEs r?�openEWS_LEDMzDevice.openEWS_LEDM�r�rAc�@�|jtj�Sr`)r�r�HPMUD_S_LEDM_SCANrEs r?�openLEDMzDevice.openLEDM�s���!�!�(�"<�"<�=�=rAc�@�|jtj�Sr`)r�r�HPMUD_S_MARVELL_EWS_CHANNELrEs r?�openMarvell_EWSzDevice.openMarvell_EWS�r�rAc�@�|jtj�Sr`)r�rr�rEs r?�
closePrintzDevice.closePrint�s���"�"�8�#A�#A�B�BrAc�@�|jtj�Sr`)r�rr�rEs r?�
closePCardzDevice.closePCard����"�"�8�#G�#G�H�HrAc�@�|jtj�Sr`)r�rr�rEs r?�closeFaxzDevice.closeFax����"�"�8�#D�#D�E�ErAc�@�|jtj�Sr`)r�r�HPMUD_S_PML_CHANNELrEs r?�openPMLzDevice.openPMLrrAc�@�|jtj�Sr`)r�r�HPMUD_S_WIFI_CHANNELrEs r?�openWifiConfigzDevice.openWifiConfig	s���!�!�(�"?�"?�@�@rAc�@�|jtj�Sr`)r�rrrEs r?�closePMLzDevice.closePML����"�"�8�#?�#?�@�@rAc�@�|jtj�Sr`)r�rr�rEs r?�closeEWSzDevice.closeEWSrrAc�@�|jtj�Sr`)r�rrrEs r?�
closeEWS_LEDMzDevice.closeEWS_LEDMrrAc�@�|jtj�Sr`)r�rrrEs r?�	closeLEDMzDevice.closeLEDMs���"�"�8�#=�#=�>�>rAc�@�|jtj�Sr`)r�rrrEs r?�closeMarvell_EWSzDevice.closeMarvell_EWSrrAc�@�|jtj�Sr`)r�r�HPMUD_S_CONFIG_UPLOAD_CHANNELrEs r?�
openCfgUploadzDevice.openCfgUploads���!�!�(�"H�"H�I�IrAc�@�|jtj�Sr`)r�rr$rEs r?�closeCfgUploadzDevice.closeCfgUploads���"�"�8�#I�#I�J�JrAc�@�|jtj�Sr`)r�r�HPMUD_S_CONFIG_DOWNLOAD_CHANNELrEs r?�openCfgDownloadzDevice.openCfgDownload!s���!�!�(�"J�"J�K�KrAc�@�|jtj�Sr`)r�rr)rEs r?�closeCfgDownloadzDevice.closeCfgDownload$s���"�"�8�#K�#K�L�LrAc�@�|jtj�Sr`)r�r�HPMUD_S_SOAP_FAXrEs r?�openSoapFaxzDevice.openSoapFax's���!�!�(�";�";�<�<rAc�@�|jtj�Sr`)r�r�HPMUD_S_MARVELL_FAX_CHANNELrEs r?�openMarvellFaxzDevice.openMarvellFax*r�rAc�@�|jtj�Sr`)r�rr.rEs r?�closeSoapFaxzDevice.closeSoapFax-s���"�"�8�#<�#<�=�=rAc�@�|jtj�Sr`)r�rr1rEs r?�closeMarvellFaxzDevice.closeMarvellFax0rrAc�@�|jtj�Sr`)r�rrrEs r?�closeWifiConfigzDevice.closeWifiConfig3s���"�"�8�#@�#@�A�ArAc��|jtk(rr|j�}||jvrStjd|z�tj|j|j|�}|j|=yyy)NzClosing %s channel...)	r�r�r�r�rCrDr�
close_channelr�)r>r�r�s   r?�__closeChannelzDevice.__closeChannel6su���=�=�,�,�'�-�-�/�L��t�}�}�,��	�	�1�L�@�A�&�4�4�T�^�^��M�M�,�/�1���M�M�,�/�
-�	-rAc�$�|j|�Sr`)r�r�s  r?�closeChannelzDevice.closeChannelEs���"�"�<�0�0rAc�P�d}d|_i|_|jtk7r	|j	�d}t
j
|j�\}}|t
jk(r||_t|�|_|r|j�|jS#YyxYw)NFr.r�T)�raw_deviceIDr�r�r�r�rr�r�r�r�r�)r>�needs_closer�r�s    r?r�zDevice.getDeviceIDIs����������
��=�=�,�,���y�y�{��;�$�2�2�4�>�>�B���T��(�-�-�-� $�D��)�$�/�D�M���J�J�L��}�}�����s�B!�!B%c��|jry	|jd|_|jry|jj	dt
�t
k7r9		|j
tj�\}|_|j�|j�d|_yy#t$rY��wxYw#t$r
d|_Y�FwxYw#|j�wxYw)Nr��status-typer.)r�r�r!r�r��STATUS_TYPE_NONE�getPMLr�OID_SERIAL_NUMBERr�r)r>r�s  r?r�zDevice.getSerialNumberas����;�;��	��-�-��-�D�K��{�{���7�7�;�;�}�&6�7�;K�K�
 �%�.2�k�k�#�:O�:O�.P�+�J����
�
���;�;���D�K���#�	��	���%�"$�D�K�%���
�
��s5�B%�'B4�%	B1�0B1�4C�C
�C�C
�
Cc��yr`rkrEs r?�getThreeBitStatuszDevice.getThreeBitStatus|r�rAc�r�|j�tjt|j��Sr`)r�r
�parseStatusr�r?rEs r?�getStatusFromDeviceIDzDevice.getStatusFromDeviceID�s*�������!�!�-��0A�0A�"B�C�CrAc��t|�}djddt|�z
z|g�}|dd|dd}}t|�}||||f|_||||fS)Nr.r��	r�)r<r�r�r4r�)r>�r_value�r_value_str�rg�rrs     r?�__parseRValueszDevice.__parseRValues�sj���'�l���g�g�s�A��K�(8�$8�9�;�G�H���R�a��+�a�b�/�B���b�'����b�"�4��
���R��+�+rAc��d\}}}}|dkD�r)|tk7�r|j�u|jr0	t|jj|jd��}|dk7r4tjd|z�|j|�\}}}}||||fS|j���|tk(r�|jr�|tk7r�		|j!d�}|�ctjd|z�|j|�\}}}}|jr@	|jj#|jd|�ntj%d	�d}|j)�n�|tk(r|t*k(r|jr	|tk(r�	|j-t.j0�\}	}|�ctjd|z�|j|�\}}}}|jr+	|jj#|jd|�nd}|j3�n|j\}}}}||||fS#tjj$r"}tjd�d}Yd}~��d}~wwxYw#tjj$r }tjd�Yd}~��dd}~wwxYw#t&$rtj%d
�d}Y���wxYw#|j)�wxYw#tjj$r }tjd�Yd}~��d}~wwxYw#|j3�wxYw)N�r�	000000000�000�000000rrMz(dbus call to GetCachedIntValue() failed.r�z
r_value=%d�z(dbus call to SetCachedIntValue() failed.z%Error attempting to read r-value (2).z%Error attempting to read r-value (1).)�STATUS_DYNAMIC_COUNTERS_NONEr�rVr4r��GetCachedIntValuer2r�r�r�rCrD�_Device__parseRValues�
STATUS_TYPE_Sr�� STATUS_DYNAMIC_COUNTERS_PML_SNMP�getDynamicCounter�SetCachedIntValuer�r�r�STATUS_DYNAMIC_COUNTERS_PCLrDr�
OID_R_SETTINGr)
r>�r_type�status_type�dynamic_countersrMrNrOrPr�r�s
          r?�
getRValueszDevice.getRValues�s���'F�$���b�"��A�:�� <�<��}�}�$��?�?�%�"%�d�l�l�&D�&D�T�_�_�V_�&`�"a��
�b�=��I�I�l�W�4�5�37�3F�3F�w�3O�0�G�[�"�b�"�K��R�7�7��}�}�$��=�0��M�M�$�(H�H�*�(�&*�&<�&<�S�&A�G�&�2� #�	�	�,��*@� A�?C�?R�?R�SZ�?[� <���b�"�#'�?�?�%^�(,���(F�(F�t���Xa�cj�(k�!$�	�	�*Q� R�*+��
���)�"�m�3�&�*E�E��-�-�&�*J�J�(�/3�{�{�3�;L�;L�/M�,��W�"�.��I�I�l�W�&<�=�;?�;N�;N�w�;W�8�G�[�"�b�#���!Z�$(�L�L�$B�$B�4�?�?�T]�_f�$g�
'(�G��
�
��04�}�}�,���b�"���R��+�+��E �?�?�8�8�%��	�	�"L�M�"$���%��6,0�?�?�+H�+H�%^�(+�	�	�2\�(]�(]��%^��
 %�(��I�I�&M�N�&'�G�(�����)��$(,���'D�'D�!Z�$'�I�I�.X�$Y�$Y��!Z���
�
��s��/H=�A
J?�'I?�;J?�AL;�+'K;�L;�=I<�I7�7I<�?J<�J7�1J?�7J<�<J?�? K#�K&�"K#�#K&�&K8�;L8�L3�-L;�3L8�8L;�;M
c
��|jjdt�}t|_|tk7�r�|j
tk7r�|jttfvr	|j�|j+|j�}|j,j/|j0|j2|j||j4ddd|j
|j6d�
�tj9d�t;j<|�\}}|rt>|_n
|rt@|_tBj|jtD�|_|j|_#|jI|jF�	|j,j/|j+|j�|j6d��|jLr*tO|jjdd��|_&|jjd	tP�}|jLr�|tRtTtVfvr|tk7rvtj9d
�	t;jX|�\|_&}	}
|j[�|j,j/t]|jL�|	|
d��|s|r|j_�|j,D].}|j,||j`|jcdd
�<�0t|jd|jt"j$ddt'j&��|_tj9|j,�y#t$rm}tjd�t|jdt t"j$ddt'j&��|_tt ��d}~wwxYw#tJtf$r&|j,j/dtDd��Y��\wxYw#|j[�wxYw)Nr��Error getting device ID.r.r�
r�r�r�r�r�r�r�r�r�r�zFax activity check...�r�r��panel-check-typerB�Panel check...�r�r�r�r�r�)2r�r�r��STATUS_PRINTER_IDLEr�r�r��	tech_type�TECH_TYPE_MONO_INK�TECH_TYPE_COLOR_INKr�r�rCr�r-r2�ERROR_DEVICE_IO_ERRORrjr6r;r�r�r�r�r�rr?r�rDr
�getFaxStatus�STATUS_FAX_TX_ACTIVE�STATUS_FAX_RX_ACTIVE�STATUS_TO_ERROR_STATE_MAPr�r�r�r!r�r�rC�STATUS_TYPE_LJr[�STATUS_TYPE_VSTATUS�
PanelCheckrr4r�r�r�)r>�quick�reread_cups_printersr�r��status_desc�	tx_active�	rx_activerb�line1�line2r�s            r?�
__queryFaxzDevice.__queryFax�sJ���'�'�+�+�i��5��.����k�!�� � �$:�:��>�>�&8�:M�%N�N�;��(�(�*�#�.�.�t�/?�/?�@�������)-���)-�);�);�)-�)9�)9�)4�)-�):�):�)*�)+�)+�)-�):�):�)-�)9�)9� ��
�I�I�-�.�#)�#6�#6�t�#<� �I�y��#7�� ��#7�� �8�<�<�T�=M�=M�O`�a�D��"�.�.�D�O��N�N�4�?�?�+�
#�������0@�0@��AQ�AQ�0R�04�0@�0@� "�#����#'������4F��(J�#K�� ��'�'�+�+�m�5E�F�K������
�?R�S�S��;�&��	�	�*�+�$�5;�5F�5F�t�5L�2�D�$�e�U��M�M�O�������T�-=�-=�)>�16�16� 9�:��1��'�'�)����	;�A�04����
�D�M�M�!�)�)�C��,�-�	;� �����T�5E�5E�t�}�}�VW�Y[�]a�]f�]f�]h�i����	�	�$�'�'���S!�;��	�	�"<�=�*/�����EZ� �M�M�1�b�$�)�)�+�+?���$�$9�:�:��;��R�e�$�
#�������0A� "�#�
#��$�M�M�O�s8�"M=�
AO6�"P.�=	O3�A(O.�.O3�61P+�*P+�.Qc�$�g|_tjd�tj�}|D]�}|j
|j
k(s�|jj
|j�|j|_|jtk(s�g|jjd�d|_
��|jjd|ji�	|jd|_y#t"$r
d|_YywxYw)Nz*Re-reading CUPS printer queue information.�,rr�r.)rrCrDrrr2rXr�stater�r��	makemodelr4r�r�r�r�r6)r>r"rs   r?r�zDevice.updateCUPSPrinters4s�������	�	�>�?��#�#�%���	;�A����!�,�,�.��"�"�)�)�!�&�&�1��W�W��
��=�=�O�3�!"���!2�!2�3�!7��!:�D�J�
	;�	
������$�*<�*<�=�>�	)�&*�&8�&8��&;�D�#���	)�&(�D�#�	)�s�'C<�<D�Dc�D�|jsLi|_t|jdtt
jddtj��|_y|jtk(r|j||�S|jjdd�}|jjdt�}|jjdt�}|jjdt �}|jjdt"�}|jjdt$�}|jjd	t$�}	t&}
g}|j(t*k7�
r<|j,t.t0fvr	|j3�|j=|j>�}
|jjA|jB|jD|j>|
|jFddd|j(|jHd�
�i}|tk(rt6jKd�d
t&i}�n�|tLtNfvr6t6jQd�tSjT|jV�}�nC|tXtZfvr7t6jQd�tSj\||jV�}�n�|t^k(r,t6jQd�tSj`|�}�n�|tbk(r,t6jQd�tSjd|�}�n�|tfk(r6t6jQd�tSjh|jj�}�nU|tlk(r6t6jQd�tSjh|jn�}�n|tpk(r@t6jQd�tSjr|j|jt�}n�|tvk(r�t6jQd�|jxr tSjz|j|�}n�d|j~z}|j�r:t�j�|j��\}}|t�j�k(rd|z}tSj�|�}nt6j9d|z�|r5|t$k7r,t6jQd�tSj�|||�|rHt6jQ|�|jjA|�	|d|d}|jd=|jjd
t&�}
t�j|
t��|_$|
|_I|j�|j��	|jjA|j=|
�|jHd��d}|�s0|tk7�r&|j�r*t�|jjdd��|_K|j�r�|tXtNtLfvr|t$k7rvt6jQd�	tSj�|�\|_K}}|j��|jjAt�|j��||d��|t"k7r"|t$k7r|j�|||�\}}}}nd\}}}}|jjA||||d��|s|r|j��|�s�|dkDrD|jjd |zd�dk(r"d}|jjA|d��d!}|D]}	|d"dk7rd#}n�d$\}}	|r*|t�|�kDr�n}||d%z
}|d"}|d&}|d'}d#}n�|jjd(||fzd)�} | d)k(r�n;|jjd*||fzd�}!|jjd+||fzd�}d!}t6jQd,| |!fz�|D]}|d&}|d'}|| k(s�||!k(s�d#}n|�r&t6jQd-|fz�jd.t��}"|jd/d0�}#|jd1t��}$t6jQd2|"|#|$|
fz�d3t�j|d4��d5t�j|d4���}%|j=|%�}&d6}%|
t�k(s|
t�k(s
|
t�k(�r�|"t�k(s|"t�k(�r�|t�k(�r�|$t�k\�r�d7t�j|$d4�z}%|t.t0fvr
|t�z}'n	|t�z}'|'|jd
<|j=|'�|jd8<t�j|'t��|jd9<|'|_I|j�|j��|$t�t�fvrd:}%nd;}%|j=|%�}(|jjAd<|z|d=|z|d>|z|jd?d!�d@|z|dA|z|#dB|z|$dC|z|jdDd!�dE|z|jdFd!�dG|z|"dH|z|jdId�dJ|z|jdKd!�dL|z|&dM|z|jdNd�dO|z|(i�n�dPt�j|"t��z}%|j=|%�}(|jjAd<|z|d=|z|d>|zd!d@|z|dA|z|#dB|z|$dC|zd!dE|zd!dG|z|"dH|zddJ|zd!dL|z|&dM|zddO|z|(i�|d%z
}nt6jQdQ|z�|d%z
}��d}|dkDr|j��|j�d}|dkDr!|jjd d�dk(rd}d%}	|jjd(||fzd�} | dk(r�n|jjd*||fzd�}!|jjd+||fzd�}d3t�j|!d4��d5t�j| d4���}%|j=|%�}&|jjAd<|z| d=|z|!d>|zd!d@|z|dA|zddB|zt�dC|zd!dE|zd!dG|zt�dH|zddJ|zd!dO|z|j=dR�dL|z|&dM|zdi�|d%z
}��*|jD].})|j|)|j�|)j�dSd5�<�0t|jd|
t
jddtj��|_t6jQ|j�y#t4$rm}t6j9d
�t|jdt:t
jddtj��|_t5t:��d}~wwxYw#t�$rY���wxYw#t�t4f$r&|jjAdt�d��Y���wxYw#|j��wxYw#Y��xYw)TNr.rzr-typez	tech-typerBzstatus-battery-check�status-dynamic-countersr�r�rfrgzNo status available for device.r�z Type 1/2 (S: or VSTATUS:) statusz"Type 3/9 LaserJet PML(+PJL) statuszType 6: LJ XMLzType 8: LJ PJLz
Type 10: LEDMzType 11: LEDM_FF_CC_0zType 12: IPPzType 13: CDMz&http://%s/cdm/supply/v1/suppliesPubliczUnimplemented status type: %dzBattery check...�agentsrhrirjrkrS)�r�rsrOrPzr%d-agent1-kindFz	agent-skuT)rrr�kind�typezr%d-agent%d-kindr�zr%d-agent%d-typezr%d-agent%d-skuzLooking for kind=%d, type=%d...zfound: r%d-kind%d-type%d�health�level�dz
level-triggerz5health=%d, level=%d, level_trigger=%d, status_code=%d�agent_r~r��agent_health_okzagent_level_%sr�r��agent_level_out�agent_level_lowzagent%d-kindzagent%d-typez
agent%d-known�knownzagent%d-skuz
agent%d-levelzagent%d-level-triggerzagent%d-ack�ackzagent%d-hp-inkzhp-inkzagent%d-healthzagent%d-dvc�dvczagent%d-virgin�virginzagent%d-descz
agent%d-id�idzagent%d-health-desczagent_health_%sz
Not found: %d�agent_health_unknownr�)hr�r�r-r2r�rjr6r;r�r�r��_Device__queryFaxr�r��TECH_TYPE_NONErC�STATUS_BATTERY_CHECK_NONErXr��STATUS_UNKNOWNr�r�rmrnror�r�rCr�rpr�r�r�r�rr?r�r�rvr[rDr
rIr�ru�STATUS_TYPE_PML_AND_PJL�StatusType3�STATUS_TYPE_LJ_XML�StatusType6�STATUS_TYPE_PJL�StatusType8�STATUS_TYPE_LEDM�StatusType10�getEWSUrl_LEDM�STATUS_TYPE_LEDM_FF_CC_0�getUrl_LEDM�STATUS_TYPE_IPP�
StatusTypeIPPr3�STATUS_TYPE_CDMr��StatusTypeCDM_USB�
getUrl_CDMr�r�r�get_zc_ip_addressr��StatusTypeCDM_Net�BatteryCheckr!rtr�r�r�r�r�rwrr4rdr�r��AGENT_HEALTH_OK� AGENT_LEVEL_TRIGGER_SUFFICIENT_0�AGENT_types�AGENT_kinds�STATUS_PRINTER_POWER_SAVErl�STATUS_PRINTER_OUT_OF_INK�AGENT_HEALTH_FAIR_MODERATE�AGENT_KIND_HEAD�AGENT_LEVEL_TRIGGER_MAY_BE_LOW�AGENT_levels�STATUS_PRINTER_LOW_INK_BASE�STATUS_PRINTER_LOW_TONER_BASE�ERROR_STATE_LOW_SUPPLIES� AGENT_LEVEL_TRIGGER_PROBABLY_OUT�)AGENT_LEVEL_TRIGGER_ALMOST_DEFINITELY_OUT�
AGENT_healthsr��AGENT_HEALTH_MISINSTALLEDr�r�)*r>rxryrarmrb�
battery_checkrcr��io_mfp_moder�r�r�rz�status_block�resource_url�retnrrMr}r~rNrOrP�dynamic_sku_data�agent�a�aa�mq_agent_sku�
agent_kind�
agent_typer��
mq_agent_kind�
mq_agent_type�agent_health�agent_level�agent_level_trigger�query�
agent_desc�code�agent_health_descr�s*                                          r?�queryDevicezDevice.queryDeviceJs�
���~�~��D�G�#�D�O�O�R�9R��
�
�q�"�d�i�i�k�3�D�O�
�����.��?�?�5�*>�?�?������X�q�)���G�G�K�K��^�<�	��g�g�k�k�-�1A�B�������$:�<U�V�
��7�7�;�;�'@�B^�_���'�'�+�+�i��5���g�g�k�k�-��=��$������� 6�6��~�~�"4�6I�!J�J�7��$�$�&��*�*�4�+;�+;�<�K��G�G�N�N�%)�[�[�%)�%7�%7�%)�%5�%5�%0�%)�%6�%6�%&�%'�%'�%)�%6�%6�%)�%5�%5��
��L��.�.����:�;� -��?���!4�m� D�D��	�	�<�=�%�1�1�$�-�-�@����1H� I�I��	�	�>�?�%�1�1�$��
�
�F��� 2�2��	�	�*�+�%�1�1�$�7����/��	�	�*�+�%�1�1�$�7��� 0�0��	�	�/�*�%�2�2�4�3F�3F�G��� 8�8��	�	�1�2�%�2�2�4�3C�3C�D����/��	�	�.�)�%�3�3�D�O�O�D�DU�DU�V����/��	�	�.�)��=�=�#)�#;�#;�D�O�O�#L�L�#K�t�y�y�#Y�L��w�w�#+�#=�#=�d�g�g�#F���b��8�#6�#6�6�*R�VX�*Y�<�#)�#;�#;�L�#I�L��	�	�9�K�G�H���;�&��	�	�,�-��#�#�D�,�
�F���	�	�,�'������|�,�*� ��*�*�(�3�F�����)��'�'�+�+�m�^�D�K�8�<�<�[�J[�\�D��)�D�O��N�N�4�?�?�+�
#�������0@�0@��0M�04�0@�0@� "�#��G��[�,<�<��#�#�'+�D�G�G�K�K�8J�A�,N�'O�D�$��#�#��N�M�CV�#W�W��{�*��I�I�.�/�(�9?�9J�9J�4�9P�6��(�%���
�
���G�G�N�N�S��1A�1A�-B�5:�5:�$=�>�
$�'C�C��{�*�37�?�?�6�;�Xh�3i�0�G�[�"�b�3R�0�G�[�"�b������w�'2�')�')�  �!��1��'�'�)���Q�;�4�7�7�;�;�/@�7�/J�A�#N�RS�#S��G��G�G�N�N�7�+6�+-�+-�$$�%�$)� �#��E�� ��-��3�/3�,�!�4�����2��'��s�6�{�?�!� &�q��s���',�[�'9��%*�6�]�
�%*�6�]�
� $��(,�����4F�'�ST��4U�WY�(Z�
�(�B�.�!�(,�����4F�'�ST��4U�WX�(Y�
�'+�w�w�{�{�3D��QR�|�3S�UW�'X�� %���	�	�"C�}�Vc�Fd�"d�e�%+�)�E�).�v��J�).�v��J�)�]�:�)�]�:�+/�5�#(�)���	�	�"<���U_�?`�"`�a�',�y�y��?�'K��&+�i�i���&=��.3�i�i��<�/>�+��	�	�"Y�)�;�8K�[�Y�#Z�[�2=����Y�1W�1<����Y�1W�!Y��&*�%5�%5�e�%<�
� 1��(�+D�D��Wj�Hj�ny�~W�oW�)�_�<�*�.H�H�Z�[j�Mj�/�3Q�Q�$4�|�7G�7G�H[�]f�7g�$g�E�(�-?�AT�,U�U�'1�4O�'O��'1�4Q�'Q��59�D�G�G�M�2�59�5E�5E�d�5K�D�G�G�M�2�5N�5R�5R�SW�Yq�5r�D�G�G�M�2�.2�D�O� �N�N�4�?�?�;�2�!A�Cl� m� n�):��(9��04�0@�0@��0G�-� �G�G�N�N� .�� 3�z� .�� 3�z� /�"� 4�u�y�y��RW�?X� -�� 2�|� /�"� 4�{� 7�"� <�?R� -�� 2�u�y�y��PU�?V� 0�2� 5�u�y�y��SX�?Y� 0�2� 5�|� -�� 2�u�y�y��PQ�?R� 0�2� 5�u�y�y��SX�?Y� .�� 3�z� ,�r� 1�u�y�y��q�?Q� 5�� :�?P���&%6�
�8I�8I�,�Xg�8h�$h�E�04�0@�0@��0G�-� �G�G�N�N� .�� 3�z� .�� 3�z� /�"� 4�u� -�� 2�|� /�"� 4�{� 7�"� <�?R� -�� 2�u� 0�2� 5�u� 0�2� 5�|� -�� 2�q� 0�2� 5�u� .�� 3�z� ,�r� 1�q� 5�� :�?P���$�a����	�	�/�A�"5�6���F�A�s�z�G���z�d�m�m�7��-�-��*����{�t�w�w�{�{�+<�a�@�A�E����A�� $�����,>�'�1��,M�q� Q�
� �A�%�� $�����,>�'�1��,M�q� Q�
�#�w�w�{�{�+<���|�+K�R�P��)4����	�)R�)4����	�)R�T��"�-�-�e�4�
������"�Q�&�-�"�Q�&�-�#�a�'�%�!�A�%�,�#�a�'�!�+�a�/�2[�!�A�%�%�$�q�(�%�$�q�(�2K�!�A�%�!�$�q�(�%�)�A�-�$�2B�2B�CY�2Z�"�Q�&�*� �1�$�!���$�Q���?�B���	;�A�04����
�D�M�M�!�)�)�C��,�-�	;� �����[�$�-�-�QR�TV�X\�Xa�Xa�Xc�d����	�	�$�'�'���c
�7��I�I�8�9�&+�D�O�O�R�AV��
�
�q�"�d�i�i�k�';�D�O� � 5�6�6��7��d �����$�e�$�
#�������0A� "�#�
#��&�
�
���T��sU�w�7x=�07y
�*z�
z�	x:�
A(x5�5x:�=	y
�	y
�
1z�z�z�zc�v�	|jd��|jttfvS#t$rYywxYw)NT�rx�r�r�r�r��ERROR_STATE_BUSYrEs r?�isBusyOrInErrorStatezDevice.isBusyOrInErrorState�sF��	����4��(����$5�7G�#H�H�H���	��	���,�	8�8c�v�	|jd��|jttfvS#t$rYywxYw)NTr�Fr�rEs r?�isIdleAndNoErrorzDevice.isIdleAndNoError�sF��	����4��(����(9�;K�'L�L�L���	��	�r�c�r�|j�}tj|j|t	j
|d�|d�\}}}}|tjkDr!tjd|d|fz�|dfSt	j||d|�}tj�r�|dtjtjfvr6tjd|d|fz�tj|�||fStjd|d|t|�fz�||fS)Nrrz+PML/SNMP GET %s failed (result code = 0x%x)z.PML/SNMP GET %s (result code = 0x%x) returned:z1PML/SNMP GET %s (result code = 0x%x) returned: %s)rr�get_pmlr�r�	PMLToSNMP�ERROR_MAX_OKrCrD�ConvertFromPMLDataFormat�is_debug�TYPE_STRING�TYPE_BINARY�log_data�repr)	r>�oid�desired_int_sizer�r�r��typ�pml_result_code�converted_datas	         r?rDz
Device.getPML�s$���\�\�^�
����T�^�^�Z����s�1�v�9N�PS�TU�PV�W�	0��T�3���S�-�-�-��I�I�C�s�1�v��F_�_�`�"�D�(�(��5�5�d�C��F�DT�U���<�<�>��1�v�#�/�/�3�?�?�;�;��	�	�J���V�_�-�.�/����T�"���.�.��	�	�M���V�_�d�>�.B�C�D�E���.�.rAc
���|j�}tj||d�}tj	|j
|tj|d�|d|�\}}tj�rz|dtjtjfvrtjd|d|fz�|Stjd|d|t|jd��fz�|S)Nrrz(PML/SNMP SET %s (result code = 0x%x) to:z+PML/SNMP SET %s (result code = 0x%x) to: %srG)rr�ConvertToPMLDataFormatr�set_pmlr�r�rCr�r�r�rDr��decode)r>r�rAr�r�r�s      r?�setPMLz
Device.setPML�s����\�\�^�
��*�*�5�#�a�&�9�����T�^�^�Z����s�1�v�9N�PS�TU�PV�X]�^�	%��_��<�<�>��1�v�#�/�/�3�?�?�;�;��	�	�D���V�_�-�.�/����	�	�G���V�_�d�5�<�<��3H�.I�J�K�L��rATc�Z�|jjdt�}tj	d|z�|tk7�r[|t
k(rL|j
tj�d��|j
tj|�d��n&|j
tj|�d��d\}}}}}tjd�	|jr|j�|dz
}|dz
}tj|�|j�d|j vrot"j%|j&��Pt)|j d|�\}	}||	k(r/|j
tjd	�d��|sd
|z}|S||kDrz|t
k(rJ|j
tj��|j
tj|�d��y|j
tjd	�d��y|t
k(rJ|j
tj��|j
tj|�d��n&|j
tj|�d�����t+t,��)Nr�zDynamic counters: %dT)�direct)rrr皙�����?r�r�r�CTRr�#)r�r�rXrCrD�#STATUS_DYNAMIC_COUNTERS_LIDIL_0_5_4�	printDatar�buildResetPacket�buildDynamicCountersPacketr�buildDynamicCounterr;r�r�r�r��pat_dynamic_ctrr�r?rBr��'ERROR_DEVICE_DOES_NOT_SUPPORT_OPERATION)
r>r@r?rcrA�tries�
times_seen�sleepy_time�	max_tries�dev_counters
          r?r]zDevice.getDynamicCounter�s)���7�7�;�;�'@�B^�_���	�	�(�+;�;�<��;�;��#F�F����s�3�3�5�d��C����s�=�=�g�F�t��T����s�6�6�w�?���M�?N�<�E�5�*�k�9��J�J�s�O���=�=��M�M�O��s�"����
���
�
�;�'�� � �"��D�M�M�)�#�*�*�4�+<�+<�=�I�)<�T�]�]�5�=Q�Sa�)b�&�K���+�-����s�'>�'>�q�'A�$��O�-�$'�%�K�E�$���9�$�'�+N�N����s�';�';�'=�>����s�'E�'E�g�'N�W[��\� ����s�'>�'>�q�'A�$��O��#�'J�J��N�N�3�#7�#7�#9�:��N�N�3�#A�#A�'�#J�SW�N�X��N�N�3�#:�#:�7�#C�D�N�Q�I�N�?�@�@rAc�@�|j|j||||�Sr`)�_Device__readChannelr��r>�
bytes_to_read�streamr�allow_short_reads     r?�	readPrintzDevice.readPrint-� ���!�!�$�.�.�-���Rb�c�crAc�@�|j|j||||�Sr`)rr�rs     r?�	readPCardzDevice.readPCard0r
rAc�@�|j|j||||�Sr`)rr�rs     r?�readFaxzDevice.readFax3� ���!�!�$�,�,�
�v�w�P`�a�arAc�@�|j|j||||�Sr`)rr%rs     r?�
readCfgUploadzDevice.readCfgUpload6s"���!�!�$�"4�"4�m�V�W�Vf�g�grAc�@�|j|j||||�Sr`)rr�rs     r?�readEWSzDevice.readEWS9rrAc�@�|j|j||||�Sr`)rrrs     r?�readEWS_LEDMzDevice.readEWS_LEDM<s"���!�!�$�"3�"3�]�F�G�Ue�f�frAc�@�|j|j||||�Sr`)rrrs     r?�readLEDMzDevice.readLEDM?s ���!�!�$�-�-����Qa�b�brAc�@�|j|j||||�Sr`)rr	rs     r?�readMarvell_EWSzDevice.readMarvell_EWSBs"���!�!�$�"6�"6�
�v�w�Xh�i�irAc�@�|j|j||||�Sr`)rr/rs     r?�readSoapFaxzDevice.readSoapFaxEs"���!�!�$�"2�"2�M�6�7�Td�e�erAc�@�|j|j||||�Sr`)rr2rs     r?�readMarvellFaxzDevice.readMarvellFaxH�"���!�!�$�"5�"5�}�f�g�Wg�h�hrAc�@�|j|j||||�Sr`)rrrs     r?�readWifiConfigzDevice.readWifiConfigKrrAc��td�}d}d}d}||||�}|j�j�D]W}	|	j�j	td��dk7s�/t|	j
td��d�}d	}n|j�j	td
��}
|
dk7r|t|j��|
z
z
}|dkDr[t�}||||�}|j|j��|s||z
}|dkry||j�k(ry|dkDr�Zyy)Nz0

�rTzcontent-lengthr�r.rFz<?xml)
r�getvaluer�r��findr4r4r�rrN)r�func�replyr�END_OF_DATA�bytes_requested�bytes_remaining�chunkedFlag�
bytes_read�line�xml_data_start�temp_bufs            r?�readLEDMDatazDevice.readLEDMDataOs3��!�+�.���������/�5�'�:�
��N�N�$�/�/�1�	�D��z�z�|� � ��/?�!@�A�R�G�#&�t�z�z�-��2D�'E�a�'H�#I��$���		����)�.�.�}�W�/E�F���b� �-��U�^�^�5E�1F�.�1X�Y�O��1�n� �{�H��o�x��A�J��K�K��)�)�+�,��"1�J�">��"�a�'���� 1� 1� 3�3���1�nrAc�&�	|d||�}|dk(ry�)z�
        Read any leftover response data from the previous session.
        We read and disregard all such leftover data here to have a clean new session.
        If we are getting a blank responses that means there is no more junk data. 
        r"rNrk)rr%r&rr+s     r?�readLEDMAllDatazDevice.readLEDMAllDataos$����d�E�7�3�J��Q���rAc��|�}tjd||j|||fz�d}|�td�}	tj|j|||�\}	}
tjd|	z�t
|
�}|	tjk(rtjd�n�|	tjk7r$tjd�tt��|stjd�n�|�td�j|
g�}n|j|
�||z
}|j�|j�||k(rtjd�n$|r ||krtjd	||fz�n��P|�tjd
|z�Stjd|z�|S)NzRReading channel %d (device-id=%d, bytes_to_read=%d, allow_short=%s, timeout=%d)...rr.�Result code=%dzI/O timeoutzChannel read errorzEnd of datazFull read complete.z.Allowed short read of %d of %d bytes complete.z"Returned %d total bytes in buffer.zSaved %d total bytes to stream.)rCrDr�rr�read_channelr��HPMUD_R_IO_TIMEOUTr�r�r�rpr�rNr�)r>�openerrrrrr��	num_bytes�bufferr�r��ls            r?�
__readChannelzDevice.__readChannel{s����X�
��	�	�f�
�����8H�'�R�S�	T��	��>�"�2�&�F���%�%�d�n�n�j�-�QX�Y�
�K��
�I�I�&��4�5��D�	�A��h�9�9�9��	�	�-�(���h�1�1�1��	�	�.�/��1�2�2���	�	�-�(���~�&�r�*�/�/����?�����T�"���N�I��}�}�(��
�
���M�)��	�	�/�0���I�
�$=��	�	�J�i�Yf�Mg�g�h��I�L�>��I�I�:�Y�F�G��M��I�I�7�)�C�D��rAc�:�|j|j|�Sr`)�_Device__writeChannelr��r>r�s  r?�
writePrintzDevice.writePrint�����"�"�4�>�>�4�8�8rAc�:�|j|j|�Sr`)r<r�r=s  r?�
writePCardzDevice.writePCard�r?rAc�:�|j|j|�Sr`)r<r�r=s  r?�writeFaxzDevice.writeFax�����"�"�4�<�<��6�6rAc�:�|j|j|�Sr`)r<r�r=s  r?�writeEWSzDevice.writeEWS�rDrAc�:�|j|j|�Sr`)r<rr=s  r?�
writeEWS_LEDMzDevice.writeEWS_LEDM�s���"�"�4�#4�#4�d�;�;rAc�:�|j|j|�Sr`)r<rr=s  r?�	writeLEDMzDevice.writeLEDM�s���"�"�4�=�=�$�7�7rAc�:�|j|j|�Sr`)r<r	r=s  r?�writeMarvell_EWSzDevice.writeMarvell_EWS�����"�"�4�#7�#7��>�>rAc�:�|j|j|�Sr`)r<r*r=s  r?�writeCfgDownloadzDevice.writeCfgDownload�rMrAc�:�|j|j|�Sr`)r<r/r=s  r?�writeSoapFaxzDevice.writeSoapFax�s���"�"�4�#3�#3�T�:�:rAc��t|t�st|d�r|j�}|j	|j
|�S)N�tobytes)�
isinstance�bytes�hasattrrSr<r2r=s  r?�writeMarvellFaxzDevice.writeMarvellFax�s9���$��&�7�4��+C��<�<�>�D��"�"�4�#6�#6��=�=rAc�:�|j|j|�Sr`)r<rr=s  r?�writeWifiConfigzDevice.writeWifiConfig�s���"�"�4�#6�#6��=�=rAc�N�|�}|dt|�}}}tjd|||jfz�t|�dkDr�tj|j||dtj�\}}tjd|z�|tjk7r$tjd�tt��|tjd}||z
}|j�|j�t|�dkDr��||k7rtt��|S)Nrz0Writing %d bytes to channel %d (device-id=%d)...r3zChannel write error)
r�rCrDr�r�
write_channelrj�max_message_lenr�r�r�rpr�)	r>r6r�r�r8�	bytes_out�total_bytes_to_writer�r|s	         r?�__writeChannelzDevice.__writeChannel�s���X�
�26��3�t�9�/�	���	�	�D�H\�^h�jn�jx�jx�Gy�y�z��&�k�A�o��&�&�t�~�~�z��0�D�0�0�1�3�
'�K��
�I�I�&��4�5��h�1�1�1��	�	�/�0��1�2�2��D�0�0�1�2�F���&�I��}�}�(��
�
���&�k�A�o�" �9�,��-�.�.��rAc
���|dk(rtj}ntj}|tjdddt	j
|d||d���}|j
||d��y)Nr�&r�WrT)r��raw)r�buildEmbeddedPML2�buildEmbeddedPML�buildPCLCmdr�buildEmbeddedPMLSetPacketr�)r>r�rA�styler�r%r�s       r?�writeEmbeddedPMLzDevice.writeEmbeddedPML�sl���A�:��(�(�D��'�'�D��C�O�O�C��c��2�2�3�q�6�49�47��F�<�=�>��	
���t�F���5rAc���|jjdt�}d||jt	|�|fz}t
j
|�|tk(r�t
jd|z�|j|�t�}|j|j|�|j�}t
j
|�|j�n�|tk(r�t
jd|z�|j!|�t�}|j|j"|�|j�}t
j
|�|j%�nt
j'd|z�t(j+t-��}|�t.S	t1|j3d��}|t.k(S#t4t6f$rt8}Y|t.k(SwxYw)NrBz{POST %s HTTP/1.1
Connection: Keep-alive
User-agent: hplip/2.0
Host: %s
Content-type: text/xml
Content-length: %d

%szstatus-type: %dzNot an LEDM status-type: %dr)r�r�rCr�r�rCr�r�rDrHrr/rr#rr�rJrr r��http_result_patrr�HTTP_OKr4r�r=rK�
HTTP_ERROR)r>�url�postrbr��responserr�s        r?rozDevice.post	s����g�g�k�k�-�1A�B���

�d�n�n�c�$�i��.�/��	���T���*�*��I�I�'�+�5�6����t�$��y�H����d�/�/��:��(�(�*�H��L�L��"���� �
�4�
4��I�I�'�+�5�6��N�N�4� ��y�H����d�m�m�X�6��(�(�*�H��L�L��"��N�N��
�I�I�3�k�A�B��%�%�n�X�&>�?���=��.�	��u�{�{�1�~�&�D��w�����I�&�	��D��w���	�s�-G�G0�/G0c�,�|j|||||�Sr`)�	printFile)r>�	file_namer3r�rc�removes      r?�
printGzipFilezDevice.printGzipFile1	s���~�~�i��v�s�F�K�KrAc	���	tj|�tj�\}}tj|d�}|j�}|jtd��sAtj||�|j�}|jtd��s�Ag}|j�}|jtd��s<|j|�|j�}|jtd��s�<tj|j |j"|j$|j&|j(|j*|j,d�}|j$dk(rd|d<n
d|d	<d|d
<t.r|D�	cgc]}	|	j1d���}}	|D]$}	tj|t|	|z���&tj||j3��|j5�tj4|�|j7||ddd
��y#t$rtj	d|z�YywxYwcc}	w)NzFile not found: %sr�z	%PY_BEGINz%PY_END)�VERSIONr/r��BUSr0�IP�PORT�DEVNODEr%zn/ar{ryrzrGFT)r�rcrt)rM�statrOrCr�r
�make_temp_file�gzipr��readliner7rrNrXrj�versionr�r2r�r�r�r�r�rr��readr�rr)
r>�
print_filer3�temp_file_fd�temp_file_namerTr�	sub_lines�SUBS�ss
          r?�printParsedGzipPostscriptz Device.printParsedGzipPostscript4	s���	��G�G�J��
(-�';�';�'=�$��n��I�I�j�#�&��
�J�J�L���,�,�}�[�9�:��H�H�\�1�%��
�
��A��,�,�}�[�9�:��	�
�J�J�L���,�,�}�Y�7�8����Q���
�
��A��,�,�}�Y�7�8�!�L�L�!�]�]�!�_�_�!�X�X�!�[�[�!�Y�Y�!�Y�Y�!�]�]����8�8�u��#�D��O��D��J� �D��L��4=�>�q����'�*�>�I�>��	>�A��H�H�\�=�!�d�(�#<�=�	>�	����q�v�v�x�(�	���	�
��������~�|�E�u�UY��Z��]�	��I�I�*�Z�7�8��	��F?s�I�I)�!I&�%I&c�x�tjj|�dj�dk(}|�|j}|stt��tjd|�d|�d|�d|�d|�d|�d	�
�|r`|r4|jtj|d
�j��y|jt|d
�j��ytjd�sjd}|rd
}|rd|�d|�d|��}nd|�d|�d|��}tj |�}	|	dk7rtj#d|	z�|rtj$|�yyd\}
}|rd}
|rd}|rd|�d|
�d|�d|��}nd|�d|
�d|�d|��}tj |�}	|	dk7rtj#d|	z�yy)Nr�z.gzzPrinting file 'z' to queue 'z' (gzip=z	, direct=z, raw=z	, remove=�)r��lprr.z-orawz
gunzip -c z | lp -c -dr�zlp -c -drz'Print command failed with exit code %d!r�z-o rawz-rz | lpr z -Pzlpr -P)rMr��splitextr�r�r��$ERROR_NO_CUPS_QUEUE_FOUND_FOR_DEVICErCrDr>r~r�r�r
r�r�executer�rt)r>rsr3r�rcrt�is_gzip�lp_optr��	exit_code�raw_str�rem_strs            r?rrzDevice.printFileh	s����'�'�"�"�9�-�b�1�7�7�9�U�B�����2�2�L���@�A�A��	�	��|�W�f�c�6�K�	L�������	�	�)�S� 9� >� >� @�A�����Y�� 4� 9� 9� ;�<��;�;�u�%����$�F��:C�\�SY�Z�A��/;�F�I�N�A�$�,�,�Q�/�	���>��I�I�G�)�S�T���I�I�i�(��$*� ����(���T�7��;D�g�w�Xd�e�A��0<�W�g�y�Y�A�$�,�,�Q�/�	���>��I�I�G�)�S�T�"rAc��|jtjjtj
ddd�|�S)Nr��psztestpage.ps.gz)r�rMr�r�rjr�)r>r3s  r?�
printTestPagezDevice.printTestPage�	s8���-�-�b�g�g�l�l�D�M�M�6�.2�4D�/G�HT�V�	VrAc���|r|j|�ytj�\}}tj||�tj
|�|j
||d|d��y)NFT)rt)r>r
r}rMrNr�rr)r>r�r3r�rcr�r�s       r?r�zDevice.printData�	sT����O�O�D�!�+0�+?�+?�+A�(�L�.��H�H�\�4�(��H�H�\�"��N�N�>�<���D�N�QrAc�z�tj|�t|_|j	|j�yr`)r�	cancelJob�STATUS_PRINTER_CANCELINGr�r�)r>�jobids  r?r�zDevice.cancelJob�	s%�����u��2������t���'rAc�P�g}|jr�	|jj|j�\}}|j�|D]"}|jtt|����$	|dj|_t"j%|jt&�|_nt |_t&|_||_|S#tj
j$r!}tjd�gcYd}~Sd}~wwxYw#t$rt |_Y��wxYw)Nz!dbus call to GetHistory() failed.r)rVr��
GetHistoryr2r�r�r�rCr��reverserXr-�tupler5r�r6r�rtr�r�r�r�)r>�resultr2�historyr��hs      r?�queryHistoryzDevice.queryHistory�	s������?�?�
�&*�l�l�&=�&=�d�o�o�&N�#�
�G�

�O�O���
0���
�
�e�U�1�X�.�/�
0�
1�"(��)�"6�"6��� 9�<�<�T�_�_�N_�`�D��-�D�O�0�D����	��
��+�?�?�0�0�
��	�	�=�>��	��
���
1�"0���
1�s/�(C
�0D�
D�*D�D�D�D%�$D%c��	|jr$|jjdd��d|��}|}n[d|j�|��}|jr<t
j
|j�\}}|t
jk(rd|�|��}d}tjd|z�ti�}	|j||�}	|j|jj��|j�|j)�y#|j�wxYw#t $r<tj#d|z�|j%d�|j'�Y�jwxYw#|j)�wxYw)Nr�r��&loc=zhttp://zOpening: %s�Status read failed: %sr)r�r2r�r�r�rr�r�rCrD�LocalOpenerr�rN�fpr�r�r�r��seek�truncater)	r>rnr�url2r�r
rr6rTs	         r?�	getEWSUrlzDevice.getEWSUrl�	s0��	��}�}�&*�o�o�&=�&=�h��&N�PS�T�����)-�	�	�3�7���7�7�!)�!;�!;�D�G�G�!D�J�F�B���!4�!4�4�02�C�8�����I�I�m�d�*�+� ��_�F�
��K�K��d�+����L�L�������-��G�G�I�
�M�M�O���G�G�I���
"��	�	�2�T�9�:����A�����!�
"��
�M�M�O�sC�B.E+�1D#�)D�-E+�D � E+�#AE(�%E+�'E(�(E+�+E=c��	|jjdd��d|��}|}ti�}	|r#|j|||�|j	�S|j||�|j	�S#t
$rtjd|z�YnwxYw	|j	�y#|j	�wxYw�Nr�r�r�r�)r2r��LocalOpenerEWS_LEDM�open_hprr�rCrD�r>rnr�footerr�r�r6s       r?r�zDevice.getEWSUrl_LEDM�	s���	!�"&�/�/�"9�"9�(�E�"J�C�P�D��D�(��,�F�
;��!�>�>�$��f�=�
��� �	"�>�>�$��5�
��� ���
;��	�	�2�T�9�:�
;��:���� ��D��� ��.�.B1�A8�A8�8!B�B1�B�B1�1Cc��	|jjdd��d|��}|}ti�}	|r#|j|||�|j	�S|j||�|j	�S#t
$rtjd|z�YnwxYw	|j	�y#|j	�wxYwr�)r2r��LocalOpener_LEDMr�r r�rCrDr�s       r?r�zDevice.getUrl_LEDM
s���
	�"&�/�/�"9�"9�(�E�"J�C�P�D��D�%�b�)�F�
;��!�>�>�$��f�=�
�N�N��"�>�>�$��5�

�N�N���	�
;��	�	�2�T�9�:�
;��:�
�N�N���D�N�N��r�c��	d}|jjdd��d|��}|}ti�}	|r#|j|||�|j	�S|j||�|j	�S#t
$rtjd|z�YnwxYw	|j	�y#|j	�wxYw)Nz/cdm/supply/v1/suppliesPublicr�r�r�r�)r2r��LocalOpener_CDMr�r r�rCrDr�s       r?r�zDevice.getUrl_CDM
s���
	�/�C�"&�/�/�"9�"9�(�E�"J�C�P�D��D�$�R�(�F�
;��!�>�>�$��f�=�
�N�N��	"�>�>�$��5�
�N�N����
;��	�	�2�T�9�:�
;��:��N�N���D�N�N��s.�0B3�A:�A:�:!B�B3�B�B3�3Cc���t�}|r|j|||�}n|j||�}|r5|jtd�d�d}|rt	j
|�}|S�N�

r)rr�r4rr
�ExtractXMLData�r>rnr��data_fpr�s     r?�FetchLEDMUrlzDevice.FetchLEDMUrl 
sg���)����#�#�C��&�9�D��#�#�C��1�D���:�:�m�J�7��;�A�>�D���,�,�T�2���rAc���t�}|r|j|||�}n|j||�}|r5|jtd�d�d}|rt	j
|�}|Sr�)rr�r4rr
r�r�s     r?�FetchEWS_LEDMUrlzDevice.FetchEWS_LEDMUrl.
sg���)����&�&�s�G�V�<�D��&�&�s�G�4�D���:�:�m�J�7��;�A�>�D���,�,�T�2���rAc���t�}|j|�}|stjd�yt	j
�j
|�}	||S#td�cYSxYw�Nz'Unable To read the XML data from devicer.)rr�rCr�r
�XMLToDictParser�parseXMLr<�r>r��	attributerr��xmlDicts      r?�readAttributeFromXml_EWSzDevice.readAttributeFromXml_EWS:
se������$�$�S�)����I�I�?�@���'�'�)�2�2�4�8��	��9�%�%��	��r�7�N���A�
A,c���t�}|j|�}|stjd�yt	j
�j
|�}	||S#td�cYSxYwr�)rr�rCr�r
r�r�r<r�s      r?�readAttributeFromXmlzDevice.readAttributeFromXmlI
se������ � ��%����I�I�?�@���'�'�)�2�2�4�9��	��9�%�%��	��r�7�N�r�c��d}tjjtjd|j
j
�dz�}tj|�tjj|�r�tjd|z�		|j'�|j)tj|�j��}	tjdt+j,|	�z�|j/�d}tjd�|Stj%d	|z�|S#t0$r-}tj%d|j2z�Yd}~|Sd}~wwxYw)
NF�firmwarez.fw.gzz!Downloading firmware file '%s'...T�OKzAn error occured: %sz%s bytes downloaded.zFirmware file '%s' not found.)rMr�r�rj�data_dirr�r�rCrDr�r��O_RDWRr~r�rNr�rO�IOErrorr�r�r>r
�commafyrr�r])
r>r��
usb_device_idr�filenamerrTrr�r|s
          r?�downloadFirmwarezDevice.downloadFirmwareV
s��
���7�7�<�<��
�
�z�4�:�:�;K�;K�;M�PX�;X�Y���	�	�(��
�7�7�>�>�(�#��I�I�9�H�D�E��>��N�N�$�$(�O�O�D�I�I�h�4G�4L�4L�4N�$O�M��I�I�4�u�}�}�]�7S�S�T��O�O�%��B��I�I�d�O��	�
�I�I�5��@�A��	���>��I�I�4�q�u�u�<�=�=��	��>�s�BE�	F�"E<�<F)NNNF)r.rr.�F)FF�T)rG)rT)NFTFr`)NTT�r.)NN)frgrhrir@r�r�r�r�r�r�r�r�r�r�r�r�rrr	rr
rrrrrrr r"r%r'r*r,r/r2r4r6r8r�r=r�r�rGrJrZrdr�r�r�r�r�r�INT_SIZE_INTrDr�r]rj�read_timeoutr	rrrrrrrrrr r/r1rr>rArCrFrHrJrLrOrQrWrYr<rirorur�rrr�r�r�r�r�r�r�r�r�r�r�r�r�rkrAr?r�r��s���04�;@�L�b>�
�?�&�3&�l
.� �>0�B�E�H�@�E�>�H�C�I�F�@�A�A�A�F�?�I�J�K�L�M�=�H�>�I�B�0�1��0�6
�D�
,�L,�^S�n)�,p�fI�M�,/�+;�+;�/�,�$5A�p/3�D�<M�<M�`e�d�/3�D�<M�<M�`e�d�-1�$�:K�:K�^c�b�37��@Q�@Q�di�h�-1�$�:K�:K�^b�b�26�t�?P�?P�cg�g�.2�4�;L�;L�_c�c�59�$�BS�BS�fj�j�15�d�>O�>O�bf�f�48��AR�AR�ei�i�48��AR�AR�ei�i��@	�;?�"�/�/�%�8�v9�9�7�7�<�8�?�?�;�>�
>��8
6�+�ZL�2[�h3U�lV�
R�(��:�@
!�� � 
�
��
�#rAr�c��eZdZd�Zy)r�c���tjd|z�tj|�}|j	d�xsd}|j	d�xsd}|j	d�xsd}|j	d�xsd}|j	d�xsd}|j�|j
d|z�t�}	|jd	|	d�
�r	|jd	|	d�
�r�|	jd�tj|	j��tj|	�}
|
j�|
jtj k7rt#t$��|
S)N�open_hp(%s)rr.r�r�r�r�zBGET %s HTTP/1.0
Content-Length:0
Host:localhost
User-Agent:hplip

r)rr)rCrD�http_pat_urlr�r�r�rFrrr�r�r#r�HTTPResponse�beginr
r�r��!ERROR_DEVICE_STATUS_NOT_AVAILABLE)r>rnrr�r�r�r��device�locr&rps           r?r�zLocalOpener.open_hp�
s)���	�	�-�#�%�&� �'�'��,�	��o�o�a� �&�B������"�(�b������#�)�r������#�)�r���o�o�a� �&�B�����
����b�eh�h�i�����k�k�$��q�k�1���k�k�$��q�k�1�	�
�
�1�
����U�^�^�%�&��+�+�E�2�������?�?�k�n�n�,��9�:�:��OrAN�rgrhrir�rkrAr?r�r��
s��rAr�c��eZdZdd�Zy)r�c��tjd|z�tj|�}|j	d�|jd�}|j
�|rOd|vr|jd|z�nJ|jd|�dt|��d��|jd|z�n|jd|z�t�}|j|j|�|jd	�|j�S�
Nr��=�PUTz%szPOST z1 HTTP/1.1
Content-Type:text/xml
Content-Length:z?
Accept-Encoding: UTF-8
Host:localhost
User-Agent:hplip

 zIGET %s HTTP/1.1
Accept: text/plain
Host:localhost
User-Agent:hplip

r)rCrDr�r�r4�countrrHr�rr/rr�r#�r>rnr�footr�r�r&s       r?r�zLocalOpenerEWS_LEDM.open_hp�
s����	�	�-�#�%�&� �'�'��,�	��i�i��n�S�Y�Y�s�^�,���������}��!�!�(�T�/�2��!�!�tw�y|�}A�yB�#C�D��!�!�(�T�/�2����w�z}�}�~��������)�)�%�0�
�
�
�1�
��~�~��rANr�r�rkrAr?r�r��
s�� rAr�c��eZdZdd�Zy)r�c��tjd|z�tj|�}|j	d�|jd�}|j
�|rOd|vr|jd|z�nJ|jd|�dt|��d��|jd|z�n|jd|z�t�}|j|j|�|jd	�|j�Sr�)rCrDr�r�r4r�rrJr�rr/rr�r#r�s       r?r�zLocalOpener_LEDM.open_hp�
s����	�	�-�#�%�&� �'�'��,�	��i�i��n�S�Y�Y�s�^�,���������}��
�
�h��o�.��
�
�ps�ux�y}�u~��@��
�
�h��o�.��M�M�s�vy�y�z����	������e�,�
�
�
�1�
��~�~��rANr�r�rkrAr?r�r��
s�� rAr�c��eZdZdd�Zy)r�c��tjd|z�tj|�}|j	d�|jd�}|j
�|jd|�dt|��d��t�}|j|j|�|jd�tj|�}|j�|j!�}|j#�}	|	S)Nr�r�zGET z� HTTP/1.1
Content-Type: application/json
User-Agent: hplip
Accept: */*
Cache-Control: no-cache
Host:localhost
Connection: keep-alive
Content-Length: r�r)rCrDr�r�r4r�rrHr�rr/rr�rr�r��getcoder�)
r>rnrr�r�r�r&rp�respcoder�s
          r?r�zLocalOpener_CDM.open_hp�
s����	�	�-�#�%�&� �'�'��,�	��i�i��n�S�Y�Y�s�^�,���������]`�ad�eh�ai�j�	k��������)�)�%�0�
�
�
�1�
��+�+�E�2�������#�#�%���}�}����rANr�r�rkrAr?r�r��
s��
rAr�r`)rr�r�)�r�r�r~�os.pathrMr;�sixext.movesrrr�iorrrH�string�g�codesr.r
rrr
r�prntrrrrrrr�strings�sixextrrrrrrr��Irkrlrm�
import_extr�HPMUD_BUFFER_SIZE�
MAX_BUFFER�AttributeError�ImportError�getenvrCr��sys�exitrVr�r�r r!r��warnings�simplefilter�DeprecationWarning�DEFAULT_PROBE_BUSr�rX�DEFAULT_FILTERr]�DEFAULT_BE_FILTERr�rJr�r�r��	ModelDatar�r�r�r��objectr-rmrxr�r�r�r�r�r#r&r(r+r�rBr�rNrPr�r[r^�AGENT_TYPE_NONE�AGENT_TYPE_BLACK�AGENT_TYPE_BLACK_B8800�AGENT_TYPE_CMY�AGENT_TYPE_KCM�AGENT_TYPE_CYAN�AGENT_TYPE_MAGENTA�AGENT_TYPE_YELLOW�AGENT_TYPE_CYAN_LOW�AGENT_TYPE_MAGENTA_LOW�AGENT_TYPE_YELLOW_LOW�AGENT_TYPE_GGK�AGENT_TYPE_BLUE�AGENT_TYPE_KCMY_CM�AGENT_TYPE_LC_LM�AGENT_TYPE_LG_PK�
AGENT_TYPE_LG�AGENT_TYPE_G�
AGENT_TYPE_PG�AGENT_TYPE_C_M�AGENT_TYPE_K_Y�AGENT_TYPE_PHOTO_BLACK�AGENT_TYPE_MATTE_BLACK�AGENT_TYPE_UNSPECIFIEDr��AGENT_KIND_NONEr��AGENT_KIND_SUPPLY�AGENT_KIND_HEAD_AND_SUPPLY�AGENT_KIND_TONER_CARTRIDGE�AGENT_KIND_MAINT_KIT�AGENT_KIND_ADF_KIT�AGENT_KIND_DRUM_KIT�AGENT_KIND_TRANSFER_KIT�AGENT_KIND_INT_BATTERY�AGENT_KIND_UNKNOWNr�r�r��AGENT_HEALTH_INCORRECT�AGENT_HEALTH_FAILED�AGENT_HEALTH_OVERTEMP�AGENT_HEALTH_CHARGING�AGENT_HEALTH_DISCHARGING�AGENT_HEALTH_UNKNOWNr�r�r�r�r��string_cacher��	URLopenerr�r�r�r�rkrAr?�<module>r7s���.�	����D�D�	��%�
�
������������&�&��^�^��"�*�*�5�r�t�t�<��

��
�
��
�U�
�
�j�
)�H���/�/�
��
��
�+��)��J������h� 2�3�+��+��+����9�
�����
�
�h�jl�jw�jw�x�
��r�z�z�W�Y[�Yf�Yf�g��
�R�Z�Z�?����
O�
��"�*�*�0�"�-�-�@��
�F����	�	����x�z|�{H�{H�
I��
�"�*�*�^�R�]�]�
3��
�"�*�*�'����
7��BD�F�BD�J�u��2!�E�!�8L-�fB'�R�
(�'���~�r�e�!(�t�t.2�F�>�,�^/3�V�N��D37���&�
�8
�F
�((I�V-����	����� ���&��������	�
 ���#��
�"���$���'���&������ ���#���!�)G��"!�)E�#�$��%�&�����);��);�&��&��&��3��8�I��V�!�X�*�[�*�W�$�[�"�Y�#�Z�'�^�&�Y�"�Y���!�T�+�n�(�k�%�h�'�j�'�j�*�m�&�i�	�
�/��1�E�:�U�����g�V�g�^5�.�*�*��< �.�2�2� �4 �~�/�/� �6�n�.�.���iT���
������2�9�9�]�#��	�	�R�S���������"�+��H�H�
)�*�+�s6�6M�	L3�N�3L>�=L>�9M>�=M>�N�N

Zerion Mini Shell 1.0