From 1c56788446edba275aa7d738a37fa479674149ce Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Mon, 18 Jan 2010 17:29:41 +0000 Subject: [PATCH] - Clean up temporary files when localizing statereason (bug #552768). --- clog1 | 2 +- system-config-printer-statereason-tmp.patch | 75 +++++++++++++++++++++ system-config-printer.spec | 3 + 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 system-config-printer-statereason-tmp.patch diff --git a/clog1 b/clog1 index c514542..897effa 100644 --- a/clog1 +++ b/clog1 @@ -1,2 +1,2 @@ * Mon Jan 18 2010 Tim Waugh - 1.1.16-9 -- Make sure serial device widgets are always initialized (bug #556488). +- Clean up temporary files when localizing statereason (bug #552768). diff --git a/system-config-printer-statereason-tmp.patch b/system-config-printer-statereason-tmp.patch new file mode 100644 index 0000000..9c79111 --- /dev/null +++ b/system-config-printer-statereason-tmp.patch @@ -0,0 +1,75 @@ +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 +-## Copyright (C) 2007, 2008, 2009 Red Hat, Inc. ++## Copyright (C) 2007, 2008, 2009, 2010 Red Hat, Inc. ++## Authors: ++## Tim Waugh ++## Jiri Popelka + + ## 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) diff --git a/system-config-printer.spec b/system-config-printer.spec index 781f400..7811a18 100644 --- a/system-config-printer.spec +++ b/system-config-printer.spec @@ -30,6 +30,7 @@ Patch12: system-config-printer-check-still-connecting.patch Patch13: system-config-printer-async-fallback.patch Patch14: system-config-printer-userdefault-traceback.patch Patch15: system-config-printer-serial-widgets.patch +Patch16: system-config-printer-statereason-tmp.patch Patch101: pycups-request-readio.patch @@ -106,6 +107,7 @@ printers. %patch13 -p1 -b .async-fallback %patch14 -p1 -b .userdefault-traceback %patch15 -p1 -b .serial-widgets +%patch16 -p1 -b .statereason-tmp pushd pycups-%{pycups_version} %patch101 -p1 -b .request-readio @@ -227,6 +229,7 @@ exit 0 %changelog * Mon Jan 18 2010 Tim Waugh - 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).