I'm at SHDH26 right now. We now have a fancy login system that prints out name tags for you!
Tom Harrison, Ernesto S., and David S. had most of the system working last night, with the exception of the automatic label printer. This morning rndmcnlly and I got the printer working in about 2 hours!
Here is how we did it:
First we had to get the printer working on a Mac, this was pretty easy. We downloaded the drivers and set up the printer though the normal means.
After that we wrote the following two files:
Media: Label 162 288 10 10 152 278
- Use the command enscript --list-media to make sure that your .enscriptrc is being parsed.
- Use man enscript for more info
- The numbers are in Postscript points!
from twisted.web.resource import Resource from twisted.web import server from twisted.internet import reactor from subprocess import * class Launcher(Resource): isLeaf = True def render_POST(self, request): names = ['first_name', 'last_name'] items = map((lambda l: request.args[l]), names) page = "\n".join(items) p = Popen(["enscript", "-r", "-B", "-f", "Helvetica35", "-MLabel"],stdin=PIPE) p.stdin.write(page) p.stdin.close() return page reactor.listenTCP(1080, server.Site(Launcher())) reactor.run()
(rndmcnlly — wrote all the python, I just figured out the enscript syntax)
Once the files were written, we ran the printer server using the "python printer_server.py command.
The printer server above listens on port TCP 1080, we had to change the port number because Comcast sucks and blocks that port.
The server listens on port 1080 for a HTTP POST and prints the value "first_name" on the first line and "last_name" on the second line.
Labels are printed by the web application sending a HTTP POST to the port of the computer connected to the printer - we had to set up port forwarding to get this working.
Unfortunately we didn't have time to implement Lee Felsenstein's suggestion to let people "tag" themselves. We'll have that working by the next SHDH - maybe even just let people go freeform on their tags.
Tom's end goal for this is to eventually have a "DevHouse Appliance" that other people could easily set up to do the same thing!