tjfontaine / airprint-generate

Automatically generate AirPrint Avahi service files for CUPS printers
http://www.atxconsulting.com/blog/tjfontaine/2010/11/21/automatically-generate-airprint-avahi-service-files-cups-printers
400 stars 119 forks source link

Does this script work with CentOs 8 #21

Closed branx86 closed 3 years ago

branx86 commented 4 years ago

Does this script work with CentOs 8 when ran with python 3.6.8 I experience error:
./airprint-generate.py Traceback (most recent call last): File "./airprint-generate.py", line 306, in apg.generate() File "./airprint-generate.py", line 140, in generate uri = urlparse.urlparse(v['printer-uri-supported']) NameError: name 'urlparse' is not defined

shaiku commented 4 years ago

See https://stackoverflow.com/questions/48072619/how-can-i-import-urlparse-in-python-3

urlparse is from python2.7. This script needs to be updated to work with python3.

danielkappelle commented 4 years ago

Or you could just use Python2.7 to run the script, install pycups for python2 (i think something like pip2 install pycups and change the first line of script to #!/usr/bin/env python2

silviucc commented 4 years ago

Hi, I got AirPrint working on Fedora 31, so this may help on Centos 8 as well.

Modify the script to use python2 as pointed out by @danielkappelle

You need to install these packages: python2-devel cups-devel Then you install pycups for python2: sudo pip2 install pycups

You can check whether the script works or not by running it in the directory where you downloaded it. If it generates a .service file then it's ok to do:

sudo ./airprint-generate.py -d /etc/avahi/services

Restart Avahi: sudo systemctl restart avahi-daemon

Checking the status of avahi-daemon should list the newly created AirPrint service: sudo systemctl status avahi-daemon

branx86 commented 4 years ago

Thank you Thank you the script works in Centos 8 when install these packages: python2-devel cups-devel Then you install pycups for python2: sudo pip2 install pycups you can then run normal the script sudo ./airprint-generate.py -d /etc/avahi/services silviucc I cannot thank you enough for the suggestion

crazyjpeters commented 4 years ago

I'm a bit unclear on how changing a commented line has any effect on the script?

!/usr/bin/env python2

With python2-devel cups-devel installed, I get errors when running pip2 install pycups. error: 'gcc' failed with exit status 1

silviucc commented 4 years ago

@crazyjpeters If you try to run that pip2 command without sudo, it will fail. Please check my other comment.

crazyjpeters commented 4 years ago

sorry, it still fails for me. sudo or not. Is there anything that could keep pycups from getting installed?

silviucc commented 4 years ago

Can you copy and paste the full log to a file and then attach it here?

crazyjpeters commented 4 years ago

pycups install fail gcc.log

crazyjpeters commented 4 years ago

Not sure if it matters, but this is on a Centos8 minimal installation in a VM.

silviucc commented 4 years ago

Maybe you are missing a proper build environment...

Try this link: https://linuxconfig.org/install-development-tools-on-redhat-8

Since you are logged as root, you don't need to use sudo.

crazyjpeters commented 4 years ago

Nada. Even with the entire development tools installed, same error. I run Plex server and Squeezebox server on the same machine. Either or both have python used. Do you think it could have something to do with that?

silviucc commented 4 years ago

Sorry. I honestly have no idea. Maybe someone else will...

crazyjpeters commented 4 years ago

I'd be curious to know what type of install this worked on. I've tried with Minimal, and Minimal-server with development tools installed. same error happens. looks like I'm not the only one with the problem: https://www.linuxbabe.com/redhat/cups-print-server-centos-8-bounjour-ipp-samba-airprint#comments

branx86 commented 4 years ago

Hi I have airprint working on CentOs 8 core install just had to install pycups for python 2 using the "pip2 install pycups" and install the "yum install python2-devel cups-devel" Then the script airprint-generate.py ran perfectly. Hoe this helps

On Fri, May 15, 2020 at 10:05 AM crazyjpeters notifications@github.com wrote:

I'd be curious to know what type of install this worked on. I've tried with Minimal, and Minimal-server with development tools installed. same error happens. looks like I'm not the only one with the problem: https://www.linuxbabe.com/redhat/cups-print-server-centos-8-bounjour-ipp-samba-airprint#comments

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjfontaine/airprint-generate/issues/21#issuecomment-629285370, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZRDQSOWPDBHLMRDJE3VBDRRVKZXANCNFSM4KDRNARQ .

-- --branx86@gmail.com Solution Provider (I will find you a answer!)

branx86 commented 4 years ago

sorry forgot to say CentOS Linux release 8.1.1911 (Core)

On Sat, May 16, 2020 at 2:19 AM Bran x86 branx86@gmail.com wrote:

Hi I have airprint working on CentOs 8 core install just had to install pycups for python 2 using the "pip2 install pycups" and install the "yum install python2-devel cups-devel" Then the script airprint-generate.py ran perfectly. Hoe this helps

On Fri, May 15, 2020 at 10:05 AM crazyjpeters notifications@github.com wrote:

I'd be curious to know what type of install this worked on. I've tried with Minimal, and Minimal-server with development tools installed. same error happens. looks like I'm not the only one with the problem: https://www.linuxbabe.com/redhat/cups-print-server-centos-8-bounjour-ipp-samba-airprint#comments

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjfontaine/airprint-generate/issues/21#issuecomment-629285370, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZRDQSOWPDBHLMRDJE3VBDRRVKZXANCNFSM4KDRNARQ .

-- --branx86@gmail.com Solution Provider (I will find you a answer!)

-- --branx86@gmail.com Solution Provider (I will find you a answer!)

crazyjpeters commented 4 years ago

Well, that's the same install I'm using, though, I'm not sure if you're running yours as a VM or not. What steps/guide are you using for your CUPS install? I wonder if I'm following the same steps as you are. I wonder also - I'm using CUPS to share a router connected USB printer, that is socket://192.168.xxx.1:9100. Are you running a printer that's directly connected to your machine?

branx86 commented 4 years ago

I’m not running in a VM. Just a plain instance of cups connected to two network printers. I used this to setup my AirPrint: https://www.marcus-povey.co.uk/2011/11/11/howto-printing-to-any-printer-with-an-ipadiphone-and-apple-airprint/

Sent from my Apple ][ e

On May 17, 2020, at 9:35 PM, crazyjpeters notifications@github.com wrote:

 Well, that's the same install I'm using, though, I'm not sure if you're running yours as a VM or not. What steps/guide are you using for your CUPS install? I wonder if I'm following the same steps as you are. I wonder also - I'm using CUPS to share a router connected USB printer, that is socket://192.168.xxx.1:9100. Are you running a printer that's directly connected to your machine?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

branx86 commented 4 years ago

just a quick note of all the cups programs installed:

cups 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system cups-client 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dclient&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - client programs cups-devel 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Ddevel&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - development environment cups-filesystem 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilesystem&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - directory layout cups-filters 1.20.0-18.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilters&version=1%2E20%2E0%2D18%2Eel8 Unspecified OpenPrinting CUPS filters and backends cups-filters-devel 1.20.0-18.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilters%2Ddevel&version=1%2E20%2E0%2D18%2Eel8 Unspecified OpenPrinting CUPS filters and backends - development environment cups-filters-libs 1.20.0-18.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilters%2Dlibs&version=1%2E20%2E0%2D18%2Eel8 Unspecified OpenPrinting CUPS filters and backends - cupsfilters and fontembed libraries cups-ipptool 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dipptool&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - tool for performing IPP requests cups-libs 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dlibs&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - libraries cups-libs 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dlibs&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - libraries cups-lpd 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dlpd&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - lpd emulation cups-pk-helper 0.2.6-5.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dpk%2Dhelper&version=0%2E2%2E6%2D5%2Eel8 System Environment/Base A helper that makes system-config-printer use PolicyKit gutenprint-cups 5.2.14-3.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=gutenprint%2Dcups&version=5%2E2%2E14%2D3%2Eel8 Unspecified CUPS drivers for Canon, Epson, HP and compatible printers python-cups-doc 1.9.72-21.el8.0.1 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=python%2Dcups%2Ddoc&version=1%2E9%2E72%2D21%2Eel8%2E0%2E1 Unspecified Documentation for python-cups python3-cups 1.9.72-21.el8.0.1 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=python3%2Dcups&version=1%2E9%2E72%2D21%2Eel8%2E0%2E1 Unspecified Python3 bindings for CUPS API, known as pycups.

On Sun, May 17, 2020 at 11:21 PM Branx86 Gmail branx86@gmail.com wrote:

I’m not running in a VM. Just a plain instance of cups connected to two network printers. I used this to setup my AirPrint: https://www.marcus-povey.co.uk/2011/11/11/howto-printing-to-any-printer-with-an-ipadiphone-and-apple-airprint/

Sent from my Apple ][ e

On May 17, 2020, at 9:35 PM, crazyjpeters notifications@github.com wrote:



Well, that's the same install I'm using, though, I'm not sure if you're running yours as a VM or not. What steps/guide are you using for your CUPS install? I wonder if I'm following the same steps as you are. I wonder also - I'm using CUPS to share a router connected USB printer, that is socket://192.168.xxx.1:9100. Are you running a printer that's directly connected to your machine?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjfontaine/airprint-generate/issues/21#issuecomment-629913473, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZRDQWRZIZQMHPWTPGEHALRSCNGNANCNFSM4KDRNARQ .

-- --branx86@gmail.com Solution Provider (I will find you a answer!)

rchenzheng commented 3 years ago

just a quick note of all the cups programs installed: cups 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system cups-client 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dclient&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - client programs cups-devel 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Ddevel&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - development environment cups-filesystem 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilesystem&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - directory layout cups-filters 1.20.0-18.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilters&version=1%2E20%2E0%2D18%2Eel8 Unspecified OpenPrinting CUPS filters and backends cups-filters-devel 1.20.0-18.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilters%2Ddevel&version=1%2E20%2E0%2D18%2Eel8 Unspecified OpenPrinting CUPS filters and backends - development environment cups-filters-libs 1.20.0-18.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dfilters%2Dlibs&version=1%2E20%2E0%2D18%2Eel8 Unspecified OpenPrinting CUPS filters and backends - cupsfilters and fontembed libraries cups-ipptool 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dipptool&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - tool for performing IPP requests cups-libs 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dlibs&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - libraries cups-libs 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dlibs&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - libraries cups-lpd 2.2.6-28.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dlpd&version=2%2E2%2E6%2D28%2Eel8 Unspecified CUPS printing system - lpd emulation cups-pk-helper 0.2.6-5.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=cups%2Dpk%2Dhelper&version=0%2E2%2E6%2D5%2Eel8 System Environment/Base A helper that makes system-config-printer use PolicyKit gutenprint-cups 5.2.14-3.el8 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=gutenprint%2Dcups&version=5%2E2%2E14%2D3%2Eel8 Unspecified CUPS drivers for Canon, Epson, HP and compatible printers python-cups-doc 1.9.72-21.el8.0.1 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=python%2Dcups%2Ddoc&version=1%2E9%2E72%2D21%2Eel8%2E0%2E1 Unspecified Documentation for python-cups python3-cups 1.9.72-21.el8.0.1 https://c-73-206-10-246.hsd1.tx.comcast.net:10000/software/edit_pack.cgi?search=cups&package=python3%2Dcups&version=1%2E9%2E72%2D21%2Eel8%2E0%2E1 Unspecified Python3 bindings for CUPS API, known as pycups. On Sun, May 17, 2020 at 11:21 PM Branx86 Gmail @.> wrote: I’m not running in a VM. Just a plain instance of cups connected to two network printers. I used this to setup my AirPrint: https://www.marcus-povey.co.uk/2011/11/11/howto-printing-to-any-printer-with-an-ipadiphone-and-apple-airprint/ Sent from my Apple ][ e On May 17, 2020, at 9:35 PM, crazyjpeters @.> wrote:  Well, that's the same install I'm using, though, I'm not sure if you're running yours as a VM or not. What steps/guide are you using for your CUPS install? I wonder if I'm following the same steps as you are. I wonder also - I'm using CUPS to share a router connected USB printer, that is socket://192.168.xxx.1:9100. Are you running a printer that's directly connected to your machine? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#21 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZRDQWRZIZQMHPWTPGEHALRSCNGNANCNFSM4KDRNARQ . -- --branx86@gmail.com Solution Provider (I will find you a answer!)

Your issue is related to python versioning, it was originally coded in python2.

If you're still interested, you can get this working by using docker from my fork until it makes it to upstream master

https://github.com/rchenzheng/airprint-generate#docker-containerized-avahi-service-generation

tjfontaine commented 3 years ago

much of this has been resolved in 0384693e462ee6a0bf9237a839d73d4c6a720cd3 to accommodate working with python3, I would suggest you build the container from the included Dockerfile for running though.