system-config-printer/system-config-printer-check-install.patch

89 lines
3.3 KiB
Diff

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: