From: Till K. <til...@gm...> - 2005-06-09 13:31:24
|
I use "lpinfo -v" to get available "hp://..." URIs. To associate /dev/usb/... devices to them, I do "getusbprinterid.pl <device>" and find the "hp://..." URI which contains the "MODEL" or "MDL" field of the detected ID string right after "hp://usb/" and, if available, matches the serial number. To determine whether a printer is supported by HPLIP already before installing/starting HPLIP I match the '<model name="...">' in /usr/share/hplip/data/xml/models.xml against the "MODEL" or "MDL" field of the detected ID string. The HPLIP RPM I have made in a way that /usr/share/hplip/data/xml/models.xml is in a separate RPM and this separate RPM is always installed. printerdrake installes the rest of HPLIP when it detects a supported printer. Till Tim Waugh wrote: > On Thu, Jun 09, 2005 at 03:10:06PM +0200, Till Kamppeter wrote: > > >>AS HPLIP does not grab the devices permanently, you can also use the >>independent programs >> >>http://www.linuxprinting.org/download/printing/getusbprinterid.pl >> >>or >> >>http://www.linuxprinting.org/download/printing/usb_id_test.c >> >>The code of the Perl version I use in printerdrake of Mandriva Linux. >> >>The programs work with all USB printers, also non-HP printers. > > > Yes, indeed, but that doesn't really help. I would still have to > parse an ID like 'hp:/usb/DESKJET_990C?serial=US05N1J00XLG' to work > out which device to use. > > Much easier would be a program like hp-devid (attached). > > Tim. > */ > > > ------------------------------------------------------------------------ > > #!/usr/bin/env python > # > # Based on HPLIP info.py: > > # (c) Copyright 2003-2004 Hewlett-Packard Development Company, L.P. > # > # This program is free software; you can redistribute it and/or modify > # it under the terms of the GNU General Public License as published by > # the Free Software Foundation; either version 2 of the License, or > # (at your option) any later version. > # > # This program is distributed in the hope that it will be useful, > # but WITHOUT ANY WARRANTY; without even the implied warranty of > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > # GNU General Public License for more details. > # > # You should have received a copy of the GNU General Public License > # along with this program; if not, write to the Free Software > # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > # > # Author: Don Welch > # > > > # Std Lib > import sys > import os > import getopt > import re > > sys.path.append ("/usr/share/hplip") > > # Local > from base.g import * > from base import device, service, status, utils > > log.set_level ('none') > > try: > device_uri = sys.argv[1] > except: > device_uri = utils.getInteractiveDeviceURI( "usb" ) > > try: > d = device.Device( None, device_uri, None ) > except Error: > log.error( "Error opening device. Exiting." ) > sys.exit(0) > > try: > s = None > try: > s = service.Service() > except Error: > log.error( "Unable to contact services daemon. Exiting." ) > sys.exit(0) > > try: > data = s.queryDevice( d.device_uri, 0, STATUS_PRINTER_IDLE, False ) > except Error: > log.error( "Device query failed." ) > else: > print data["deviceid"] > > finally: > log.debug( "Closing services..." ) > if s is not None: > s.close() > if d is not None and d.io_state == IO_STATE_HP_OPEN: > d.close() > |