Timeout on file write?

Larry Bates lbates at swamisoft.com
Sat Jun 26 18:57:36 CEST 2004


Not tested, but you might want to take a look at:

http://www.geocities.com/dinceraydin/python/indexeng.html

second option, you could try something like:
p.write("whatever")
try:
    p.write("whatever")
    p.flush()

except:
      print "Write error on receipt printer"

p.close()

Just possible solutions, not tested.

HTH,
Larry Bates
Syscon, Inc.

"Chris Farley" <nbrewer at visi.com> wrote in message
news:40dda426$0$32608$a1866201 at newsreader.visi.com...
> I'm working on a cross-platform Python program that prints to a receipt
> printer.  The code is simple, I just do something like this:
>
> printer = file('/dev/lp0','w')          # on Win32, change to 'lpt1'
> p.write("whatever")
> p.close()
>
>
> I would like to gracefully handle situations such as when the paper is out
> or the printer is powered off. Right now the program just hangs.
>
> Suggestions? Thanks...





More information about the Python-list mailing list