From 0fd6a1d808bc1717b1cbf731a00c83a045064096 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Mon, 1 Mar 2010 16:36:17 +0000 Subject: [PATCH] - Attempt to install drivers in the Device ID checker. --- system-config-printer-check-install.patch | 88 +++++++++++++++++++++++ system-config-printer.spec | 9 ++- 2 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 system-config-printer-check-install.patch diff --git a/system-config-printer-check-install.patch b/system-config-printer-check-install.patch new file mode 100644 index 0000000..dc0d72d --- /dev/null +++ b/system-config-printer-check-install.patch @@ -0,0 +1,88 @@ +diff -up system-config-printer-1.1.93/check-device-ids.py.check-install system-config-printer-1.1.93/check-device-ids.py +--- system-config-printer-1.1.93/check-device-ids.py.check-install 2010-02-27 10:33:00.000000000 +0000 ++++ system-config-printer-1.1.93/check-device-ids.py 2010-03-01 16:16:01.088735654 +0000 +@@ -20,6 +20,7 @@ + ## along with this program; if not, write to the Free Software + ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + ++import dbus + import cups + import cupshelpers + from cupshelpers.ppds import PPDs, ppdMakeModelSplit +@@ -27,10 +28,6 @@ import sys + + cups.setUser ('root') + c = cups.Connection () +-print "Fetching driver list" +-ppds = PPDs (c.getPPDs ()) +-ppds._init_ids () +-makes = ppds.getMakes () + + devices = None + if len (sys.argv) > 1 and sys.argv[1] == '--help': +@@ -66,14 +63,56 @@ if len (devices) == 0: + sys.exit (0) + + n = 0 ++device_ids = [] + for device, attrs in devices.iteritems (): + make_and_model = attrs.get ('device-make-and-model') + device_id = attrs.get ('device-id') + if not (make_and_model and device_id): + continue + ++ id_fields = cupshelpers.parseDeviceID (device_id) ++ this_id = "MFG:%s;MDL:%s;" % (id_fields['MFG'], id_fields['MDL']) ++ device_ids.append (this_id) + n += 1 + ++if device_ids: ++ try: ++ bus = dbus.SessionBus () ++ ++ print "Installing relevant drivers using session service" ++ try: ++ obj = bus.get_object ("org.freedesktop.PackageKit", ++ "/org/freedesktop/PackageKit") ++ proxy = dbus.Interface (obj, "org.freedesktop.PackageKit.Modify") ++ proxy.InstallPrinterDrivers (0, device_ids, ++ "hide-finished", timeout=3600) ++ except dbus.exceptions.DBusException, (e, r): ++ print "Ignoring exception: %s" % e ++ except dbus.exceptions.DBusException: ++ try: ++ bus = dbus.SystemBus () ++ ++ print "Installing relevant drivers using system service" ++ try: ++ obj = bus.get_object ("com.redhat.PrinterDriversInstaller", ++ "/com/redhat/PrinterDriversInstaller") ++ proxy = dbus.Interface (obj, ++ "com.redhat.PrinterDriversInstaller") ++ for device_id in device_ids: ++ id_dict = cupshelpers.parseDeviceID (device_id) ++ proxy.InstallDrivers (id_dict['MFG'], id_dict['MDL'], '', ++ timeout=3600) ++ except dbus.exceptions.DBusException: ++ print "Ignoring exception: %s" % e ++ except dbus.exceptions.DBusException: ++ print "D-Bus not available so skipping package installation" ++ ++ ++print "Fetching driver list" ++ppds = PPDs (c.getPPDs ()) ++ppds._init_ids () ++makes = ppds.getMakes () ++ + i = 1 + item = unichr (0x251c) + unichr (0x2500) + unichr (0x2500) + last = unichr (0x2514) + unichr (0x2500) + unichr (0x2500) +@@ -92,7 +131,7 @@ for device, attrs in devices.iteritems ( + print "%s %s: MFG:%s;MDL:%s;" % (line, make_and_model, + id_fields['MFG'], + id_fields['MDL']) +- ++ + try: + drivers = ppds.ids[id_fields['MFG'].lower ()][id_fields['MDL'].lower ()] + except KeyError: diff --git a/system-config-printer.spec b/system-config-printer.spec index 525c228..2694eeb 100644 --- a/system-config-printer.spec +++ b/system-config-printer.spec @@ -7,7 +7,7 @@ Summary: A printer administration tool Name: system-config-printer Version: 1.1.93 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2+ URL: http://cyberelk.net/tim/software/system-config-printer/ Group: System Environment/Base @@ -18,6 +18,7 @@ Source2: http://cyberelk.net/tim/data/pysmbc/pysmbc-%{pysmbc_version}.tar.bz2 Patch1: system-config-printer-no-epydoc.patch Patch2: system-config-printer-lowercase-mfg-mdl.patch Patch3: system-config-printer-import-gobject.patch +Patch4: system-config-printer-check-install.patch BuildRequires: cups-devel >= 1.2 BuildRequires: python-devel >= 2.4 @@ -78,7 +79,8 @@ printers. %setup -q -a 1 -a 2 %patch1 -p1 -b .no-epydoc %patch2 -p1 -b .lowercase-mfg-mdl -%patch3 -p1 -b .import_gobject +%patch3 -p1 -b .import-gobject +%patch4 -p1 -b .check-install %build %configure --with-udev-rules --with-polkit-1 @@ -195,6 +197,9 @@ rm -rf %buildroot exit 0 %changelog +* Mon Mar 1 2010 Tim Waugh - 1.1.93-3 +- Attempt to install drivers in the Device ID checker. + * Sun Feb 28 2010 Tim Waugh - 1.1.93-2 - Import gobject in gtkspinner.py.