Sindbad~EG File Manager

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

o

�/�aʜ�@s4ddlmZdZdZdZdZddlZddlZddlZddl	Z	ddl
mZmZddl
mZdd	l
Tdd
lmZmZmZmZdd	lTddlmZdZz
dd
lmZmZWney`e�d�YnwdZedddfdedddfejdddejejejej ej!ej"ddddgZ#e	�$d�Z%dZ&dHdd�Z'd d!�Z(d"d#�Z)d$d%�Z*Gd&d'�d'e+�Z,e-d(k�r�zQe�.e�ze�ej/d)d�d*gd+��\Z0Z1Wn!ej2y�Z3ze�4e3j5�e'�e�6d)�WYdZ3[3ndZ3[3wwd,Z7e�8d-�r�d.Z7e9Z:dZ;dZ<e0D]�\Z=Z>e=d/v�re'�q�e=d0k�re'd1�q�e=d2k�re'd3�q�e=d4k�r)e?ed5d6�e�6d�q�e=d7v�r5e>�@��A�Z7q�e=d8k�r=d.Z7q�e=d9k�rEdZ<q�e=d:v�rMeBZ:q�e=d;v�rUeCZ:q�e=d<v�r]e9Z:q�e=d=k�rpe�De�Ed>��e�6d)�q�e=d?k�rwdZ;q�e�Fe7��s�e'�e<�s�e�G�ejH�Id@�ZJe�De�EdAeJ��ejH�KeJ��r�ze�LeJ�WneM�y�e�DdBeJ�Ynwe�NeJ�e;�s�e�OejP�ne�OejQ�e(�eR�SdCdD�ZTe,eUeVeT�ZWeWjX�Y�eW�Ze:e;�\Z[Z\e[�s�e\�r�eW�]�ne�De�^dE��Wne_�ye�4dF�Ynwe�D�e�DdG�dSdS)I�)�print_functionz15.1z Dependency/Version Check Utilityzhp-checkzyChecks dependency versions,permissions of HPLIP. (Run as 'python ./check.py' from the HPLIP tarball before installation.)N)�PY3�to_string_utf8)r)�*)�utils�tui�queues�
smart_install)�cupsF)�device�pmlzDevice library is not avail.T��namezUsage: %s [OPTIONS]�summary)zCompile-time check:z-c or --compile�optionF)zRun-time check:z-r or --run or --runtimerF)zCompile and run-time checks:z-b or --both (default)rF)zb1. For checking for the proper build environment for the HPLIP supplied tarball (.tar.gz or .run),r
�noteF)z%use the --compile or --both switches.r
rF)zc2. For checking for the proper runtime environment for a distro supplied package (.deb, .rpm, etc),r
rF)zuse the --runtime switch.r
rFz	FUNC#(.*)�no�textcCs4|dkr
t�tt�t�t|ttt�t�d�dS)Nrr)	r�	log_title�	__title__�__version__�format_text�USAGE�__mod__�sys�exit)�typ�r�/usr/share/hplip/check.py�usageLsrcCsJt�tt�t�t�d��t�d�D]}t�|�qt�d�D]}t�|�q t�d�D]}t�|�q-t��t�d�D]}t�|�q>t�d�D]}t�|�qKt�d�D]}t�|�qXt�d�D]}t�|�qet�d	�D]}t�|�qrt�d
�D]}t�|�qt��t�d�t�d�t�d
�t�d�t��dS)Nz)Note: hp-check can be run in three modes:z�1. Compile-time check mode (-c or --compile): Use this mode before compiling the HPLIP supplied tarball (.tar.gz or .run) to determine if the proper dependencies are installed to successfully compile HPLIP.z�2. Run-time check mode (-r or --run): Use this mode to determine if a distro supplied package (.deb, .rpm, etc) or an already built HPLIP supplied tarball has the proper dependencies installed to successfully run.z�3. Both compile- and run-time check mode (-b or --both) (Default): This mode will check both of the above cases (both compile- and run-time dependencies).zCheck types:z&a. EXTERNALDEP - External DependencieszMb. GENERALDEP  - General Dependencies (required both at compile and run time)z*c. COMPILEDEP  - Compile time Dependencieszd. [All are run-time checks]z PYEXT
SCANCONF
QUEUES
PERMISSIONz
Status Types:z    OKz?    MISSING       - Missing Dependency or Permission or Plug-inzE    INCOMPAT      - Incompatible dependency-version or Plugin-version)	rrrr�log�info�boldr�format_paragraph)�lrrr�
show_titleUs6



r%cCs.|dus|dkr|dkst||�rdSdSdS)NTr�-�OK�INCOMPAT�MISSING)�
check_version)�Installedsts�min_ver�
Installed_verrrr�Status_Typeys
r.cCsd}|dks
|dkr%|dkr#t|d�st|d�rd}|St|d�s#d}|S|d	kr5|dkr1d
}|Sd}|S|dksA|d
ksA|dkrI|dkrGd}|S|dkrY|dkrUd}|Sd}|S|dkritdkri|dkrgd}|S|dkry|dkrud}|Sd}|S|dkr�d|}|S)Nr&�pyqt�pyqt4r'z2.3z2.2z/Fax is not supported if version is lessthan 2.3z>Python Programming is not supported if version is lessthan 2.2�hpaioz%'hpaio found in /etc/sane.d/dll.conf'zP'hpaio not found in /etc/sane.d/dll.conf. hpaio needs to be added in this file.'�cupsext�pcardext�hpmudextz5'Not Found or Failed to load, Please reinstall HPLIP'r
z*'CUPS may not be installed or not running'z'CUPS Scheduler is running'�libusb�yesz"'libusb-1.0 needs to be installed'�dbusz*'DBUS may not be installed or not running'z'%s needs to be installed')r*�IS_LIBUSB01_ENABLED)�package�Inst_status�
installed_ver�commentrrr�get_comment�sL
�������	���r=c@sreZdZeedfdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
edfdd�Zdd�ZdS)�DependenciesCheck�qt4cCsNd|_d|_t|||�|_||_g|_g|_g|_i|_d|_	g|_
d|_dS)Nrr
)�
num_errors�	num_warns�CoreInstall�core�
ui_toolkit�req_deps_to_be_installed�opt_deps_to_be_installed�cmds_to_be_run�comm_error_devices�
plugin_status�smart_install_devices�
user_grps_cmd)�self�mode�ui_moderDrrr�__init__�s
zDependenciesCheck.__init__cCs�|dkr|jdkrdS|jdkr |jdkr |jdkr |dkr dS|dkr+|jdkr+dS|dkr6|jdkr6dS|dkrA|jdkrAdS|dkrJ|jsJdS|jjd	kr[d
|jvr[|dvr[dS|ddurdd
}n"t�|d�r�|d|jjvr}|jj|d�}n	d
}nt	|d�}t
|d�|d|�}t|||�}gg}}|j��r�|j�
|�\}}|s�|dkr�|�|�n|j�
||�\}}|s�|dkr�|�|�|dr�d}	nd}	|dkr�|d
ks�t|d�r�d|_t�d|�|dkr�|dkr�d|_|dk�r
t�d||d|	|d|||f�dSt�t�d||d|	|d|||f��|jd7_|D]}
|
�r6|j�|
��q+|	dk�rN|D]}|�rJ|j�|��q?dS|D]}|�r[|j�|��qPdS)N�cups-ddkT�qt5r?�qt3r/r0r1�rhelz5.)r7zpython-develzpython-dbusz
pyqt4-dbuszlibnetsnmp-devel�gcc�make�	reportlab�	policykitz
sane-develrP�r&��r�REQUIRED�OPTIONALr
z1.4z6cups -ddk not required as cups version [%s] is => 1.4 r4r'z' %-20s %-60s %-15s %-15s %-15s %-10s %s�z. error: %-13s %-60s %-15s %-15s %-15s %-10s %s�)�cups_ddk_not_reqrD�scanning_enabledrC�distro_name�distro_version�Ver_Func_Pat�search�version_func�get_versionr.r=�is_auto_installer_support�get_dependency_data�appendr*r �debug�hpmudext_availr!�redr@rGrFrE)rL�
sup_dist_vers�d�	deps_infor;�Statusr<�packages_to_install�commands�package_type�cmd�pkgrrr�__update_deps_info�sx&


�

(*�
����z$DependenciesCheck.__update_deps_infocC�|jS�N)rE�rLrrr�get_required_deps�z#DependenciesCheck.get_required_depscCrwrx)rFryrrr�get_optional_depsr{z#DependenciesCheck.get_optional_depscCrwrx)rGryrrr�get_cmd_to_runr{z DependenciesCheck.get_cmd_to_runcCrwrx)rHryrrr�get_communication_error_devsr{z.DependenciesCheck.get_communication_error_devscCrwrx)rKryrrr�get_user_grp_cmdr{z"DependenciesCheck.get_user_grp_cmdcCrwrx)rIryrrr�get_plugin_statusr{z#DependenciesCheck.get_plugin_statuscCrwrx)rJryrrr�get_smart_install_devices r{z+DependenciesCheck.get_smart_install_devicesFcLsp
d�_d�_t�dd��_t��}|rt�tj�t�ddd�}�j	�
d�}�j	j}�j	j|vrPt|�rP|t|�d}t�
t�d�j	j�j	j�j	j|f��t�d	�t�d
�\}}t�d�\}}	t�d
�\}}
t�d||	|
�j	j�j	jf�t�d
t���t�d�t�dd�}|�r�t�dd�}t�d|�t�d|��j	��r�t�d�j	j�j	jf�n
t�
d�j	j�j	jf�t��t�t�d��z	tdd���}
Wn#ttfy�}zt�d|j��jd7_WYd}~n
d}~wwt�|
�t��t�t�d��z
ttj� d�d���}
Wnttf�y9}zt�d|j�WYd}~n
d}~wwt�|
�t��t�t�d��z
ttj� d�d���}
Wn$ttf�y|}zt�
d |j��j!d7_!WYd}~n
d}~wwt�|
�t�"t�dd!d"���_#t�d#d$��j	j$�%�j	j&�|t'k�s�|t(k�r�t)t*t+t,t-d%�}|D]:}t�|��j	j$D]-}�j	j$|d&||k�r�t.�fd'd(��j	j$|dD���r��/||�j	j$|��q��q��j#�rt�d)�t�0d*��rt�d+�\}}
|d,k�r
t�d-�nd.|
v�rt�d/�nt�|
�t1�rt2j3�rXt�d0�t4�5d1g�}|�rSt�6�}d2|_t7|�8��D]\}}|�9||d,f��q?|�:�nt�d3�t�d4�t;�<d5t;j=�}t�d6�\}}
t��g}d}|
�>�D]&}z|�?|�}|�@d�}|�@d7�}|�A||f�W�qwtB�y�Y�qwwt�C|�|�r|D�]g}|\}}|�Dd8��s�|�Dd9��r��q�zt4�E|�\	}}} }!}"}#}$}%}&WntF�y�d:\	}}} }!}"}#}$}%}&Ynwt�t�|��t�t�d;t|���d<}'|d=k�rd>}'n|d?k�rd@}'t�dA|'�t�dB|�tj�GdC|dD�}(tj�H|(��r�t�dE|(�t;�<dFt;jI�})ztJt|(dG����}Wnt�yRt�
dH|(�dI}*Ynwz
|)�?|��@d�}*WntB�yidI}*Ynwt�dJ|*�t�dK|�\}}
t�dL|
�KdMdI��|d=k�r�|*�r�dN|*v�r��jd7_t�dO|�n-|d?k�r�|*�r�dN|*v�r��jd7_t�dP|�n|dQv�r�t�
dR��j!d7_!t1�r|�rd}�z(zt4�L|ddddS�}WntF�y�t�dT�YW|du�r�|�M��q�w|jN�dUtO�}+|+tPtQfv�rv|�sd,dVlRmS},|,�T�}-|-�U�}||,jVk�r8tV�_W|+|,jPk�r2t�dW�nDt�dX�n>||,jXk�r`tX�_W|+tPk�rS�jd7_t�dY�n#�j!d7_!t�
dZ�n||,jYk�rv�j!d7_!|,jY�_Wt�
d[�| d\v�r�z|��WntF�y�}zt�|jZ�dI}.WYd}~nd}~ww|�[�}.t�C|.�|.�s�t�d]�|�j\|<�jd7_n:t�d^�n4| d_k�r�z
|�]t^j_�\}/}.Wn
tF�y�Ynw|.�s�t�d]�|�j\|<�jd7_nt�d^�W|du�r�|�M�n|du�r
|�M�wwt���q�nt�
d`�t�da��j�rut�0db�}0|0�rutj�G|0db�}0t�dc|0�\}}
|
�rut;�<ddt;j=�}1t�C|
�zt�`de�}2Wnta�ydt�df��jd7_Ynw|
�>�D�]
}3dS}4|1�?|3�}|du�rs|�b�\} }5}6}7}8|2�c| |5�\}9}:|9|2jdk�r�tJ|:�}:d}zt4�L|:ddddS�}WntF�y�Y�qiw|je�s��qint�Cdg��qitf�g�};d}|;D]}|jh|:k�r�|ji}n�q�tj�Gdhdidjd1| |5�}<tj�H|<��s�tj�Gdhdkdjd1| |5�}<tj�H|<��rst�j|<�\
}=}>}?}@}A}B}C}D}E}Ft�0dldS�}G|G�r_t�dm|G|<f�\}}
|
�kdn�}HdI}I|HD])}Jdl|Jv�rIdI|Jk�rIdo|Jv�rIt;�<dp�}K|K�?|J��rI|Idq|K�?|J��@d�}I�q!t�drds|dtd;d;dudv|<|Iff��qit�drds|dtd;d;dudw|<|=dx@ff��qitl�m��_nt�jn��r�t�dy��jd7_�jnD]
}t�dz|d{d|f��q�nt�d}��jd7_|�r�t�|��j�j!fS)~NF�	configure�
ui-toolkitzlibusb01-buildr�
versions_listr^zZ%s-%s version is not supported. Using %s-%s versions dependencies to verify and install...zSYSTEM INFOzuname -r -v -ozuname -nz1 Kernel: %s Host: %s Proc: %s Distribution: %s %sz Bitness: %s bit
zHPLIP CONFIGURATION�hplip�version�dirs�homezHPLIP-Version: HPLIP %szHPLIP-Home: %szMHPLIP-Installation: Auto installation is supported for %s distro  %s version zQHPLIP-Installation: Auto installation is not supported for %s distro  %s version z.Current contents of '/etc/hp/hplip.conf' file:z/etc/hp/hplip.conf�rz4Could not access file: %s. Check HPLIP installation.z3Current contents of '/var/lib/hp/hplip.state' file:z/var/lib/hp/hplip.statez4Plugins are not installed. Could not access file: %sz/Current contents of '~/.hplip/hplip.conf' file:z~/.hplip/hplip.confzCould not access file: %sz
scanner-build�0z' %-20s %-20s %-10s %-10s %-10s %-10s %s)z<Package-name>z <Package-Desc>z<Required/Optional>z
<Min-Version>z<Installed-Version>z<Status>z	<Comment>)zExternal DependencieszGeneral Dependencies�
COMPILEDEPzPython ExtentionszScan Configuration�csg|]}�jj|�qSr)rC�selected_options)�.0�xryrr�
<listcomp>nsz.DependenciesCheck.validate.<locals>.<listcomp>zDISCOVERED SCANNER DEVICES�	scanimagezscanimage -Lrz#Failed to get Scanners information.zNo scanners were identifiedzNo Scanner found.zDISCOVERED USB DEVICES�usb)z
Device URI�ModelzNo devices found.zINSTALLED CUPS PRINTER QUEUESz(\S*): (.*)z	lpstat -vr]z
cups-pdf:/zipp://)	r
Fr
r
r
r
r
r
r^r&�Unknown�hpfax�Fax�hp�PrinterzType: %szDevice URI: %sz
/etc/cups/ppdz.ppdzPPD: %sz\*NickName:\s*\"(.*)"�rbzFailed to read %s ppd filer
zPPD Description: %szlpstat -p%szPrinter status: %s�
zHP FaxzNIncorrect PPD file for fax queue '%s'. Fax queues must use 'HP-Fax-hplip.ppd'.zXIncorrect PPD file for a print queue '%s'. Print queues must not use 'HP-Fax-hplip.ppd'.)r�r�z`Printer is not HPLIP installed. Printers must use the hp: or hpfax: CUPS backend for HP-Devices.TzDevice initialization failed.�plugin)�
pluginhandlerz"Required plug-in status: Installedz"Optional plug-in status: Installedz&Required plug-in status: Not installedz&Optional plug-in status: Not installedz plug-in status: Version mismatch)�parr�zCommunication status: FailedzCommunication status: Good�netzNo queues found.�
PERMISSION�lsusbz
%s -d03f0:zd^Bus\s([0-9a-fA-F]{3,3})\sDevice\s([0-9a-fA-F]{3,3}):\sID\s([0-9a-fA-F]{4,4}):([0-9a-fA-F]{4,4})(.*)r4zfNOT FOUND OR FAILED TO LOAD! Please reinstall HPLIP and check for the proper installation of hpmudext.z     Device URI: (Makeuri FAILED)�/�dev�bus�proc�getfaclz%s %sz
�filez.*:(.*)� z#%-15s %-30s %-15s %-8s %-8s %-8s %s�USB�Requiredr'zNode:'%s' Perm:'%s'zNode:'%s' Mode:'%s'i�z)'CD-ROM'/'Smart Install' Detected Devicesz%-30s %-20s %s �CD_ROM_EnabledzNeeds to disable Smart InstallzHPLIP not found.)or_rk�sys_conf�getrDr �	get_where�	set_where�LOG_TO_FILErC�get_distro_datarb�len�warnr"rar�headerr�runr!�
getBitnessrg�open�read�IOError�OSError�error�strerrorr@�os�path�
expanduserrA�to_boolr`�dependencies�update�hplip_dependencies�DEPENDENCY_RUN_AND_COMPILE_TIME�DEPENDENCY_RUN_TIME�EXTERNALDEP�
GENERALDEPr��PYEXT�SCANCONF�any�$_DependenciesCheck__update_deps_info�which�device_avail�prop�	usb_buildr�probeDevices�	Formatter�list�items�add�output�re�compile�
IGNORECASE�
splitlinesrd�groupri�AttributeErrorrj�
startswith�parseDeviceURI�Error�join�exists�	MULTILINEr�replace�Device�close�mq�PLUGIN_NONE�PLUGIN_REQUIRED�PLUGIN_OPTIONAL�	installerr��PluginHandle�	getStatus�PLUGIN_INSTALLEDrI�PLUGIN_NOT_INSTALLED�PLUGIN_VERSION_MISMATCH�msg�getDeviceIDrH�getPMLr�
OID_DEVICE_ID�
import_ext�ImportError�groups�make_usb_uri�
HPMUD_R_OK�	supportedr
�getPrinters�
device_urir�stat�splitr	� get_smartinstall_enabled_devicesrJ)LrL�	time_flag�
is_quiet_mode�org_log_locationr8�vrs�supported_distro_vrs�Sts�Kernel_info�	Host_info�	Proc_info�vr�r��e�dep_dict�	dep_check�dep�status�devices�frn�dd�
lpstat_pat�
cups_printers�
plugin_sts�p�match�printer_namer��back_end�is_hpr��model�serial�dev_file�host�zc�portr��ppd�nickname_pat�descr�r��	pluginObj�deviceid�
error_coder��	lsusb_patr4�o�okr��vid�pid�mfg�result_code�	deviceuri�printers�devnode�st_mode�st_ino�st_dev�st_nlink�st_uid�st_gid�st_size�st_atime�st_mtime�st_ctimer��getfacl_out_list�out�g�patrryr�validate$sd
�
�

��
��
��

>
���(










�

����

	��



>��


��



�


�
�
�
���





�

��
��

�((�


�

zDependenciesCheck.validatecCs�t�d�t�t�d��t�t�dtd���t|j�dkr&t�d�n|jD]}|dkr9t�d||f�q)t�d|�q)t�d	�t�t�d
��t�t�dtd
���t|j�dkrgt�d�n
|jD]	}t�d|�qj|j	t
ks~|j	tkr�t�d	�t�t�d��t�t�dtd���t�d
�|jr�t�d	�t�t�d��t�t�dtd���|jD]	}t�d|�q�t
��\}}t�t�d|��t�d	�t�d|j�t�d|j�t��dS)N�SUMMARYzMissing Required Dependenciesr&r�Noner
z7'%s' package is missing or '%s' service is not running.z%'%s' package is missing/incompatible r
zMissing Optional DependencieszNone
zPlug-in StatuszPlug-ins need to be installedz$SMART INSTALL/CD_ROM ENABLED DEVICESz%sz�Smart Install is enabled for these devices. Please disable Smart Install to enable device functionalities.

Refer link '%s' to disable Smart Install.
zTotal Errors: %dzTotal Warnings: %d)rr�r r!r"r�rEr�rFrIr�r�rJr	�get_SmartInstall_tool_infor@rA)rLrqr��url�	tool_namerrr�display_summary�sB








z!DependenciesCheck.display_summaryN)�__name__�
__module__�__qualname__�
MODE_CHECK�INTERACTIVE_MODErOr�rzr|r}r~rr�r�r�r;rArrrrr>�sC9r>�__main__r^z
hl:gtcrbsi)
�helpz	help-restzhelp-manz	help-desczlogging=r��runtimer��both�fixr!�HPLIP_DEBUGrj)z-hz--helpz--help-rest�restz
--help-man�manz--help-descr�)�end)z-lz	--loggingz-gz-t)z-cz	--compile)z-rz	--runtimez--run)z-bz--bothz--fixzI

Note:- 'hp-check --fix' is deprecated. Please run 'hp-doctor' command

z-sz./hp-check.logzSaving output in log file: %szFailed to remove %s filer�r�zNo errors or warnings.z	User exitzDone.)r)`�
__future__rrrr�__doc__rr��getoptr��base.sixextrr�base.g�baserrrr	�installer.core_install�prntr
r�rrr�r rj�
USAGE_OPTIONS�USAGE_LOGGING1�USAGE_LOGGING2�USAGE_LOGGING3�USAGE_LOGGING_PLAIN�
USAGE_HELP�USAGE_NOTESrr�rcr8rr%r.r=�objectr>rB�
set_module�argv�opts�args�GetoptErrorrr�r�r�	log_level�getenvr�r�r��fmtr$�a�print�lower�strip�DEPENDENCY_COMPILE_TIMEr�r!r"�	set_level�
no_formattingr��abspath�log_filer��remover��set_logfiler��LOG_TO_CONSOLE_AND_FILEr�r�r�rDrErFr
rC�initr;r@rArA�green�KeyboardInterruptrrrr�<module>s��
�

	$&
p
$��














��


���

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