403Webshell
Server IP : 209.205.66.10  /  Your IP : 216.73.216.173
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ammon 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64
User :  ( 1006)
PHP Version : 8.5.8
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/system-config-printer/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/system-config-printer/__pycache__/monitor.cpython-310.pyc
o

3�bq��@sddlZddlZe�d�ddlZddlZddlmZddlmZddlZddl	Tddl
Z
ddlZejej
ejd�ddlZddlZddlmZdZd	Zd
d�Zdd
�ZGdd�dej�Zedkr�Gdd�d�Zed�e�Zee�e��e��Zze��We��dSe��wdS)�Nz1.9.50)�GObject)�GLib)�*)�domain�	localedir)�StateReason�<�cCs:|�d�s|�d�s|�d�s|�d�s|�d�rdSdS)Nzmoving-to-paused�paused�shutdown�stoppingzstopped-partlyTF)�
startswith)�reason�r�+/usr/share/system-config-printer/monitor.py�state_reason_is_harmless's
����rcCs�i}z|��}Wntjy|YSw|��D]+\}}|d}|D] }|dkr+nt|�r0q#||vr8g||<||�t|||��q#q|S)N�printer-state-reasons�none)�getPrinters�cups�IPPError�itemsr�appendr)�
connection�ppdcache�result�printers�name�printer�reasonsrrrr�collect_printer_state_reasons0s$��r c@s�eZdZejjddfejjddfejjdejffejjdejffejjdejffejjdeffejjdeeejejffejjdeeejejffejjdeeejffejjdeffejjdeeejffejjdeffejjddfejjddfejjdeeffd�Z	dZ
dZ			d'dd�Zd	d
�Z
dd�Zd
d�Zdd�Zdd�Zdd�Zifdd�Ze�ifdd�Zdd�Zd(dd�Zdd�Zd)dd �Zd!d"�Zd#d$�Zd%d&�ZdS)*�MonitorNr)�refresh�monitor-exited�state-reason-added�state-reason-removed�still-connecting�
now-connected�	job-added�	job-event�job-removed�
printer-added�
printer-event�printer-removed�cups-connection-error�cups-connection-recovered�cups-ipp-errorz/com/redhat/PrinterSpoolerzcom.redhat.PrinterSpoolerTcCs4tj�|�||_||_||_i|_i|_t�|_d|_	d|_
d|_|r)t�
|�|r0t�|�|r7t�|�t��|_t��|_t��|_t��|_tj|j|j|jd�|_d|_i|_i|_t�|_i|_d|_d|_ |dur�zt!�"�}Wnt!j#j$y�Ynw||_%|dur�|j&|j'|j(|j)d�d|_*dS)NTF��host�port�
encryptionz
not-completed��path�dbus_interface���)+r�__init__�my_jobs�specific_dests�monitor_jobs�jobs�printer_state_reasons�setr�process_pending_events�fetch_jobs_timer�cups_connection_in_errorr�	setServer�setPort�
setEncryption�getUser�user�	getServerr2�getPortr3�
getEncryptionr4r�PPDCache�
which_jobs�reasons_seen�connecting_timers�still_connecting�connecting_to_device�received_any_dbus_signals�update_timer�dbus�	SystemBus�
exceptions�
DBusException�bus�add_signal_receiver�handle_dbus_signal�	DBUS_PATH�
DBUS_IFACE�sub_id)�selfrWr:r;r<r2r3r4rrrr9ksX






���
zMonitor.__init__cC�
|j��S�N)r�copy�r]rrr�get_printers��
zMonitor.get_printerscCr^r_)r=r`rarrr�get_jobs�rczMonitor.get_jobscCs|jSr_)rrarrr�get_ppdcache�szMonitor.get_ppdcachecCs�|jdkr3t��}z t�|j�tj|j|j|jd�}|�	|j�t
d|j�WnYt�|�|jdurD|jj|j
|j|jd�t|j���}|j|jfD]	}|rZ|�|�qQ|D]}t�|�q]|�d�dS)Nr8r1�Canceled subscription %dr5r#)r\rrF�setUserrG�
Connectionr2r3r4�cancelSubscription�
debugprintrW�remove_signal_receiverrYrZr[�listrN�valuesrRrArr�
source_remove�emit)r]rG�c�timers�timerrrr�cleanup�s4
�


�
�zMonitor.cleanupcCs
||_dSr_)r@)r]�whetherrrr�set_process_pending�rczMonitor.set_process_pendingcCs\|jst�d|j|�}||j|<dS||jvr|j|=td|�|��\}}|�|�dS)z8Timer callback to check on connecting-to-device reasons.��Fz%Still-connecting timer fired for `%s')r@r�timeout_add�check_still_connectingrNrj�sort_jobs_by_printer�update_connecting_devices)r]rrr�printer_jobs�my_printersrrrrx�s
�


zMonitor.check_still_connectingcCs�t��}i}d}|j��D]�\}}d}|D]y}|��dkr�d}	|�|i���D]\}
}|�dtj�}|tjkr;d}	nq'|	sCtd�q|�	�}|j
�||�}
|
||<td||
�||
tkr�|	r�||jvrs|j�
|�|�d|�||jvr�t�|j|�|j|=td|�d}nq|r�||jvr�t�|j|�|j|=td|�q
t�}|jD](}||vr�|�
|�|�d	|�||jvr�t�|j|�|j|=td|�q�|j�|�|_||_
d
S)z;Updates connecting_to_device dict and still_connecting set.FT�connecting-to-device�	job-statez%Ignoring stale connecting-to-device xzConnecting time: %dr&z!Stopped connecting timer for `%s'r'N)�timer>r�
get_reason�getr�IPP_JOB_CANCELED�IPP_JOB_PROCESSINGrj�get_printerrP�CONNECTING_TIMEOUTrO�addrorNrrnr?�
difference)r]r{�time_nowrP�troublerr�	connectedr�have_processing_job�job�data�state�t�removerrrrz�sp�
�

���"�


�
z!Monitor.update_connecting_devicescsht�j���}t�}�j��D]z\}}|D]s}|��}|��}|�|�|�jvr8t	�
�fdd�|�|�j|<|��dkr�|�jvr�d}	|�
|i���D]\}
}|�
dtj�}|tjkrad}	nqM|	rzt	�dt�j|�}
|
�j|<td|�qtd	�t�r�tt�|��qq��|�t�j���}|D]}||vr��j|}�j|=t	�
�fd
d�|�q�dS)Nc���d|�S)Nr$�ro��xrarr�<lambda> sz-Monitor.check_state_reasons.<locals>.<lambda>r}Fr~Tr	zStart connecting timer for `%s'z#Ignoring stale connecting-to-devicecr�)Nr%r�r�rarrr�F�)rlrM�keysr?r>r�	get_tupler�r�r�idle_addr�rPr�rr�r��timeout_add_secondsr�rxrNrj�
get_debugging�pprint�pformatrz)r]r|r{�old_reasons_seen_keys�reasons_nowrrr�tupler�r�r�r�r�rrrar�check_state_reasonssb

�

�
��
���
%
���zMonitor.check_state_reasonscCs�|jr	t�|j�d|_|jst�d|j�|_td�dStd�t��}z�t�	|j
�tj|j|j
|jd�}z!z|�|jg|jdg�}WntyV|�|jg�}YnwWnStjy�}zF|j\}}t�	|�|tjkr�d|_td�|��WYd}~WdS|�d	||�|tjkr�WYd}~WdStd
||f�WYd}~WdSd}~wwWnty�t�	|�td�d|_|�d
�YdSw|jr�d|_td�|�d�t�	|�|j��}|dD�]�}|d}||_|d}	td||	|df�t��r
tt�|��|	� d��r�|d}
|	dk�r,|
|j!v�r,|j!�"|
�|�d|
�n||	dk�rq|
|j!v�rq|j!�#|
�t$|j%�&��}|D]}|d|
k�r^|j%|}
|j%|=|�d|
��qF|
|j'v�rj|j'|
=|�d|
�n7|
|j!v�r�|d}g}|D]}
|
dk�r�nt(|
��r��q|�)t*|
|
|j+���q||j'|
<|�d|
|	|�q�|	� d��s�tdt,|	��q�|d}|	d k�s�|	d!k�r@||v�r@|d"tj-k�r@|j.du�r�|d|j.v�r�q�z|�/|�}|j0�r�|d#t��k�r�Wq�|||<Wn5t1�yd$d%i||<Yn&tj�y1}z|j\}}|�d	||�d$d%i||<WYd}~nd}~ww|�d&||	|||���n1|	d'k�sR|	d!k�rq|d"tj2k�rq|j3d(v�rqz
||=|�d)||	|�Wn
t1�yoYnwq�z||}Wn
t1�y�Yq�w|j.du�r�|d|j.v�r�||=|�d)||	|�q�d*D]	}||||<�q�d+|v�r�|d+|d,<|�d-||	||���q�|�4d�|�5|�||_|�4d�|j6�s�|d.}t�7||j�}td/|�||_dS)0Nrvz#Deferred get_notifications by 200msF�get_notificationsr1r	r8z$Subscription not found, will refreshr0z$getNotifications failed with %d (%s)Tz!cups-connection-error, will retryr.r/�eventsznotify-sequence-numberznotify-subscribed-eventz%d %s %sznotify-textzprinter-zprinter-namer+�printer-deletedr%r-rrr,zjob-zUnhandled nse %sz
notify-job-id�job-created�job-state-changedr~�job-originating-user-name�job-k-octetsrr(�
job-completed)�	completed�allr*)r~�job-nameznotify-printer-uri�job-printer-urir)znotify-get-interval�Next notifications fetch in %ds)8rRrrnr@rwr�rjrrFrgrGrhr2r3r4�getNotificationsr\�sub_seq�AttributeErrorr�args�
IPP_NOT_FOUNDr"ro�
IPP_FORBIDDEN�RuntimeErrorrBr=r`r�r�r�r
rr�r�rlrMr�r>rrrr�reprr�r;�getJobAttributesr:�KeyError�IPP_JOB_COMPLETEDrLru�update_jobsrQr�)r]rGrp�
notifications�e�mr=�event�seq�nserrr�rr>r�jobid�attrsr��	attribute�intervalr�rrrr�Is:��

���



���

�



�



�





��

��



�zMonitor.get_notificationsc
s�td���d�|dur|�_t��}zt��j�tj�j�j	�j
d�}Wnty=t�
�jd�t�|�YdSw�jdkr�z|��j�Wn#tjyn}z|j\}}t�
�fdd�||�WYd}~nd}~ww�jrxt��j�d�_td�j�z�`Wn	ty�Ynwgd�}�jr�|�gd	��z|jd
|d��_td�jt|�f�Wn#tjy�}z|j\}}t�
�fd
d�||�WYd}~nd}~wwt�|��jdkr��jr�t��j�t�t�j��_tdt��j�r;�j��}�jdv�r$i}	|��D]\}
}|� dtj!�tj!k�r ||	|
<�q
|	}d�_"�j#�r1t��j#�t�$d�j%|��_#ni}zt&|�j'�}|�_(|�)�}
t*|
�+���_,Wn6tj�yx}z|j\}}t�
�fdd�||�WYd}~dSd}~wt�y�t�
�jd�YdSw�j-du�r�|�+�D]!}
||
� dd
�}|�.d
�}||dd�}|�j-v�r�||
=�q���/d��j,D]
}t�
�fdd�|��q�|��D]\}
}t�
�fdd�|
|��qЈ�0|�|�_��/d�dS)Nr"r1r.r8c���d||�S�Nr0r��r�r�rarrr��z!Monitor.refresh.<locals>.<lambda>rf)r+zprinter-modifiedr�zprinter-state-changed)r�r�zjob-stoppedr�zjob-progress�/)r�z"Created subscription %d, events=%scr�r�r�r�rarrr�.r�r�)r�r�r~r	�cr�r�r�r�rarrr�Wr�r�Fcr�)Nr+r�r�rarrr�hr�cs��d|di|�S)Nr(�r�)r�r�rarrr�jsT)1rjrorLrrFrgrGrhr2r3r4r�rr�r\rirr�rRrnr�r�r<�extend�createSubscriptionr�r��MIN_REFRESH_INTERVALr�r=r`rr�r��fetch_first_job_idrArw�
fetch_jobsr rr>rr?r�rr;�rfindrur�)r]rL�refresh_allrGrpr�r�r�r=�filteredr�r��r�dests�uri�irrrarr"�s�

�
�

�����
���

��
���
�
���
�

�

zMonitor.refreshc
Cs|jsdSt��}zt�|j�tj|j|j|jd�}Wnt	y3|�
d�d|_t�|�YdSwd}gd�}z|j|j
|j|j||d�}Wn(tjyq}z|j\}}|�
d||�d|_t�|�WYd}~dSd}~wwt�|�t|�}	td	|	|f�|j��}
t|���}|��|	d
kr�||	d}||jkr�|j|d}tdt|��td�n|j|d}t|j|d�D]Y}
z=||
}|jdur�|�d
d�}|�d�}||dd�}||jvr�t�|
|
vr�d}nd}||
|
<|�
||
di|���Wq�t�y|
|
v�r|
|
=|�
d|
di�Yq�wt|
���}|��|	|k�rUd}tt|��D]}||}
|�sE|
|k�rEd}|�rS|
|
=|�
d|
di��q5|�|
�|
|_|	|k�rgd|_dS|
d}|�s�||jv�r�|d7}|�s�||jv�st||_dS)NTr1r.Fr	)zjob-idr�r~r�r�r�ztime-at-creation)rLr:�first_job_id�limit�requested_attributesr0zGot %s jobs, asked for %srzUnexpected job IDs returned: %szThat's not what we asked for!r�r�r)r(r�r*) r@rrFrgrGrhr2r3r4r�rorA�getJobsrLr:r�rr��lenrjr=r`rlr��sortr��ranger;r�r�r�r�)r]r�rGrpr�r��fetchedr�r��gotr=�jobids�
last_jobidr�r�r�r�r�n�trim�nextrrrr�rs�
�

�
�

��


�



��
�

�zMonitor.fetch_jobsc
Cs�|dur|j}t�}i}|��D]<\}}|�dtj�}|tjkr!q|�dd�}|�d�}|dkr1q||dd�}	|�|	�|	|vrFi||	<|||	|<q||fS)Nr~r�r�r�r8r	)r=r?rr�rr�r�r�)
r]r=r|r{r�r�r�r�r�rrrrry�s$


zMonitor.sort_jobs_by_printercCs&td�|�|�\}}|�||�dS)Nr�)rjryr�)r]r=r{r|rrrr��szMonitor.update_jobscCs.|jr	t�|j�t�d|j�|_td�dS)Nrvz1Next notifications fetch in 200ms (update called))rRrrnrwr�rjrarrr�update�szMonitor.updatecGs$td�|��|jsd|_dSdS)Nz(D-Bus signal from CUPS... calling updateT)rjr�rQ)r]r�rrrrY�s

�zMonitor.handle_dbus_signal)NTNTNNN)NTr_)�__name__�
__module__�__qualname__r�SignalFlags�RUN_LAST�
TYPE_PYOBJECT�str�int�__gsignals__rZr[r9rbrdrersrurxrzr?r�r�r"r�ryr�r�rYrrrrr!Cs�����������������$
�2=4
0z
jr!�__main__c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�
SignalWatchercCs�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d	|j	�|�d
|j
�|�d|j�|�d|j�|�d
|j
�dS)Nr#r$r%r&r'r(r)r*r+r,r-r.r0)�connect�on_monitor_exited�on_state_reason_added�on_state_reason_removed�on_still_connecting�on_now_connected�on_job_added�on_job_event�on_job_removed�on_printer_added�on_printer_event�on_printer_removed�on_cups_connection_error�on_cups_ipp_error)r]�monitorrrrr9s"��zSignalWatcher.__init__cC�td|�dS)Nz*%s: monitor exited��print�r]�objrrrr��zSignalWatcher.on_monitor_exitedcC�td||f�dS)Nz*%s: +%sr�r]rrrrrr��z#SignalWatcher.on_state_reason_addedcCr)Nz*%s: -%srrrrrr�r	z%SignalWatcher.on_state_reason_removedcCr)Nz*%s: still connecting: %srrrrrr� r	z!SignalWatcher.on_still_connectingcCr)Nz*%s: now connected: %sr)r]rrrrrr�#r	zSignalWatcher.on_now_connectedcCr)Nz*%s: job %d addedr�r]rr��	eventnamer��jobdatarrrr�&r	zSignalWatcher.on_job_addedcCstd|||f�dS)Nz*%s: job %d event: %srr
rrrr�)�zSignalWatcher.on_job_eventcC�td|||f�dS)Nz*%s: job %d removed (%s)r)r]rr�rr�rrrr�,r
zSignalWatcher.on_job_removedcCr)Nz*%s: printer added: %sr�r]rrrrrr�/r	zSignalWatcher.on_printer_addedcCr)Nz*%s: printer event: %s: %sr)r]rrrr�rrrr�2r
zSignalWatcher.on_printer_eventcCr)Nz*%s: printer %s removedrrrrrr�5r	z SignalWatcher.on_printer_removedcCr)Nz*%s: cups connection errorrrrrrr�8rz&SignalWatcher.on_cups_connection_errorcCr)Nz*%s: IPP error (%d): %sr)r]r�err�	errstringrrrr�;r
zSignalWatcher.on_cups_ipp_errorN)r�r�r�r9r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�sr�T) �configr�requirerS�	dbus.glib�
gi.repositoryrrr�debugr��gettext�install�PACKAGErr�statereasonrr�r�rr r!r�r��
set_debuggingr�r"�MainLoop�loop�runrsrrrr�<module>sH
	F9
�

Youez - 2016 - github.com/yon3zu
LinuXploit