Re: Need for a printconf package

Chris Lawrence <[email protected]> Wed, 23 Jun 2004 02:17:12 -0500
Newsgroups gmane.linux.debian.devel.gtk-gnome,gmane.linux.debian.usability
Organization The University of Mississippi (Standard Disclaimer Applies)
Message-ID <[email protected]>
On Jun 22, Michael Banck quoted Daniel:
> > Just like etherconf, printconf would "only" handle 90 % of the cases,
> > imposing Debian's prefered spooler and filters because in 90 % of the
> > cases, they don't matter. Thus, printconf would depend on, say, cups =
and
> > foomatic-*, and use libprinterconf0 to detect parallel, USB and netwo=
rk
> > printers. printconf would also provide a debconf frontend to
> > foomatic-configure (=E0 la foomatic-gui) and mention the weird
> > http://localhost:631/ (CUPS configuration).

This stuff is trivially easy with anything USB or IEEE 1284 parallel.
The pain is really getting network printers right--CUPS will normally
Do The Right Thing automagically with other CUPS servers with Browsing
On and BrowseAddress set to @LOCAL, but Samba and JetDirect etc. take
some manual probing.

Here'd be my idea for a "proof of concept" printconf:

- Depend on foomatic-db-engine, foomatic-db,
  foomatic-db-{hpijs,gimp-print} and the preferred spooler.
  (Also depend on network stuff?)

- Debconf .config question at medium: do you want to automatically
  configure any printers found?  Probably default yes.

- If yes, in postinst run needed code ripped out of foomatic-gui to
  detect said printers and set up the preferred driver for them using
  sensible defaults.  99% of the needed code is already written in
  foomatic-gui; just a matter of doing something like:

# printconf

  #!/usr/bin/python
  # printconf - silly script to set up every printer attached to the
  # system with zero fuss.

  # Copyright (C) 2004 Chris Lawrence <[email protected]>
  # GPL v2 or later

  from foomatic import detect, foomatic
  import re
  import os

  # regex for invalid characters in queue names to be filtered
  _invalidre =3D re.compile(r'([^A-Za-z0-9_])')

  def cleanup_name(model):
      model =3D model.lower().replace(' ', '_')
      newmod =3D invalidre.sub('', model)
      return newmod

  # CUPS needs printer.conf established before lpadmin will work properly
  os.system('touch /etc/cups/printer.conf')

  printdb =3D foomatic.get_printer_db()
  for (device, detectdata, devdesc, detectdesc) in conns:
      # Skip everything we don't have autodetection data for
      if not detectdata: continue

      # Get the IEEE 1284 printer description
      desc =3D detectdata.get('description')
      if not desc: continue

      model =3D detectdata.get('model', desc)

      pdbinfo =3D printdb.autodetect_ids.get(desc)
      # Unknown printer; probably should print a message here asking
      # people to contribute this information to foomatic-db
      if not pdbinfo: continue

      prefdriver =3D pdbinfo.get('driver')
      # Unsupported printer; barf something here
      if not prefdriver: continue

      foomatic.setup_queue( {'connect' : device, 'description' : desc,
                             'name' : cleanup_name(model),
                             'location' : devdesc,
                             'driver' : prefdriver } )
      # Queue X is now set up with name based on the IEEE model
      # some sort of message here would be nice

  # After loop, reinit CUPS
  os.system('/usr/sbin/invoke-rc.d cupsys reload')   =20

# End of script

That code should do exactly what we want, modulo bugs of course.  All
that's needed from a practical standpoint is:

- Split foomatic-gui into: foomatic-gui, python-foomatic, and
  printconf
- The debconf stuff for printconf


Chris
--=20
Chris Lawrence <[email protected]> - http://blog.lordsutch.com/


--=20
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]=
.org