rpms/hal-cups-utils/devel hal-cups-utils-syslog.patch, NONE, 1.1 hal-cups-utils.spec, 1.46, 1.47
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Sun Dec 17 15:25:41 UTC 2006
Author: twaugh
Update of /cvs/dist/rpms/hal-cups-utils/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv10271
Modified Files:
hal-cups-utils.spec
Added Files:
hal-cups-utils-syslog.patch
Log Message:
* Sun Dec 17 2006 Tim Waugh <twaugh at redhat.com>
- Added syslogging to hal_lpadmin.
hal-cups-utils-syslog.patch:
hal_lpadmin | 68 +++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 43 insertions(+), 25 deletions(-)
--- NEW FILE hal-cups-utils-syslog.patch ---
--- hal-cups-utils-0.6.2/systemv/hal_lpadmin.syslog 2006-12-17 15:24:06.000000000 +0000
+++ hal-cups-utils-0.6.2/systemv/hal_lpadmin 2006-12-17 15:24:30.000000000 +0000
@@ -1,7 +1,9 @@
#!/bin/env python
import dbus, sys, os
+import traceback
sys.path.append("/usr/share/system-config-printer")
import cups, cupshelpers, foomatic
+from syslog import *
class HalPrinter:
def __init__(self):
@@ -64,6 +66,7 @@
printer.device_uri == self.properties.get("linux.device.file", False)):
if not printer.enabled:
printer.setEnabled(True)
+ syslog (LOG_INFO, "Re-enabled printer %s" % name)
found = True
pass
if found:
@@ -80,21 +83,17 @@
ppd=ppd, info="Added by HAL")
self.cups_connection.enablePrinter(self.name)
self.cups_connection.acceptJobs(self.name)
-
- # XXX log
+ syslog (LOG_INFO, "Added printer %s" % name)
else:
# ask eggcups
- try:
- bus = dbus.SystemBus()
- obj = bus.get_object("com.redhat.PrintDriverSelection",
- "/com/redhat/PrintDriverSelection")
- interface = dbus.Interface(obj, "com.redhat.PrintDriverSelection")
- interface.PromptPrintDriver(self.make, self.model,
- self.uid, self.name)
- except:
- # XXX Error handling
- pass
-
+ syslog (LOG_INFO, "Prompting for driver for printer %s" % name)
+ bus = dbus.SystemBus()
+ obj = bus.get_object("com.redhat.PrintDriverSelection",
+ "/com/redhat/PrintDriverSelection")
+ interface = dbus.Interface(obj, "com.redhat.PrintDriverSelection")
+ interface.PromptPrintDriver(self.make, self.model,
+ self.uid, self.name)
+
def remove(self):
printers = cupshelpers.getPrinters(self.cups_connection)
@@ -104,6 +103,7 @@
printer.device_uri == self.properties.get("linux.device.file", False)):
if printer.enabled:
printer.setEnabled(False)
+ syslog (LOG_INFO, "Disabled printer %s" % name)
# XXX log, error handling
def configure(self):
@@ -115,17 +115,26 @@
f = foomatic.Foomatic()
printer = f.getMakeModel(make, model)
- if not printer: return
+ if not printer:
+ syslog (LOG_ERR,
+ "User-selected make/model \"%s\" \"%s\" not found" %
+ (make, model))
+ return
ppd = printer.getPPD()
-
- if ppd:
- # add printer
- self.cups_connection.addPrinter(
- self.name, device=self.get_cups_uri(),
- ppd=ppd, info="Added by HAL")
- self.cups_connection.enablePrinter(self.name)
- self.cups_connection.acceptJobs(self.name)
+ if not ppd:
+ syslog (LOG_ERR,
+ "Failed to get PPD for %s %s" % (make, model))
+ return
+
+ # add printer
+ self.cups_connection.addPrinter(
+ self.name, device=self.get_cups_uri(),
+ ppd=ppd, info="Added by HAL")
+ self.cups_connection.enablePrinter(self.name)
+ self.cups_connection.acceptJobs(self.name)
+ syslog (LOG_INFO,
+ "Added printer %s with user-selected make/model" % name)
class HalLpAdmin:
@@ -140,7 +149,7 @@
elif sys.argv[1]=="--configure":
self.configurePrinter()
else:
- return usage()
+ return self.usage()
def usage(self):
print "Usage: hal_lpadmin (--add|--remove|--configure)"
@@ -158,8 +167,17 @@
printer.configure()
def main():
+ openlog ("hal_lpadmin", 0, LOG_DAEMON)
try:
h = HalLpAdmin()
- except Exception, e:
- pass # XXX error handling
+ except:
+ (type, value, tb) = sys.exc_info ()
+ tblast = traceback.extract_tb (tb, limit=None)
+ if len (tblast):
+ tblast = tblast[:len (tblast) - 1]
+ for line in traceback.format_tb (tb):
+ syslog (LOG_ERR, line.strip ())
+ extxt = traceback.format_exception_only (type, value)
+ syslog (LOG_ERR, extxt[0].strip ())
+
main()
Index: hal-cups-utils.spec
===================================================================
RCS file: /cvs/dist/rpms/hal-cups-utils/devel/hal-cups-utils.spec,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- hal-cups-utils.spec 9 Nov 2006 12:30:03 -0000 1.46
+++ hal-cups-utils.spec 17 Dec 2006 15:25:39 -0000 1.47
@@ -12,6 +12,7 @@
Patch3: hal-cups-utils-introspection.patch
Patch4: hal-cups-utils-match-commandset.patch
Patch5: hal-cups-utils-ieee1284.patch
+Patch6: hal-cups-utils-syslog.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: glib2-devel
BuildRequires: dbus-devel >= 0.60
@@ -40,6 +41,7 @@
%patch3 -p1 -b .introspection
%patch4 -p0 -b .match-commandset
%patch5 -p1 -b .ieee1284
+%patch6 -p1 -b .syslog
%build
@@ -75,6 +77,9 @@
%{_initrddir}/cups-config-daemon
%changelog
+* Sun Dec 17 2006 Tim Waugh <twaugh at redhat.com>
+- Added syslogging to hal_lpadmin.
+
* Thu Nov 9 2006 Tim Waugh <twaugh at redhat.com> - 0.6.2-7
- IEEE 1284 Device ID in CUPS backend (bug #214755).
More information about the fedora-cvs-commits
mailing list