[23513] in Source-Commits
/svn/athena r23157 - in trunk/debathena/config/printing-config: debian files/usr/bin
daemon@ATHENA.MIT.EDU (geofft@MIT.EDU)
Sat Aug 23 03:17:20 2008
Date: Sat, 23 Aug 2008 03:16:49 -0400 (EDT)
From: geofft@MIT.EDU
Message-Id: <200808230716.DAA22738@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: geofft
Date: 2008-08-23 03:16:48 -0400 (Sat, 23 Aug 2008)
New Revision: 23157
Modified:
trunk/debathena/config/printing-config/debian/changelog
trunk/debathena/config/printing-config/files/usr/bin/lpr.debathena
Log:
In printing-config:
* Add awareness of the default printer, specified by the PRINTER environment
variable or via Hesiod cluster information.
Modified: trunk/debathena/config/printing-config/debian/changelog
===================================================================
--- trunk/debathena/config/printing-config/debian/changelog 2008-08-22 21:02:18 UTC (rev 23156)
+++ trunk/debathena/config/printing-config/debian/changelog 2008-08-23 07:16:48 UTC (rev 23157)
@@ -1,3 +1,10 @@
+debathena-printing-config (1.2) unstable; urgency=low
+
+ * Add awareness of the default printer, specified by the PRINTER environment
+ variable or via Hesiod cluster information.
+
+ -- Geoffrey Thomas <geofft@mit.edu> Sat, 23 Aug 2008 00:30:32 -0400
+
debathena-printing-config (1.1) unstable; urgency=low
* Handle rename of cupsys to cups in Debian sid.
Modified: trunk/debathena/config/printing-config/files/usr/bin/lpr.debathena
===================================================================
--- trunk/debathena/config/printing-config/files/usr/bin/lpr.debathena 2008-08-22 21:02:18 UTC (rev 23156)
+++ trunk/debathena/config/printing-config/files/usr/bin/lpr.debathena 2008-08-23 07:16:48 UTC (rev 23157)
@@ -8,6 +8,8 @@
# intended for should go to CUPS or LPRng and sends it off in the
# right direction
+import errno
+import hesiod
import getopt
import os
import sys
@@ -45,7 +47,14 @@
def lprngQueueExists(queue):
"""Test if queue name exists as an LPRng queue
"""
- return returnCode('/usr/bin/hesinfo', queue, 'pcap') == 0
+ try:
+ h = hesiod.Lookup(queue, 'pcap')
+ return len(h.results) > 0
+ except IOError, e:
+ if e.errno in (errno.ENOENT, errno.EMSGSIZE):
+ return None
+ else:
+ raise
def useCups(command, queue, args):
"""If queue exists as a CUPS queue, pass the command and arguments on to the
@@ -86,6 +95,20 @@
one of lpr, lpq, lprm, lp, or cancel
""" % command)
+ default = os.getenv('PRINTER')
+ if default:
+ return default
+ try:
+ h = hesiod.Lookup(os.uname()[1], 'cluster')
+ for result in h.results:
+ (key, value) = result.split(None, 1)
+ if key == 'lpr':
+ return value
+ except IOError, e:
+ if e.errno in (errno.ENOENT, errno.EMSGSIZE):
+ pass
+ else:
+ raise
if __name__ == '__main__':
# Remove the command name from the arguments when we extract it