rpms/system-config-printer/F-11 system-config-printer-statereason-tmp.patch, NONE, 1.1 system-config-printer.spec, 1.336, 1.337

Tim Waugh twaugh at fedoraproject.org
Mon Jan 18 17:28:22 UTC 2010


Author: twaugh

Update of /cvs/pkgs/rpms/system-config-printer/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv21070

Modified Files:
	system-config-printer.spec 
Added Files:
	system-config-printer-statereason-tmp.patch 
Log Message:
* Mon Jan 18 2010 Tim Waugh <twaugh at redhat.com> - 1.1.16-9
- Clean up temporary files when localizing statereason (bug #552768).


system-config-printer-statereason-tmp.patch:
 statereason.py |   44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

--- NEW FILE system-config-printer-statereason-tmp.patch ---
diff -up system-config-printer-1.1.16/statereason.py.statereason-tmp system-config-printer-1.1.16/statereason.py
--- system-config-printer-1.1.16/statereason.py.statereason-tmp	2009-12-22 14:44:19.000000000 +0000
+++ system-config-printer-1.1.16/statereason.py	2010-01-18 17:24:22.301560654 +0000
@@ -1,7 +1,9 @@
 #!/usr/bin/env python
 
-## Copyright (C) 2007, 2008, 2009 Tim Waugh <twaugh at redhat.com>
-## Copyright (C) 2007, 2008, 2009 Red Hat, Inc.
+## Copyright (C) 2007, 2008, 2009, 2010 Red Hat, Inc.
+## Authors:
+##  Tim Waugh <twaugh at redhat.com>
+##  Jiri Popelka <jpopelka at redhat.com>
 
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -18,6 +20,7 @@
 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 import cups
+import os
 
 _ = lambda x: x
 def set_gettext_function (fn):
@@ -41,6 +44,7 @@ class StateReason:
         self.level = None
         self.canonical_reason = None
         self.connection = connection
+        self._ppd = None
 
     def get_printer (self):
         return self.printer
@@ -125,21 +129,29 @@ class StateReason:
             elif self.get_level () == self.ERROR:
                 title = _("Printer error")
 
-            try:
-                f = self.connection.getPPD(self.printer)
-                ppd = cups.PPD (f)
-                schemes = ["text", "http", "help", "file"]
-                localized_reason = ""
-                for scheme in schemes:
-                    reason = ppd.localizeIPPReason(self.reason, scheme)
-                    if reason != None:
-                        localized_reason = localized_reason + reason + ", "
-                if localized_reason != "":
-                    reason = localized_reason[:-2]
-                else:
+            if not self._ppd:
+                try:
+                    f = self.connection.getPPD(self.printer)
+                    self._ppd = cups.PPD (f)
+                    os.unlink (f)
+                except (cups.IPPError, OSError):
+                    pass
+
+            if self._ppd:
+                try:
+                    schemes = ["text", "http", "help", "file"]
+                    localized_reason = ""
+                    for scheme in schemes:
+                        reason = self._ppd.localizeIPPReason(self.reason,
+                                                             scheme)
+                        if reason != None:
+                            localized_reason = localized_reason + reason + ", "
+                    if localized_reason != "":
+                        reason = localized_reason[:-2]
+                    else:
+                        reason = self.get_reason()
+                except RuntimeError:
                     reason = self.get_reason()
-            except (cups.IPPError, RuntimeError):
-                reason = self.get_reason()
 
             text = _("Printer '%s': '%s'.") % (self.get_printer (), reason)
         return (title, text)


Index: system-config-printer.spec
===================================================================
RCS file: /cvs/pkgs/rpms/system-config-printer/F-11/system-config-printer.spec,v
retrieving revision 1.336
retrieving revision 1.337
diff -u -p -r1.336 -r1.337
--- system-config-printer.spec	18 Jan 2010 17:05:13 -0000	1.336
+++ system-config-printer.spec	18 Jan 2010 17:28:22 -0000	1.337
@@ -29,6 +29,7 @@ Patch11: system-config-printer-check-sti
 Patch12: system-config-printer-async-fallback.patch
 Patch13: system-config-printer-userdefault-traceback.patch
 Patch14: system-config-printer-serial-widgets.patch
+Patch15: system-config-printer-statereason-tmp.patch
 
 Patch101: pycups-request-readio.patch
 
@@ -93,6 +94,7 @@ the configuration tool.
 %patch12 -p1 -b .async-fallback
 %patch13 -p1 -b .userdefault-traceback
 %patch14 -p1 -b .serial-widgets
+%patch15 -p1 -b .statereason-tmp
 
 pushd pycups-%{pycups_version}
 %patch101 -p1 -b .request-readio
@@ -204,6 +206,7 @@ exit 0
 
 %changelog
 * Mon Jan 18 2010 Tim Waugh <twaugh at redhat.com> - 1.1.16-9
+- Clean up temporary files when localizing statereason (bug #552768).
 - Make sure serial device widgets are always initialized (bug #556488).
 - Handle errors more gracefully in userdefault.py (bug #556345).
 - Don't rely on cups-pk-helper being around (bug #556170).



More information about the scm-commits mailing list