1
0
forked from pool/cups-airprint
cups-airprint/python3.patch
Olav Reinert a5a154994e Accepting request 806255 from home:oreinert:branches:Printing
- python3.patch: Port script to python3
- pdf-support.patch: Fix printer discovery
- Add minimal build check to verify the script can run at all

OBS-URL: https://build.opensuse.org/request/show/806255
OBS-URL: https://build.opensuse.org/package/show/Printing/cups-airprint?expand=0&rev=7
2020-05-17 17:48:17 +00:00

79 lines
2.7 KiB
Diff

commit 86dda7081513a9999dcb73fd46ca88bd23a2b26d
Author: Álvaro Jurado <elbingmiss@gmail.com>
Date: Wed Feb 12 20:00:04 2020 +0100
Upgrading to python 3
Signed-off-by: Álvaro Jurado <elbingmiss@gmail.com>
diff --git a/airprint-generate.py b/airprint-generate.py
old mode 100755
new mode 100644
index 989f63b..1e23178
--- a/airprint-generate.py
+++ b/airprint-generate.py
@@ -22,9 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
-import cups, os, optparse, re, urlparse
+import cups, os, optparse, re, urllib.parse
import os.path
-from StringIO import StringIO
+from io import StringIO
from xml.dom.minidom import parseString
from xml.dom import minidom
@@ -70,6 +70,7 @@ DOCUMENT_TYPES = {
# These content-types will be at the front of the list
'application/pdf': True,
'application/postscript': True,
+ 'application/vnd.cups-postscript': True,
'application/vnd.cups-raster': True,
'application/octet-stream': True,
'image/urf': True,
@@ -124,7 +125,7 @@ class AirPrintGenerate(object):
for p, v in printers.items():
if v['printer-is-shared']:
attrs = conn.getPrinterAttributes(p)
- uri = urlparse.urlparse(v['printer-uri-supported'])
+ uri = urllib.parse.urlparse(v['printer-uri-supported'])
tree = ElementTree()
tree.parse(StringIO(XML_TEMPLATE.replace('\n', '').replace('\r', '').replace('\t', '')))
commit 6365eaf86f0f3128fbc03aa21f4eebd063334f4a
Author: Olav Reinert <seroton10@gmail.com>
Date: Sun May 17 16:38:03 2020 +0200
more python3 fixes
diff --git a/airprint-generate.py b/airprint-generate.py
index 29f1eef..6391b27 100644
--- a/airprint-generate.py
+++ b/airprint-generate.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
"""
Copyright (c) 2010 Timothy J Fontaine <tjfontaine@atxconsulting.com>
@@ -43,7 +43,7 @@ except:
from elementtree import Element, ElementTree, tostring
etree = None
except:
- raise 'Failed to find python libxml or elementtree, please install one of those or use python >= 2.5'
+ raise Exception('Failed to find python libxml or elementtree, please install one of those or use python >= 2.5')
XML_TEMPLATE = """<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
@@ -123,7 +123,7 @@ class AirPrintGenerate(object):
printers = conn.getPrinters()
- for p, v in printers.items():
+ for p, v in list(printers.items()):
if v['printer-is-shared']:
attrs = conn.getPrinterAttributes(p)
uri = urllib.parse.urlparse(v['printer-uri-supported'])