[PATCH] Activated and fixed testing mode for device ID/driver association

Till Kamppeter till.kamppeter at gmail.com
Tue Mar 1 12:50:40 PST 2011


Currently, newprinter.py has only one testing mode to test the
complete wiozard setting up physically available printers. This did
not allow testing which driver gets associated to a printer with a
given device ID, for example if a user reports a bug about a wrong
driver being selected but the maintainer or developer does not have
the user's printer.

Exactly this is now available by a second testing mode with
parameters, which is fixed and made available with this change.

Instead of

cd /usr/share/system-config-printer
python newprinter.py

one does the call with parameters:

cupsctl FileDevice=yes
cd /usr/share/system-config-printer
python newprinter.py --setup-printer=file:/tmp/printout --devid="MFG:HP;MDL:Fax;"

and the printer with the device ID "MFG:HP;MDL:Fax;" will get set up
and the appropriate driver (here the fax driver of HPLIP) gets
selected. Also automatic driver downloads happen if appropriate.

This change only makes an already existing testing mode accessible and
fixes a bug in it (the device/driver association did not get
triggered). It does not change any behavior for normal use of
system-config-printer.
---
 newprinter.py |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/newprinter.py b/newprinter.py
index f10018a..0d58a40 100644
--- a/newprinter.py
+++ b/newprinter.py
@@ -661,6 +661,16 @@ class NewPrinterGUI(GtkGUI):
             self.on_rbtnNPFoomatic_toggled(self.rbtnNPFoomatic)
             self.rbtnChangePPDKeepSettings.set_active(True)
 
+            if self.dialog_mode == "printer_with_uri":
+                p = ppdsloader.PPDsLoader (device_id=devid,
+                                           device_uri=device_uri,
+                                           parent=self.NewPrinterWindow,
+                                           host=self._host,
+                                           encryption=self._encryption)
+                self.ppdsloader = p
+                p.connect ('finished',self.change_ppd_have_devs_and_ppds)
+                p.run ()
+
             self.auto_make = ""
             self.auto_model = ""
             self.auto_driver = None
@@ -3665,9 +3675,39 @@ class NewPrinterGUI(GtkGUI):
         self.device = None
         del self.printers
 
+def show_help():
+    print ("\nThis is the test/debug mode of the new-printer dialog of " \
+           "system-config-printer.\n\n"
+           "Options:\n\n"
+           "  --setup-printer URI\n"
+           "            Select the (detected) CUPS device URI on start up\n"
+           "            and run the new-printer wizard for it.\n\n"
+           "  --devid   Supply a device ID which should be used for the\n"
+           "            setup of the new peinter with \"--setup-printer\".\n"
+           "            This can be any printer's ID, so that driver \n"
+           "            selection can be tested for p[rinters which are not\n"
+           "            physically available.\n")
+
 gobject.type_register (NewPrinterGUI)
 
 if __name__ == '__main__':
+    import getopt
+    try:
+        opts, args = getopt.gnu_getopt (sys.argv[1:], '',
+                                        ['setup-printer=',
+                                         'devid='])
+    except getopt.GetoptError:
+        show_help ()
+        sys.exit (1)
+
+    setup_printer = None
+    devid = ""
+    for opt, optarg in opts:
+        if opt == '--setup-printer':
+            setup_printer = optarg
+        elif opt == '--devid':
+            devid = optarg
+
     os.environ["SYSTEM_CONFIG_PRINTER_UI"] = "ui"
     import ppdippstr
     import locale
@@ -3683,5 +3723,8 @@ if __name__ == '__main__':
     n.connect ("printer-added", on_signal)
     n.connect ("printer-modified", on_signal)
     n.connect ("dialog-canceled", on_signal)
-    n.init ("printer")
+    if setup_printer != None:
+        n.init ("printer_with_uri", device_uri=setup_printer, devid=devid)
+    else:
+        n.init ("printer")
     gtk.main ()
-- 
1.7.4.1


--------------000701060200040804040608--


More information about the Printing-architecture mailing list