- Attempt to install drivers in the Device ID checker.

This commit is contained in:
Tim Waugh 2010-03-01 16:36:24 +00:00
parent 7ac71a21f6
commit 7a8c466203
2 changed files with 95 additions and 2 deletions

View File

@ -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:

View File

@ -7,7 +7,7 @@
Summary: A printer administration tool Summary: A printer administration tool
Name: system-config-printer Name: system-config-printer
Version: 1.1.93 Version: 1.1.93
Release: 2%{?dist} Release: 3%{?dist}
License: GPLv2+ License: GPLv2+
URL: http://cyberelk.net/tim/software/system-config-printer/ URL: http://cyberelk.net/tim/software/system-config-printer/
Group: System Environment/Base 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 Patch1: system-config-printer-no-epydoc.patch
Patch2: system-config-printer-lowercase-mfg-mdl.patch Patch2: system-config-printer-lowercase-mfg-mdl.patch
Patch3: system-config-printer-import-gobject.patch Patch3: system-config-printer-import-gobject.patch
Patch4: system-config-printer-check-install.patch
BuildRequires: cups-devel >= 1.2 BuildRequires: cups-devel >= 1.2
BuildRequires: python-devel >= 2.4 BuildRequires: python-devel >= 2.4
@ -78,7 +79,8 @@ printers.
%setup -q -a 1 -a 2 %setup -q -a 1 -a 2
%patch1 -p1 -b .no-epydoc %patch1 -p1 -b .no-epydoc
%patch2 -p1 -b .lowercase-mfg-mdl %patch2 -p1 -b .lowercase-mfg-mdl
%patch3 -p1 -b .import_gobject %patch3 -p1 -b .import-gobject
%patch4 -p1 -b .check-install
%build %build
%configure --with-udev-rules --with-polkit-1 %configure --with-udev-rules --with-polkit-1
@ -195,6 +197,9 @@ rm -rf %buildroot
exit 0 exit 0
%changelog %changelog
* Mon Mar 1 2010 Tim Waugh <twaugh@redhat.com> - 1.1.93-3
- Attempt to install drivers in the Device ID checker.
* Sun Feb 28 2010 Tim Waugh <twaugh@redhat.com> - 1.1.93-2 * Sun Feb 28 2010 Tim Waugh <twaugh@redhat.com> - 1.1.93-2
- Import gobject in gtkspinner.py. - Import gobject in gtkspinner.py.