Package: printconf
Severity: wishlist
Tags: patch
Hi
I would like to have printconf accepting customized/preferred ppd files
offered by the local admins. The attached patch worked for me.
Would you consider adding something similar?
Cheers
Steffen
--- usr/bin/aa-printconf 2008-11-25 08:54:57.000000000 +0100
+++ /usr/bin/aa-printconf 2008-11-25 16:39:12.000000000 +0100
@@ -30,6 +30,7 @@
import commands
import sys
import tempfile
+import glob
from optparse import OptionParser
@@ -189,22 +190,37 @@
data = {'connect' : device, 'description' : desc, 'name' : qname,
'location' : devdesc }
+
+ a = printer.replace('-', '_')
+ prefppd = '%s%s%s' % ('/usr/local/share/ppd/', a, '.ppd')
+ if glob.glob(prefppd):
+ print 'Using prefered ppd file'
+ foundppd = True
+ system_ppd = False
+ data['printer'] = printer
+ data['ppdfile'] = prefppd
+ print_fill(
+ 'Configuring %s %s on %s with %s driver as queue "%s".',
+ make, model, device, prefdriver, qname)
+ else:
+ foundppd = False
- foundppd = False
- if prefdriver == 'postscript' and pdbinfo.get('ppd'):
- ppd_content = foomatic.get_ppd_content(pdbinfo.get('ppd'))
- if ppd_content:
- foundppd = True
-
- (tfh, tfname) = tempfile.mkstemp(text=True, suffix=".ppd",
- prefix="printconf-")
- tf = os.fdopen(tfh, 'w+')
- tf.write(ppd_content)
- tf.close()
- data['ppdfile'] = tfname
- print_fill(
- 'Configuring %s %s on %s with PPD %s as queue "%s".',
- make, model, device, fp.name, qname)
+ if not foundppd:
+ if prefdriver == 'postscript' and pdbinfo.get('ppd'):
+ ppd_content = foomatic.get_ppd_content(pdbinfo.get('ppd'))
+ if ppd_content:
+ foundppd = True
+ system_ppd = True
+
+ (tfh, tfname) = tempfile.mkstemp(text=True, suffix=".ppd",
+ prefix="printconf-")
+ tf = os.fdopen(tfh, 'w+')
+ tf.write(ppd_content)
+ tf.close()
+ data['ppdfile'] = tfname
+ print_fill(
+ 'Configuring %s %s on %s with PPD %s as queue "%s".',
+ make, model, device, fp.name, qname)
if not foundppd:
data['driver'] = prefdriver
@@ -220,10 +236,10 @@
if verbose:
print 'printer already exists and --force option so we remove the printer before readding it'
foomatic.foomatic.remove_queue(qname)
- foomatic.foomatic.setup_queue(data)
+ foomatic.foomatic.setup_queue(data)
- if foundppd:
- os.unlink(tfname)
+ if system_ppd:
+ os.unlink(tfname)
# Queue X is now set up with name based on the IEEE model
# some sort of message here would be nice