From 6e83a42ff4a7fb64ff00672dec0e45664cb6f779 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 23 Dec 2020 23:45:34 -0700 Subject: [PATCH] Adding python3 support and gutenprint packages --- Dockerfile | 14 +++++++++----- root/root/airprint-generate.py | 12 +++++++----- root/root/run_cups.sh | 10 ++++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 014baf5..9652fa7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,17 +8,21 @@ RUN echo "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositorie cups-client \ cups-filters \ cups-dev \ + gutenprint \ + gutenprint-libs \ + gutenprint-doc \ + gutenprint-cups \ ghostscript \ avahi \ inotify-tools \ - python \ - python-dev \ - py-pip \ + python3 \ + python3-dev \ + py3-pip \ build-base \ wget \ rsync \ - && pip --no-cache-dir install --upgrade pip \ - && pip install pycups \ + && pip3 --no-cache-dir install --upgrade pip \ + && pip3 install pycups \ && rm -rf /var/cache/apk/* # This will use port 631 diff --git a/root/root/airprint-generate.py b/root/root/airprint-generate.py index 989f63b..9fb5895 100644 --- a/root/root/airprint-generate.py +++ b/root/root/airprint-generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Copyright (c) 2010 Timothy J Fontaine @@ -22,9 +22,10 @@ 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 +import urllib.parse as urlparse import os.path -from StringIO import StringIO +from io import StringIO from xml.dom.minidom import parseString from xml.dom import minidom @@ -43,7 +44,8 @@ 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' + print('Failed to find python libxml or elementtree, please install one of those or use python >= 2.5') + raise XML_TEMPLATE = """ @@ -121,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 = urlparse.urlparse(v['printer-uri-supported']) diff --git a/root/root/run_cups.sh b/root/root/run_cups.sh index 618fcf6..dbda4de 100644 --- a/root/root/run_cups.sh +++ b/root/root/run_cups.sh @@ -2,6 +2,16 @@ set -e set -x +# Is CUPSADMIN set? If not, set to default +if [ -z "$CUPSADMIN" ]; then + CUPSADMIN="cupsadmin" +fi + +# Is CUPSPASSWORD set? If not, set to $CUPSADMIN +if [ -z "$CUPSPASSWORD" ]; then + CUPSPASSWORD=$CUPSADMIN +fi + if [ $(grep -ci $CUPSADMIN /etc/shadow) -eq 0 ]; then adduser -S -G lpadmin --no-create-home $CUPSADMIN fi