3
NZ              %   @   s  d Z dZdZdZddlZddlZddlT ddlmZm	Z	m
Z
mZ ddlmZ d	Zd
ZdBddZdCddZdd Zedddfde dddfe	je	je	je	je	jdDdEdFe	jdde dd
fe	je	jdGdHdId$e dd!d
fdJgZe
jeee eeefdddd&	Zejd'd(d)gd
d*\Z Z!Z"Z#Z$Z%d+e&j' Z(ej)j*e(rRyej+e( W n e,k
rP   Y nX e-j.e( e-j/e-j0 yddl1Z1dd,l1m2Z2m3Z3 W n$ e4k
r   e-j5d- d
ZY nX dZyej6d Z7W n e8k
r   dZ7Y nX e-j9d.e7  e:e7d/k re  ej;  ye7rej<e7\Z!Z=Z>e!s6e-j?d0 ej;d e-j9d1e!  ej@e!ZAeA sheAjBd2eCeCkr|e-j?d3 ej;d/ dZ"e&jDZDdZEd4e!kre ree!e"eFeDeEd n
e-j?d5 eAjBd6eGZHeHeGkrejI ZJeJjK ZLeLejMkre-jNd7 n"eLejOkre-jNd8 n
e-jNd9 eLejMkrLe rBee!e"ePeDeEd: n
e-j?d; eAjBd<d
ZQeQrd=e7 ZRe-jNeR e	jSeR\ZTZUeTdkre-j9d>e!  ne-j5d?e!  W n  eVk
r   e-j?d@ Y nX e-j9dA dS )Kz1.2zHP device config using USBzhp-config_usb_printerzUdev invokes this tool. Tool detects the plugin, Smart Install (C/DVD-ROM) issues and notifies to logged-in user. Tool also downloads firmware to the device.    N)*)deviceutilsmoduleservices)pluginhandlerzcom.hplip.StatusServiceF c       	      C   s`   t dkrd S tjd | ||||||g}tjdtd}|j|ddi t j| tjd d S )NFzsend_message() entered/ZEventZ	signatureZssisisszsend_message() returning)	DBUS_AVIALABLElogdebuglowlevelZSignalMessageDBUS_SERVICEappend	SystemBussend_message)	
device_uriprinter_nameZ
event_codeusernamejob_idtitleZ	pipe_nameargsmsg r   &/usr/share/hplip/config_usb_printer.pyr   +   s    
r   textc             C   s    t jt| ttt tjd d S )Nr   )r   Zformat_textUSAGE	__title____mod____version__sysexit)typr   r   r   usage9   s    r#   c              C   sx   t dkrdS d} tjd\}}|dkr^tj dkr>tjd n tjd tj	  tjd\}}|dkrtd} tj
d | S )NFz
hp-systrayr   z@ hp-systray must be running.
 Run 'hp-systray &' in a terminal. zStarting hp-systray serviceTzhp-systray service is running
)r
   r   ZIs_Process_Runningosgetuidr   errorinfor   Zrun_systrayr   )ZSystray_Is_RunningZstatusoutputr   r   r   start_systray?   s    

r)   nameTz$Usage: %s [OPTIONS] [USB bus:device]Zsummary[USB bus:device]headingUSB bus:device :x"xxx:yyy" where 'xxx' is the USB bus and 'yyy' is the USB device. (Note: The ':' and all leading zeros must be present.)option3Use the 'lsusb' command to obtain this information.zUSB, IDs specified:z$%s 001:002Zexample-1. Using 'lsusb' to obtain USB IDs: (example)note
   $ lsusb9         Bus 003 Device 011: ID 03f0:c202 Hewlett-Packardz   $ %s 003:011n   (Note: You may have to run 'lsusb' from /sbin or another location. Use '$ locate lsusb' to determine this.))Zrun_as_root_okquietZghz	time-out=ztimeout=)Zhandle_device_printerz%s/hplip_config_usb_printer.log)r   r   zFailed to Import DBUS zparam=%s   zThis is not a valid devicez
Setting up device: %s
zsupport-typezUnsupported printer model.ZSMART_INSTALL_ENABLEDzSMART INSTALL (CD/DVD-ROM) is enabled in the system. Refer http://hplipopensource.com/hplip-web/index.html for more information.pluginz"Device Plugin is already installedzHP Device Plug-in is not foundz>HP Device Plug-in version mismatch or some files are corruptedZ
AutoConfigzVHP Device plugin's are not installed. Please install plugin's using hp-plugin command.zfw-downloadzhp-firmware -y3 -s %szFirmware downloaded to %s z(Failed to download firmware to %s devicez	User exitzDone.)r   )r   )r+   r   r,   F)r-   r.   r/   F)r   r0   r/   F)r1   r   r2   F)r3   r   r2   F)r4   r   r2   F)r5   r   r2   T)Wr   r   r   __doc__r    r$   Zbase.gbaser   r   r   r   Z	installerr   r   r
   r   r#   r)   ZUSAGE_OPTIONSZUSAGE_LOGGING1ZUSAGE_LOGGING2ZUSAGE_LOGGING3Z
USAGE_HELPZUSAGE_EXAMPLESZUSAGE_SPACEZUSAGE_NOTESr   ZModuleZINTERACTIVE_MODEmodZparseStdOptsZoptsr   r   modeZ
ui_toolkitlocZpropZuser_dirZLOG_FILEpathexistsremoveOSErrorr   Zset_logfileZ	set_whereZLOG_TO_CONSOLE_AND_FILEZdbusr   r   ImportErrorwarnr   Zparam
IndexErrorr   lenr!   ZmakeURIZsane_uriZfax_urir&   ZqueryModelByURIZmqgetZSUPPORT_TYPE_NONEr   r   ZEVENT_DIAGNOSE_PRINTQUEUEZPLUGIN_NONEr8   ZPluginHandleZ	pluginObjZ	getStatusZ
plugin_stsZPLUGIN_INSTALLEDr'   ZPLUGIN_NOT_INSTALLEDZEVENT_AUTO_CONFIGUREZfw_download_reqZfw_cmdZrunZfw_stsZfw_outKeyboardInterruptr   r   r   r   <module>   s   


 
















