Sindbad~EG File Manager

Current Path : /usr/share/hplip/base/__pycache__/
Upload File :
Current File : //usr/share/hplip/base/__pycache__/services.cpython-310.pyc

o

�/�a�&�@sVddlZddlZddlmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlTddlTddlmZmZddlmZe�dejjejj�Z e �!d	�d
d�Z"dd
�Z#dd�Z$ddd�Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*dd�Z+dS)�N)�Popen�PIPE�)�
html_entities)�*)�utils�tui)�logger��infocCst��dkS)Nr)�os�geteuid�rr�!/usr/share/hplip/base/services.py�running_as_root<srcCs$tj�d�rdStj�d�rdSdS)Nz/etc/init.d/cupsz/etc/init.d/cups restartz/etc/init.d/cupsysz/etc/init.d/cupsys restartzkillall -HUP cupsd)r�path�existsrrrr�restart_cups?s
rcCsRd}t�d�}|r'|r'dtj�|d�}|��|}t�||d�\}}|dk}|S)NF�shutdownz	%s -r nowz%Need authentication to restart systemr)r�whichrr�join�
getAuthCmd�run)�passwordObj�okr�cmd�status�outputrrr�restartIs
rcCs�|�d�}t�|�|rE|rGd}|D]6}|��|}t�||d|�\}}|dkr5t�d|�t�|�|dur@||d|�|d7}qdSdSdS)N�open_mdns_portrz*Need authentication to open mdns port [%s]rzAn error occurred running '%s'zOpen mDNS/Bonjour step %d)�get_distro_ver_data�log�debugrrr�warn)�corer�callback�open_mdns_port_cmd�xrrrrrr�run_open_mdns_portUs



�r(cCsJ|durt�|d�}|s|}t�|�t�|�\}}|dkSt�d�dS)NTrzCommand not foundF)rrr!r"r�error)r�	hpCommandrrrrr�run_hp_toolshs

r+cCsf|dur,|dur,t�|d�}|s|}|��|}t�|�t�||d|�\}}|dkSt�d�dS)NTz%Need authentication to run %s commandrz1Command not found or password object is not validF)rrrr!r"rr))rrr*rrrrr�run_hp_tools_with_authws

r,cCs�d}|r|s|St�d�rb|��d|}t�|�t�||d|�\}}|dkrWd|vs1d|vrS|��d|}t�d	|�t�||d
|�\}}|dkrQd}|Sd}|St�d||f�|St�d
�r�|��d|}t�|�t�||d|�\}}|dkr�d|vs�d|vr�|��d|}t�d	|�t�||d
|�\}}|dkr�d}|Sd|vr�t�d|�|Sd}|St�d||f�|Stj�	d|��r*|��d|}t�|�t�||d|�\}}|dk�rd|vs�d|v�r|��d|}t�d	|�t�||d
|�\}}|dk�rd}|Sd}|St�d||f�|S|dk�rQd}t�||d|�\}}|dk�rJd|v�rJd}|St�d�|St�d||f�|S)NF�	systemctlzsystemctl status %s.servicez,Need authentication to get %s service statusr�stop�inactivezsystemctl start %s.servicezcmd_start=%sz/Need authentication to start/restart %s serviceTz;Fail to start %s service, please start %s service manually.�servicezservice %s statuszservice %s startzunrecognized servicez0Failed to Start since %s is unrecognized servicez/etc/init.d/%sz/etc/init.d/%s statusz/etc/init.d/%s start�cupsz	lpstat -rz
is runningz>service command not found, please start cups service manually.)
rrrr!r"rr)rrr)�service_namer�ret_Val�
cmd_status�sts�out�	cmd_startrrrr�
start_service�s�

2�0�.
�
"� ���


��
�
��r8cCs~t�d�}|rtj�|d�}ntj�tjd�}tj�|�s"t�	d�t�
d|�t�tj|ddd�t�
d�t
�d�dS)	N�
hp-systrayz
systray.pyzUnable to start hp-systrayz&Running hp-systray: %s --force-startupz--force-startupz--ignore-update-firsttimez"Waiting for hp-systray to start...r)rrrrr�prop�home_dirrr!r#r"�spawnlp�P_NOWAIT�time�sleep)rrrr�run_systray�s


r@cCs�t�dd�}|r"d}d||f}t|�rt�d�dSt�d�dSz#ddlm}t}t	}|�
|tk|�\}}|r;|sCt�d	�WdSWdStyTt�d
�YdSw)Nzhp-SIDisableT�-z%s %szSmart Install is disabled
z$Smart Install could not be disabled
r)�pkitzFailed to install plug-in.z
Import error
)
rrr+r!r"r)r
rB�PLUGIN_REQUIRED�PLUGIN_REASON_NONE�run_plugin_command�ImportErrorr#)r�param�sicmdrB�plugin�
plugin_reasonr�sudo_okrrr�disable_SmartInstall�s$��rLc	Cs
t�d�\}}|durqt�dddgd�\}}|r|dkr#t�d�dSz
dd	lm}m}Wnt	y;t�
d
�Yn6wz+ddttj
dddg}|�dd
d�}|j|ddi�t�d�|��|�t�d�Wn	t�
d�Yt�d�\}}|dur�t�
d�dSdS)Nr9Tzq
Some HPLIP applications are running. Press 'y' to close applications or press 'n' to quit upgrade(y=yes*, n=no):�y�nz;Manually close HPLIP applications and run hp-upgrade again.Fr)�	SystemBus�lowlevelzUnable to load DBus.r
�/zcom.hplip.StatusService�Event�	signature�ssisissz'Sending close message to hp-systray ...g�?z5Failed to send DBus message to hp-systray/hp-toolbox.z
hp-toolboxzVFailed to close either HP-Toolbox/HP-Systray. Manually close and run hp-upgrade again.)r�Is_Process_Runningr�enter_choicer!r�dbusrOrPrFr)�EVENT_SYSTEMTRAY_EXITr:�username�
SignalMessage�appendr"�send_messager>r?)	rrr�choicerOrP�args�msg�toolbox_statusrrr�close_running_hp_processes�s6

�


ra)N),�sysr�
subprocessrr�grp�fnmatch�tempfile�socket�struct�selectr>�fcntl�errno�stat�string�glob�io�re�getpass�locale�sixext.movesr�g�codesr
rrr	�Logger�LOG_LEVEL_INFO�LOG_TO_CONSOLEr!�	set_levelrrrr(r+r,r8r@rLrarrrr�<module>sJ


D

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists