Comment archive for Automatically generate AirPrint Avahi service files for CUPS printers
Worked perfectly!
Submitted by Anonymous (not verified) on Tue, 11/23/2010 - 12:30am.
Thanks for this script, it vastly simplified my services configuration for this. I've jotted down my setup notes on my homepage, hopefully this can help people figure out they don't need to buy a bunch of new printers for their iPhones.
CentOS - line 28 error
Submitted by reckless2k2 (not verified) on Tue, 11/23/2010 - 7:25am.
I'm running CentOS 5 and I'm getting an error at line 28:
from xml.etree.ElementTree import Element, ElementTree, tostring
Any help?
I did python yourscriptname
It's likely the python in
Submitted by tjfontaine on Tue, 11/23/2010 - 12:38pm.
It's likely the python in centos 5 is < 2.5, please let me know if python-lxml is available and I'll refactor the code to use one code path or another and then error out if neither is available.
I've pushed an updated
Submitted by tjfontaine on Tue, 11/23/2010 - 1:44pm. I've pushed an updated version that uses python libxml bindings (which is available in the EPEL repository) through out, or tries to find python elementtree, and then errors out if you're on python less than 2.5, please test and let me know the results
I really appreciate the help.
Submitted by reckless2k2 (not verified) on Tue, 11/23/2010 - 4:16pm.
I really appreciate the help. I have libxml2-2.6.26-2.1.2.8-el5_5.1 and libxslt-1.1.17-2.el5_2.2. I'm in python 2.4 with no path to 2.5. I pulled you latest script and am now getting the following errors:
[root@mail airprint]# python airprint-generate.py
Traceback (most recent call last):
File "airprint-generate.py", line 250, in ?
apg.generate()
File "airprint-generate.py", line 135, in generate
port_no = uri.port
AttributeError: 'tuple' object has no attribute 'port'
Thanks again.
I have just pushed a new
Submitted by tjfontaine on Tue, 11/23/2010 - 4:28pm.
I have just pushed a new version that I believe will handle more of the python 2.4 case, please inspect the resulting xml, the record starting with rp= should not contain a hostname or etc, it should only be something like: /printers/myprinter
SUCCESS!!!
Submitted by reckless2k2 (not verified) on Tue, 11/23/2010 - 4:34pm.
Thank you very much. The new script worked. Thanks for the quick response. This script now supports back to python 2.4.
Thanks again.
python 2.4
Submitted by reckless2k2 (not verified) on Tue, 11/23/2010 - 4:06pm.
I did find that I'm using python 2.4 without an ability to upgrade without serious instability in my system. I was able to install python-lxml 1.3.4-1.el5.rf but I'm still getting line 28 errors. Do you have a new code for me to use?
Thanks.
This is the error I keep
Submitted by reckless2k2 (not verified) on Tue, 11/23/2010 - 11:18am.
This is the error I keep getting using CentOS 5:
ImportError: No module named etree.ElementTree
Any help is appreciated. Thanks.
It works!
Submitted by Steven Stern (not verified) on Tue, 11/23/2010 - 11:49am.
I added ServerAlias * to cupsd.conf, restarted cups, restarted avahi-daemon, and I can print from my phone. Thanks!
(Fedora 14)
Getting an error
Submitted by Neil (not verified) on Tue, 11/23/2010 - 2:56pm.
Thanks for this. Unfortunately, I get an error (Python 2.6)
Traceback (most recent call last):
File "./airprint_generate.py", line 245, in
apg.generate()
File "./airprint_generate.py", line 135, in generate
port.text = '%d' % uri.port
TypeError: %d format: a number is required, not NoneType
I had another friend have
Submitted by tjfontaine on Tue, 11/23/2010 - 3:08pm.
I had another friend have this error, I've committed a fix for this part, but it's likely that the rp= record will also be broken, for some reason urlparse is failing to parse the ipp uri. If you could let me know what the value in v['printer-uri-supported'] is, and more information about your environment I would appreciate it.
Hi, v['printer-uri-supported'
Submitted by Neil (not verified) on Wed, 11/24/2010 - 6:12am.
Hi,
v['printer-uri-supported'] is ipp://localhost:631/printers/HP-LaserJet-1020
I'm using Ubuntu 9.04 with CUPS 1.3.9. Let me know if you need anything else.
Thanks.
I've committed a fix that
Submitted by tjfontaine on Wed, 11/24/2010 - 3:05pm.
I've committed a fix that uses a regex to try and grab the proper path, I'm not thrilled to have to do it and I'm not sure why urlparse is failing in these cases
printer disappears
Submitted by ben (not verified) on Wed, 11/24/2010 - 12:45am.
Great script it worked like a charm on my Ubuntu server. I am having a strange problem though. After restarting avahi, the printer shows up only briefly on my Iphone. If I wait a few minutes it no longer shows up, I have to restart avahi and wash rinse repeat. I can't get it to stay advertised.
I'm having exactly the same
Submitted by Jackal (not verified) on Fri, 11/26/2010 - 10:22pm.
I'm having exactly the same problem with fedora 9. Works great for a minute or so the I have to restate avahi dae,on to get it working again. Anyone know how to fix.
Indeed - me 2
Submitted by hybris (not verified) on Sun, 03/06/2011 - 12:36pm.
I have the same issue with my Ubuntu 9.04. Remains visible for a couple of minutes and the disappears :(
alos dissapears
Submitted by Richard (not verified) on Fri, 11/18/2011 - 4:16am.
On debian 6, also the printer dissapears after couple minutes. anyone a solution?
Minor problem, easy fix for me...
Submitted by john (not verified) on Wed, 11/24/2010 - 10:57am.
Running ubuntu 9.04, your script generated a rp line as:
rp=//localhost:631/printers/PDF
This caused the actual request to be malformed, if I edit the generated file to just be
rp=/printers/PDF
it works fine. Dunno if its something with my config or not, but figured I'd pass along the info.
Thanks for the script :)
That's the right fix, it's
Submitted by tjfontaine on Wed, 11/24/2010 - 11:17am.
That's the right fix, it's something to do with urlparse, I'm not sure why but certain python builds don't properly split the url, I'll be adding a backup regex in the event I notice it's happening, but it won't be fool proof
Works on Ubuntu 8.04
Submitted by Anonymous (not verified) on Wed, 11/24/2010 - 3:54pm.
Great script! It works on Ubuntu 8.04 with Python 2.5.2. In order to handle the output from the iPhone, I used the service file only for the printer that uses the Foomatic/hpijs driver. I suspect this performs the PDF filter that Ryan Finnie's web page mentions. After copying the service file into /etc/avahi/services directory and I was done.
Works! OpenSUSE 11.3
Submitted by Mike Roeder (not verified) on Wed, 11/24/2010 - 5:53pm.
This script worked great on my OpenSUSE 11.3 system with CUPS. Avahi service is already in place in this OS and is used for managing SSH (apparently).
After enabling remote printing in CUPS, I also had to add
ServerAlias *
to /etc/cups/cupsd.conf
Tested on iPad and iPhone.
Thanks!
Just saying thanks and sharing my own experience with the script
Submitted by Nick (not verified) on Fri, 11/26/2010 - 11:58am.
Thanks for the great work.
http://www.fiorellonj.com/wp/2010/11/airprint-using-ubuntu-server-and-a-...
Cannot run python script :(
Submitted by Rune (not verified) on Tue, 11/30/2010 - 4:13pm.
File "airprint-generate.py", line 46
raise 'Failed to find python libxml or elementtree....
I am not a Linux expert, and I am trying to get python to run this generate script on my Mybook World Edition, but keeps getting this error. Have installed python 2.5.2, libxml and elementtree, but maybe something more need to be done?
Help apreciated!
The best, RUne
Awesome
Submitted by xiffy (not verified) on Sat, 12/04/2010 - 9:35am.
Just a quick hello and more importantly, a big thank you. This script just saved my day while i was figuring out what i had misconfigured in my handwritten service-file. Running Centos5, the script worked after installing python-lxml (yum install python-lxml).
Cheers!
DEB Package
Submitted by QB89Dragon (not verified) on Tue, 12/28/2010 - 6:05pm.
Thanks for your great work with this. I took some of this script and built a DEB package that does all configuration to get airprint working on install, uses DBus for avahi instead of service files and will add and remove printers from avahi as they are added and removed from cups. I hope this may be of use to someone.
http://gtk-apps.org/content/show.php/Apple+AirPrint+Support+for+Ubuntu?c...
Syntax Error
Submitted by Johann Wein (not verified) on Sun, 01/02/2011 - 9:57am.
Hi,
I got this error message:
sudo python airprint-generate.py
File "airprint-generate.py", line 6
Is there something similar for android based devices ?
Submitted by Anand Shah (not verified) on Mon, 01/03/2011 - 7:03pm.
I would like to print from android based applications... Is there something similar to AirPrint (I have checked out Printer Share etc/.,) but am looking for more of an open source or default solution...
Doesn’t work
Submitted by Anonymous (not verified) on Wed, 04/27/2011 - 8:51am.
./airprint-generate.py: 6: Syntax error: newline unexpected
doesn`t work
Submitted by Anonymous (not verified) on Sun, 05/29/2011 - 5:28am.
I tried to install it on an new Opensuse 11.4 Gnome system.
./airprint-generate.py: 6: Syntax error: newline unexpected
All libs are installed like python-lxml and pyton cups ...
Any ideas?
Greetings
pastebin.ca/2054694
Submitted by Anonymous (not verified) on Fri, 05/06/2011 - 5:53pm.
pastebin.ca/2054694
You need to install the
Submitted by tjfontaine on Fri, 05/06/2011 - 6:08pm.
You need to install the python cups package, on debian/ubuntu like machines: apt-get install python-cups
Amazing.
Submitted by Anonymous (not verified) on Tue, 06/14/2011 - 10:44pm.
Thanks! This script made things real easy! After opening up the permissions on cups, this works go good!