Your message dated Sun, 23 May 2010 00:47:09 +0000
with message-id <[email protected]>
and subject line Bug#507870: fixed in foomatic-gui 0.7.9.3
has caused the Debian Bug report #507870,
regarding printconf: Please consider adding support for cups groups
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
507870: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=507870
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: printconf
Severity: wishlist
Tags: patch

Hi

I had the case where I needed all printers added to a certain group.
Since cups was in use (and it appears to be the default anyway), I started
to implement some cups classes support. Right now I ended up adding a
commandline option to printconf, which adds all cups printers to
one specified cups group. I've added some sanity checks to prevent
things like adding the group to itself and such. Please have a look over
the patch and tell me, if you find it useful.

Cheers
Steffen
--- /usr/bin/printconf	2008-10-06 03:59:55.000000000 +0200
+++ printconf	2008-12-05 10:11:05.000000000 +0100
@@ -30,6 +30,7 @@
 import commands
 import sys
 import tempfile
+import cups
 
 from optparse import OptionParser
 
@@ -44,10 +45,13 @@
                   action='store_true', help="don't configure any printers")
 parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
                   help="include more detail about what's happening")
+parser.add_option('-c', '--class', dest='printers_class', action='store',
+                 help="add all printers to specified class")
 options, args = parser.parse_args()
 
 dryrun = options.dryrun
 verbose = options.verbose
+printers_class = options.printers_class
 
 if os.geteuid() and not dryrun:
     print >> sys.stderr, "Please run printconf as root or specify the --dry-run option."
@@ -109,6 +113,9 @@
     for q in existing.queues:
         queues[q['name']] = True
 
+# Initiate cups connection so it is available during printer queue setup
+c = cups.Connection()
+
 for (device, detectdata, devdesc, detectdesc) in conns:
     # Skip everything we don't have autodetection data for
     if not detectdata:
@@ -214,9 +221,42 @@
     queues[qname] = True
     print
 
+# Add printers to specified class
+if printers_class:
+   c = cups.Connection()
+   available_classes = c.getClasses()
+   available_printers = c.getPrinters()
+   # Only do sanity checks, if class doesn't exist yet
+   if printers_class in available_classes:
+       for iter_class, iter_class_printers in available_classes.iteritems():
+           if printers_class in iter_class:
+               for iter_printers in available_printers:
+                   # Check that printer is neither in the group, nor a classname itself
+                   if iter_printers not in iter_class_printers and iter_printers not in available_classes and iter_printers not in str(available_classes):
+                       print_fill('Adding "%s" printer to class "%s"', iter_printers, printers_class)
+                       c.addPrinterToClass(iter_printers, printers_class)
+                       c.enablePrinter(printers_class)
+                       c.acceptJobs(printers_class)
+                       # Check that given class is not already a printer, otherwise we'd allow a potential DoS
+                   elif iter_printers not in available_classes:
+                       print_fill('Printer "%s" already in group "%s"', iter_printers, printers_class)
+                   else:
+                       print_fill('Class "%s" is already defined as a printer and thus cannot be used', printers_class)
+   elif printers_class not in available_classes:
+       print_fill('Creating new class "%s" and adding all printers to it', printers_class)
+       for i in c.getPrinters():
+               if i not in available_classes:
+                       c.addPrinterToClass(i, printers_class)
+                       c.enablePrinter(printers_class)
+                       c.acceptJobs(printers_class)
+
+
+
+
 # After loop, reinit CUPS
 if not dryrun:
-    os.system('/usr/sbin/invoke-rc.d cups force-reload')    
+    # Need to restart cups completely, otherwise we are crashing it with the cups calls
+    os.system('/usr/sbin/invoke-rc.d cups restart')
 
     print_fill('''If printconf was unable to install all of your printers,
 please visit http://www.linuxprinting.org/ for printer information and support

--- End Message ---
--- Begin Message ---
Source: foomatic-gui
Source-Version: 0.7.9.3

We believe that the bug you reported is fixed in the latest version of
foomatic-gui, which is due to be installed in the Debian FTP archive:

foomatic-gui_0.7.9.3.dsc
  to main/f/foomatic-gui/foomatic-gui_0.7.9.3.dsc
foomatic-gui_0.7.9.3.tar.gz
  to main/f/foomatic-gui/foomatic-gui_0.7.9.3.tar.gz
foomatic-gui_0.7.9.3_all.deb
  to main/f/foomatic-gui/foomatic-gui_0.7.9.3_all.deb
printconf_0.7.9.3_all.deb
  to main/f/foomatic-gui/printconf_0.7.9.3_all.deb
python-foomatic_0.7.9.3_all.deb
  to main/f/foomatic-gui/python-foomatic_0.7.9.3_all.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Chris Lawrence <[email protected]> (supplier of updated foomatic-gui package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Sat, 22 May 2010 19:33:20 -0500
Source: foomatic-gui
Binary: foomatic-gui printconf python-foomatic
Architecture: source all
Version: 0.7.9.3
Distribution: unstable
Urgency: low
Maintainer: Chris Lawrence <[email protected]>
Changed-By: Chris Lawrence <[email protected]>
Description: 
 foomatic-gui - GNOME interface for configuring the Foomatic printer filter 
syste
 printconf  - automatically configures USB and parallel printers with CUPS
 python-foomatic - Python interface to the Foomatic printer database
Closes: 506940 506941 507666 507668 507869 507870 508357 508427 549037 567062
Changes: 
 foomatic-gui (0.7.9.3) unstable; urgency=low
 .
   * Migrate from gtkhtml2 to webkit. (Closes: #549037)
   * Update Portuguese translation.  (Closes: #567062)
   * Convert Perl hex escapes to Python hex escapes.  (Closes: #508427)
   * Improve USB printer handling with hotplugging and udev.  (Closes: #508357)
   * Add new option to printconf to reload parallel modules.  (Closes: #507869)
   * printconf: Allow PPD files in /usr/local/share/ppd to override system
     PPD files.  (Closes: #506940)
   * printconf: add papersize option.  (Closes: #506941)
   * printconf, python-foomatic: add spooler option.  (Closes: #507666, #507668)
   * printconf: add CUPS classes support.  (Closes: #507870)
   * printconf: ensure output is valid for user's locale's charset.
   * Incorporate NMU changes.
Checksums-Sha1: 
 170da46b80e10066d7d9074303f33fc6d19a4e5e 910 foomatic-gui_0.7.9.3.dsc
 1176d0aef54153c46b30028b911cb40bf51275ac 123760 foomatic-gui_0.7.9.3.tar.gz
 889e3161337188359b8e0e5009f38f7e3d6a163a 61650 foomatic-gui_0.7.9.3_all.deb
 9342a4608e785b86b53a142391d11b1a4cc2759b 20254 printconf_0.7.9.3_all.deb
 75fa827bb34eaabe784b74a26eff4b27af89a3cd 23266 python-foomatic_0.7.9.3_all.deb
Checksums-Sha256: 
 c4c415aaa74337c46fdd11775cac02ccbc193ca706070e71b69fddbb52e90e61 910 
foomatic-gui_0.7.9.3.dsc
 3b221f8398a78b4ea738051b8e01a253a2cc01f6c12b38217871ef7469ac4b3a 123760 
foomatic-gui_0.7.9.3.tar.gz
 379369701bbfcafb019fb6e220cfda98e9d076693026d20a7e7156579c28059a 61650 
foomatic-gui_0.7.9.3_all.deb
 3778c225d3feeaa0f2438307cbc23a65392c74b6b2dae69e6ab409b8c55c9df7 20254 
printconf_0.7.9.3_all.deb
 7434be41cfadb154cedee90d5eb4290173d7c772243f6ae97179b69c75143205 23266 
python-foomatic_0.7.9.3_all.deb
Files: 
 21fd337a1037155af918d1cea3ef61bb 910 gnome optional foomatic-gui_0.7.9.3.dsc
 4947d9c0e757c739867f977482acf75e 123760 gnome optional 
foomatic-gui_0.7.9.3.tar.gz
 db3ba87ab6e652f02adc1a8c958194d4 61650 gnome optional 
foomatic-gui_0.7.9.3_all.deb
 1171b7392b7a3d847d8f4f9881e9028d 20254 utils optional printconf_0.7.9.3_all.deb
 98a7404682423a3b0f50bde3b8bca2df 23266 python optional 
python-foomatic_0.7.9.3_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkv4eH8ACgkQ2wQKE6PXubzFfgCg46g03sNtSyEOmqlT35c5K9rk
fxQAniPdkI9xWkUfXSCMfMpE+TrAQ/0j
=42AF
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to