%PDF- %PDF-
Mini Shell

Mini Shell

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

�

=	fQ����dZdZdZdZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZddl�ddl�ddlmZmZmZmZmZmZmZdd	lmZdd
lmZ	ddlmZmZmZddl Zddl!m"Z"er	dd
l#m$Z$m%Z%m&Z&m'Z'm(Z(ndd
l*m$Z$m%Z%m&Z&m'Z'm(Z(dZ+ddl0Z0e0jbde2�dZ3d\a4a5da6da7d\a8a9a:iZ;Gd�de<�Z=Gd�dej|j~�Z@d�ZAd�ZBd�ZCd�ZDd�ZEd�ZFd �ZGd*d!�ZHd"�ZId*d#�ZJd$�ZKd*d%�ZLd&�ZMd'�ZNd(�ZO			dd)�ZPy#dd
l)m$Z$m%Z%m&Z&m'Z'm(Z(Y��xYw#e,$r(e-j]d�dZ+ej^d�Y��wxYw)+z12.0z9Services and Status System Tray dBus Child/Parent Process�hpssdz�Provides persistent data and event services to HPLIP client applications. Required to be running for PC send fax, optional in all other cases.�N)�loads�HIGHEST_PROTOCOL)�*)�utils�device�status�models�module�services�os_utils)�PY3)�
to_bytes_utf8)�lowlevel�	SystemBus�
SessionBus)�
DBusGMainLoop)�MainLoop�timeout_add�threads_init�io_add_watch�IO_INTzAdbus failed to load (python-dbus ver. 0.80+ required). Exiting...F��ignorei)NN)NNNc��eZdZdd�Zy)�DeviceCachec���tjtj�|_tj|�|_i|_i|_	i|_
d|_d|_d|_
y)NrF)r�
RingBuffer�prop�history_size�historyr
�normalizeModelName�model�cache�faxes�dq�backoff_counter�backoff_countdown�polling)�selfr#s  �/usr/share/hplip/hpssd.py�__init__zDeviceCache.__init__XsX���'�'��(9�(9�:����.�.�u�5��
���
���
���� ���!"������N)�)�__name__�
__module__�__qualname__r,�r-r+rrWs��	r-rc�Z�eZdZd�Zej
j
ddd��d��Zej
j
ddd��d��Zej
j
dd	d
��d��Z	ej
j
ddd
��d
��Z
ej
j
ddd��d��Zej
j
ddd��d��Zej
j
dd	d��dd��Z
d�Zej
j
ddd��d��Zy)�
StatusServicec�Z�tjjj|||�y�N)�dbus�service�Objectr,)r*�name�object_paths   r+r,zStatusService.__init__fs�������$�$�T�4��=r-�com.hplip.StatusService�szsa(ssisisd))�in_signature�
out_signaturec��tjd|z�t�	t|t|jj�}tjdt
|�z�|D�cgc]}|j���c}||D�cgc]}|j���c}fScc}wcc}w#t$r|gfcYSwxYw)NzGetHistory('%s')z%d events in history:)	�log�debug�send_systray_blip�devicesr!�get�len�as_tuple�KeyError)r*�
device_uri�h�xs    r+�
GetHistoryzStatusService.GetHistoryjs����	�	�$�z�1�2���		;��J��
�
�#�+�+�/�/�1�A��I�I�-��A��6�7� !�"�1�Q�W�W�Y�"��q� 9�!����� 9�:�:��
#�� 9���	$���#�#�	$�s�	B7�3B-�B2�7
C�Czsa{ss}c
�l�tjd|z�t�	t|i}t|j}t|j
��D�cgc] }|j|t||����"c}tj|�||fScc}w#t$r|ifcYSwxYw)NzGetStatus('%s'))
rArBrCrDr&�list�keys�
setdefault�strrH)r*rI�tr&rKs     r+�	GetStatuszStatusService.GetStatuszs����	�	�#�j�0�1���
	#��J��
�A���$�'�'�B�26�r�w�w�y�/�B�Q�Q�\�\�!�S��A��Z�
(�B��I�I�a�L���?�"��
C��
�	$���#�#�	$�s�	B#�%B�#
B3�2B3�ssi�ic��tjd|||fz�t|�tk(r|t|j
|<|Sy)Nz!SetCachedIntValue('%s', '%s', %d)����rArB�check_device�
ERROR_SUCCESSrDr$�r*rI�key�values    r+�SetCachedIntValuezStatusService.SetCachedIntValue�sE���	�	�5��S�%�8P�P�Q��
�#�}�4�-2�G�J��%�%�c�*��L�r-�ssc��	t|j|}tj	d|||fz�|S#t$rd}Y�*wxYw)NrWz$GetCachedIntValue('%s', '%s') --> %d�rDr$rHrArB�r*rIr\�rets    r+�GetCachedIntValuezStatusService.GetCachedIntValue�sR��	��*�%�+�+�C�0�C�	�	�	�8�J��S�;Q�Q�R��
��	�	��C�	�s�5�A�A�sssc	��tjd|�d|�d|�d��t|�tk(r|t|j
|<|Sy)NzSetCachedStrValue('�', 'z')r.rXr[s    r+�SetCachedStrValuezStatusService.SetCachedStrValue�s?���	�	�:�s�E�R�S��
�#�}�4�-2�G�J��%�%�c�*��L�r-c��	t|j|}tj	d|�d|�d|���|S#t$rd}Y�-wxYw)Nr.zGetCachedStrValue('rgz') --> rarbs    r+�GetCachedStrValuezStatusService.GetCachedStrValue�sL��	��*�%�+�+�C�0�C�	�	�	�J��S�Q�R��
��	�	��C�	�s�8�A�A�ssisisdsc��tjd|||fz�t�|dd||dddf}t|�t	|�|r,	t
|j||f|j|||�Stt
|jj��D]\}}||k(s�|j|||�cS|S#t$r|cYSwxYw)Nz"CheckForWaitingFax('%s', '%s', %d)r.r�)rArBrCrY�show_waiting_faxesrDr%�check_for_waiting_fax_returnrHrNrO)r*rI�username�job_id�r�u�js       r+�CheckForWaitingFaxz StatusService.CheckForWaitingFax�s����	�	�6�*�h�PV�9W�W�X���
��Q��&�"�c�2�>���Z� ��:�&��
W��
�#�)�)�8�V�*<�=��8�8��X�v�V�V��W�Z�0�6�6�;�;�=�>�
O���1���=��<�<�Z��A�N�N�
O��H���
���
�s�	C�C�Cc���tjd||fz�t|j||fj	�}t|j||f=t|�|S)NzFFax (username=%s, jobid=%d) removed from faxes and returned to caller.)rArBrDr%rGrn)r*�drsrtrrs     r+roz*StatusService.check_for_waiting_fax_return�s_���	�	�Z�^_�ab�]c�c�d��A�J���a��V�$�-�-�/���A�J���a��V�$��1���r-�ssisisr.c�N�tj||||||�}t|�yr6�r�Event�handle_event)r*rI�printer_name�
event_coderprq�title�events        r+�	SendEventzStatusService.SendEvent�s#�����Z��z�8�V�UZ�[���U�r-N)r)r/r0r1r,r7r8�methodrLrSr^rdrhrjruror�r2r-r+r4r4est��>�
�\�\���2��Ta��b�;�c�;�
�\�\���2��T\��]�
#�^�
#� 
�\�\���2��VY��Z��[��
�\�\���2��UX��Y��Z��
�\�\���2��VY��Z��[��
�\�\���2��UX��Y��Z��
�\�\���2��V`��a��b��0�
�\�\���2��Y[��\��]�r-r4c
�`�tst|�}	t|tS#t$r�tjd|z�	t
j|�\	}}}}}}}}}	n/#t$r#tjd|z�tcYcYSwxYwt|�t|<YtSwxYw)NzNew device: %szInvalid device URI: %s)rrQrDrHrArBr�parseDeviceURI�Error�ERROR_INVALID_DEVICE_URIrrZ)
rI�back_end�is_hp�busr#�serial�dev_file�host�zc�ports
          r+rYrY�s������_�
�1��
������	1��	�	�"�Z�/�0�	,��%�%�j�1�
J�H�e�S�%���4��T���	,��I�I�.��;�<�+�+�	,��*�%�0��
����	1�s3�	"�!B-�A$�#B-�$'B�B-�B�B-�,B-c�r�t|jjj�}|r^|dj|jk(rBt
j
d�t|jjj|�yt|jjj|�y)NrWz*Duplicate event. Replacing previous event.TF)	rDrIr!rEr~rArB�replace�append)r�r!s  r+�create_historyr��s����e�&�&�'�/�/�3�3�5�G��7�2�;�)�)�U�-=�-=�=��	�	�>�?��� � �!�)�)�1�1�%�8���� � �!�)�)�0�0��7�r-c�:�|jtk(�rb|jtjk(�rDt	j
d��\}}t
j|tj�}d}	t
j|t�}|sn%t
j||�|t|�z
}�Btjd||fz�t
j|�t
j|�t!j"||�t$|j&j(|j|j*f<t-|j&�	t
j.dtj0�t5j6d|j8zd�\}}|r�t5j:|�t5j<d�}	|	r!tj>jA|	d�}	ntjCd	�ytjd
|	�d|j8���t
jDtjF|	dd|j8z�ytjd
�ytjId�y#t2$rY��wxYw)Nzhpfax-)�prefixrTzSaved %d bytes to file %srWz
hp-sendfax-%sz
hp-sendfaxz"Unable to find hp-sendfax on PATH.zRunning hp-sendfax: z --printer=z--printer=%sz=hp-sendfax is running. Waiting for CheckForWaitingFax() call.zNot handled!)%r~�EVENT_FAX_RENDER_COMPLETErpr�tempfile�mkstemp�os�open�O_RDONLY�read�PIPE_BUF�writerFrArB�closer�FaxEventrDrIr%rqrn�waitpid�WNOHANG�OSErrorr�lock_appr}�unlock�which�path�join�error�spawnlp�P_NOWAIT�warn)
r��	pipe_name�fax_file_fd�
fax_file_name�pipe�
bytes_read�data�ok�	lock_filer�s
          r+�handle_fax_eventr�s������4�4�
���$�-�-�'�%-�%5�%5�X�%F�"��]��w�w�y�"�+�+�.���
���7�7�4��*�D����H�H�[�$�'��#�d�)�#�J�
�	�	�	�-��]�0K�K�L�
�����
�����
�O�O�M�5�1�	�� � �!�'�'�������(F�G�	�5�+�+�,�	��J�J�r�2�:�:�&�
�����9K�9K�'K�T�R�
��I�
��L�L��#��;�;�|�,�D���w�w�|�|�D�,�7���	�	�>�?���I�I�t�U�EW�EW�X�Y��J�J�r�{�{�D�,���!3�!3�3�
5�
�I�I�U�V�	���� ���9�	��	�s�$J
�
	J�Jc�R�t|j}t|�stj	d|z�yt|�dk(rtj	d|z�n#tj	dt|�|fz�|D�cgc]}||j	���c}ycc}w)NzNo faxes waiting for %srz1 fax waiting for %s:z%d faxes waiting for %s:)rDr%rFrArB)rw�frKs   r+rnrn;s|����
���A��q�6��	�	�+�a�/�0��q�6�Q�;��I�I�-��1�2��I�I�0�C��F�A�;�>�?� �!�!��1�����!��!s�B$c
���tjd|z�dtd�}}	tjtggtgd�\}}}|snRtjtt�}|sn1td�j||g�}|t|�z
}||k(rn�{tjd|z�||k(r�t|�}t|j�tk(r�|j�t|j_t#t%j&|jd|j)dt*�t,j.dd��t1|t2�yyy)Nz#Reading %d bytes from hpdio pipe...rr.rmz
Read %d byteszstatus-code)rArBr�select�r3r�r�r�r�rFrrYrIrZ�copyrDr&r|rr{rE�STATUS_PRINTER_IDLErrp�send_toolbox_event�EVENT_DEVICE_UPDATE_REPLY)	r��
bytes_written�
total_readr�rr�w�erKr&s	         r+�handle_hpdio_eventr�Js2���I�I�3�m�C�D��-��+��J�
��-�-���b�2�$��4���1�a��%��G�G�B��!���%��R� �%�%�t�Q�i�0���c�!�f��
���&����I�I�o�
�*�+��]�"�
�4�[����(�(�)�]�:�+-�7�7�9�G�E�$�$�%�(�����e�&6�&6�����}�&9�:�D�M�M�1�b�R�
S�
�u�&?�@�
;�#r-c���tj�}|dk(r�tjd�}|j	�tj
�}ddlm}|j�}|j�tk7rtjd�ntjd�|j�tj |t"j$�ytjd�y)Nrz/tmp/pluginInstall.tmp)�
pluginhandlerzhp-diagnose_pluginzNDevice Plug-in was already installed. Not Invoking Plug-in installation wizardz#Started Plug-in installation wizard)r��forkr�	Sync_Lock�acquire�getpid�	installerr��PluginHandle�	getStatus�PLUGIN_INSTALLEDr
�executerArB�release�kill�signal�SIGKILL)�
child_process�lockObj�	child_pidr��	pluginObjs     r+�handle_plugin_installr�gs����'�'�)�M��q���/�/�":�;�������)�)�+�	�+�!�.�.�0�	���� �$4�4����1�2��I�I�f�g�����
���	�&�.�.�)��	�	�7�8r-c��tjd�}|r!tjj	|d�}nt
j
d�yt
jd|z�tjtj|dd�y)Nzhp-diagnose_queuesz*Unable to find hp-diagnose_queues on PATH.zRunning hp-diagnose_queues: %sz-s)
rr�r�r�r�rAr�rBr�r�)r�s r+�handle_printer_diagnoser�|sb���;�;�+�,�D���w�w�|�|�D�"6�7���	�	�>�?���I�I�.�$�7�8��J�J�r�{�{�D�"6�t�<r-c���	tjdtj�tjd�|�g}|j�|jtk(rt�y|jtk(rt�y|jrt|j�tk7ry|jtkDr$tj |j�|_|jt"kryt"|jcxkr	t$kr�nn�|jr�t'|�}|jt(t*t,t.t0fvrnU|jt2t4t6t8t:t<t>t@tBtDtFtHtJtLfvr	stO|�tQ|tR�|jt<tBtHfvrt�yytT|jcxkr	tVkr5nn2|r0tjd�tY|d�}t[||�y|jt\k(rtO|�y|jt^k(rtO|�y|jt`fvrtc|�y|jtdtffvrtO|�y|jthk(rtk|d�}tm||�y|jtnk(s|jtpk(rtO|�tQ|tR�y|jtrk(rKtc|�tQ|�tO|�tjd�ttjw�y|jt2t(fvrytjyd|jz�y#t$rY���wxYw)NrzHandling event...z	Fax eventr�ExitingzUnhandled event: %d)=r�r�r�r�rArBr~�EVENT_AUTO_CONFIGUREr��EVENT_DIAGNOSE_PRINTQUEUEr�rIrYrZ�EVENT_MAX_EVENTr	�MapPJLErrorCode�EVENT_MIN_USER_EVENT�EVENT_MAX_USER_EVENTr��EVENT_DEVICE_STOP_POLLING�EVENT_START_MAINT_JOB�EVENT_START_COPY_JOB�EVENT_START_FAX_JOB�EVENT_START_PRINT_JOB�EVENT_DEVICE_START_POLLING�EVENT_END_MAINT_JOB�EVENT_END_COPY_JOB�EVENT_END_FAX_JOB�EVENT_END_PRINT_JOB�!EVENT_PRINT_FAILED_MISSING_PLUGIN�EVENT_SCANNER_FAIL�EVENT_END_SCAN_JOB� EVENT_SCAN_FAILED_MISSING_PLUGIN�EVENT_FAX_JOB_FAIL�EVENT_FAX_JOB_CANCELED�EVENT_FAX_FAILED_MISSING_PLUGIN�EVENT_COPY_JOB_FAIL�EVENT_COPY_JOB_CANCELED�send_event_to_systray_uir��EVENT_HISTORY_UPDATE�
EVENT_FAX_MIN�
EVENT_FAX_MAXrQr�� EVENT_USER_CONFIGURATION_CHANGED�EVENT_SYS_CONFIGURATION_CHANGED�EVENT_DEVICE_UPDATE_REQUESTED�send_event_to_hpdio�EVENT_DEVICE_UPDATE_ACTIVE�EVENT_DEVICE_UPDATE_INACTIVEr��intr��EVENT_CUPS_QUEUES_ADDED�EVENT_CUPS_QUEUES_REMOVED�EVENT_SYSTEMTRAY_EXIT�	main_loop�quitr�)r��	more_args�	dup_eventr�r�s     r+r|r|�s0��

�
�
�
�1�b�j�j�!��I�I�!�"����	�	�K�K�M����/�/�������4�4��!�����L��)9�)9�:�m�K��
���/�)�!�1�1�%�2B�2B�C���
���.�.��	��!1�!1�	I�5I�	I����&�u�-�I����$=�$9�$8�$7�$9�	$;�;�
��!�!�&@�&9�&8�&7�&9�&G�&8�&8�&F�&8�&<�&E�&9�&=�
&?�
?���$�U�+�	�5�"6�7���� A�Cc�eD� E�E�!�#�E�
�%�*�*�	;�m�	;�	��	�	�+���	�!��%�	���	�*�	�	�	�=�	=�	!��'�	�	�	�<�	<� ��'�
�	�	�;�=�	=�	�E�"�
�	�	�8�:�<�
<� ��'�
�	�	�6�	6��I�a�L�)�
��5�-�0�
�	�	�4�	4��8H�8H�Le�8e� ��'��5�"6�7�
�	�	�2�	2��E�"��5�!� ��'��	�	�)������	�	�	�8�7�9�
9��	�	�	�'�%�*:�*:�:�;��q�
��
�s�$O�	O#�"O#c�L�ttjddt��y)Nr.)r�rr{�EVENT_DEVICE_UPDATE_BLIPr2r-r+rCrCs���V�\�\�"�b�2J�K�Lr-c�b�|j�}|�||_|jtd�y)N�
systemtray)r�r~�
send_via_pipe�w1�r�r~r�s   r+r�r�s(��
�
�
��A���!����O�O�B��%r-c�0�|jtd�y)N�hpdio)r
�w2)r�s r+r�r�s��	����G�$r-c�b�|j�}|�||_|jtd�y)Nzcom.hplip.Toolbox)r�r~�
send_via_dbus�session_busrs   r+r�r�s+��	�
�
��A���!����O�O�K�!4�5r-c�n�|ddk(r-|ddk(r$tj|dd�}t||dd�Syy)N�	interfacer<�memberr{�rz)�typ�args�kwdsr�s    r+�
handle_signalr(sM���K��5�5��X��'�!����d�2�A�h�'���E�4���8�,�,�	"�6r-c� �tdg|��i|��S)N�system�r�rrs  r+�handle_system_signalr0s����1�D�1�D�1�1r-c� �tdg|��i|��S)N�sessionrrs  r+�handle_session_signalr"4s����2�T�2�T�2�2r-c�V�tjd�tjdtj�z�|||caaatd��a	t�a	tt��a
	tj(�atj/t0ddd
dd��t*j/t2ddd
dd��tj4j7dt*�}t9|d�}tjd�	tj;�y#tjj $r4}tj#d�t%j&d�Yd}~��d}~wwxYw#tjj $rw}tj,�dk7r+tj#d	�t%j&d�n*tj#d
�t%j&d�Yd}~��|d}~wwxYw#t<$rtjd�YywxYw)Nzhp-systray(hpssd)zPID=%dT)�set_as_default)�mainloopz.Unable to connect to dbus system bus. Exiting.rrz/Unable to connect to dbus session bus. Exiting.z8Unable to connect to dbus session bus (running as root?)�sender�destrrr�)�sender_keyword�destination_keyword�interface_keyword�member_keyword�path_keywordr<z/com/hplip/StatusServicezEntering main dbus loop...zCtrl-C: Exiting...)rA�
set_modulerBr�r�rrr�r�	dbus_looprrr�
system_busr7�
exceptions�
DBusExceptionr��sys�exitrr�getuid�add_signal_receiverrr"r8�BusNamer4�run�KeyboardInterrupt)�write_pipe1�write_pipe2�
read_pipe3r��session_name�status_services      r+r7r79s����N�N�&�'��I�I�h�����$�%��k�:�J�B��B��T�2�I��
�I���	�2�
�
��o�o�'���"�"�#7��"�k��f�#�6�
�#�#�$9�(�"�k��f�$�6�
�<�<�'�'�(A�;�O�L�"�<�1K�L�N��I�I�*�+�(��
�
���=�?�?�(�(���	�	�B�C�����������?�?�(�(��
�9�9�;�!���I�I�G�H��H�H�Q�K��I�I�P�Q��H�H�Q�K���
��2�(��	�	�&�'�(�sC�D�/E0�H�E-�9*E(�(E-�0H�
A,G?�?H�H(�'H(r6)Q�__version__�	__title__�__mod__�__doc__r2�structr��time�getoptr�r�r��picklerr�base.g�
base.codes�baserrr	r
rrr
�base.sixextrrr7rrr�dbus.service�dbus.mainloop.glibr�gi._gobjectrrrrr�gi.repository.GLib�gobject�dbus_loaded�ImportErrorrAr�r3�warnings�simplefilter�DeprecationWarningr�r.rr/rrrr�rD�objectrr8r9r4rYr�r�rnr�r�r�r|rCr�r�r�rrr"r7r2r-r+�<module>rUs���.��G�	�
��[���
�	��
�
�
��+���J�J�J��%��4�4��0�
�	d�\�\�	U�T��K������h� 2�3���!��	�9�
�
���
�
��B��
��
�&�
�w�D�L�L�'�'�w�v�(	�7
�t"�A�:9�*	=�<�FM�&�%�6�-�2�3�
���1(��C	d�c�c�����I�I�Q�R��K��C�H�H�Q�K��s*�D1�1D�?D1�D.�,D1�1*E�E

Zerion Mini Shell 1.0