Re: HPLIP: equivalent of ptal-devid wanted
Tim Waugh <[email protected]> Thu, 9 Jun 2005 14:13:53 +0100
| Newsgroups | gmane.linux.drivers.hpofficejet.devel |
|---|---|
| Message-ID | <[email protected]> |
--iogImpl5JeySoxiL
Content-Type: multipart/mixed; boundary="MiYnpxbAAMzII6w/"
Content-Disposition: inline
--MiYnpxbAAMzII6w/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
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=20
> independent programs
>=20
> http://www.linuxprinting.org/download/printing/getusbprinterid.pl
>=20
> or
>=20
> http://www.linuxprinting.org/download/printing/usb_id_test.c
>=20
> The code of the Perl version I use in printerdrake of Mandriva Linux.
>=20
> 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=3DUS05N1J00XLG' to work
out which device to use.
Much easier would be a program like hp-devid (attached).
Tim.
*/
--MiYnpxbAAMzII6w/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=hp-devid
Content-Transfer-Encoding: quoted-printable
#!/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
=20
log.set_level ('none')
try:
device_uri =3D sys.argv[1]
except:
device_uri =3D utils.getInteractiveDeviceURI( "usb" )
try:
d =3D device.Device( None, device_uri, None )
except Error:
log.error( "Error opening device. Exiting." )
sys.exit(0)
try:
s =3D None
try:
s =3D service.Service()
except Error:
log.error( "Unable to contact services daemon. Exiting." )
sys.exit(0)
=20
try:
data =3D 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:=20
s.close()
if d is not None and d.io_state =3D=3D IO_STATE_HP_OPEN:
d.close()
--MiYnpxbAAMzII6w/--
--iogImpl5JeySoxiL
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCqECRHU/d4jnpWe0RApcrAKCONHq7YT3rSZ6NjJx3lGMOYZJgYwCgi3pw
RQcU/x0lfd5KjogHEQMN+2Y=
=mBBy
-----END PGP SIGNATURE-----
--iogImpl5JeySoxiL--
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20