Ticket #1032 (closed defect: fixed)

Opened 10 years ago

Last modified 9 years ago

printing-config's clusterinfo lookup bypasses local clusterinfo

Reported by: jdreed Owned by:
Priority: normal Milestone: Precise Release
Component: -- Keywords:
Cc: Fixed in version: debathena-printing-config 1.29
Upstream bug:

Description

It just queries Hesiod, which is Wrong(tm).

Change History

comment:1 Changed 9 years ago by jdreed

  • Milestone changed from The Distant Future to Precise Release

How Wrong(tm) is this?

--- common.py	(revision 25590)
+++ common.py	(working copy)
@@ -8,7 +8,7 @@
 import urllib
 import string
 import re
-
+import subprocess
 import cups
 import hesiod
 
@@ -153,12 +153,25 @@
         if default:
             return default
 
-    for result in _hesiod_lookup(socket.getfqdn(), 'cluster'):
-        key, value = result.split(None, 1)
-        if key == 'lpr':
-            return value
 
+    hesprinter = subprocess.Popen("eval $(getcluster -b $(lsb_release -sr)) && echo $LPR", stdout=subprocess.PIPE, shell=True).communicate()[0]
+    if hesprinter:
+        return hesprinter.strip()
 

comment:2 Changed 9 years ago by amu

You could at least use the Python module behind lsb_release directly.

comment:3 Changed 9 years ago by jdreed

I would use platform.dist() if it wasn't full of lies:

jdreed@jdreed-desktop:~$ lsb_release -sc
hardy
jdreed@jdreed-desktop:~$ echo -e "import platform\nprint platform.dist()[1]" | python
lenny/sid
jdreed@jdreed-desktop:~$ 

comment:4 Changed 9 years ago by jdreed

  • Status changed from new to committed

If you don't like the shell stuff, propose something better.

comment:5 Changed 9 years ago by amu

There's a literal lsb_release module; sorry if that was unclear.

$ lsb_release -sc
wheezy
$ python -c 'import lsb_release; print lsb_release.get_distro_information().get("CODENAME")'
wheezy

This approach works at least as far back as lucid; I don't have ready access to anything older. That said, I can't argue too much with working code; it's just a matter of style.

comment:6 Changed 9 years ago by jdreed

  • Status changed from committed to development

1.29 in dev

comment:7 Changed 9 years ago by jdreed

  • Fixed in version set to debathena-printing-config 1.29

lsb_release is not a thing until you get to Jaunty. (/usr/bin/lsb_release in Hardy is hilarious).

So we don't get to do this until April 2013. (Seriously, can we _please_ stop supporting Hardy?)

comment:8 Changed 9 years ago by jdreed

  • Status changed from development to proposed

comment:9 Changed 9 years ago by jdreed

  • Status changed from proposed to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.