File system-config-printer-more-checks.patch of Package system-config-printer

diff --git a/AdvancedServerSettings.py b/AdvancedServerSettings.py
index bd1f0de..2987136 100644
--- a/AdvancedServerSettings.py
+++ b/AdvancedServerSettings.py
@@ -128,7 +128,14 @@ class AdvancedServerSettingsDialog:
         # Fetch cupsd.conf
         f = tempfile.TemporaryFile ()
         try:
-            cupsconn.getFile (self.RESOURCE, file=f)
+            try:
+                self.cupsconn.getFile (self.RESOURCE, file=f)
+            except TypeError:
+                # Specifying a file object requires pycups >= 1.9.38
+                (fd, name) = tempfile.mkstemp ()
+                self.cupsconn.getFile (self.RESOURCE, name)
+                os.unlink (name)
+                f = os.fdopen (fd, "r+")
         except cups.HTTPError, s:
             show_HTTP_Error (s, dialog)
             raise
diff --git a/cupshelpers/cupshelpers.py b/cupshelpers/cupshelpers.py
index 5b9cbfc..eba5a7e 100755
--- a/cupshelpers/cupshelpers.py
+++ b/cupshelpers/cupshelpers.py
@@ -558,7 +558,11 @@ class _PrintersConf:
                 self.connection.getFile(file, filename)
         except cups.HTTPError, e:
             os.close(fd)
-            os.unlink(filename)
+            try:
+                os.unlink(filename)
+            except OSError:
+                pass
+
             if (e.args[0] == cups.HTTP_UNAUTHORIZED or
                 e.args[0] == cups.HTTP_NOT_FOUND):
                 return []
openSUSE Build Service is sponsored by