How to print on the server from xmlrpc?

Asked by Martin Collins

I have a handheld unit running Windows CE 2003. I have written a client in python that uses xmlrpc to create and update some data in OpenERP. It then needs to print a report. I have the report running and being sent from the server to the client. Unfortunately WinCE 2003 has no printing facilities.
I need to tell the OpenERP server to send the report to a network printer instead. How can I do that?

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Collins
Solved:
Last query:
Last reply:
Revision history for this message
Martin Collins (mkc-steadfast) said :
#1

I found a pure python version of lpr but CUPS always thinks the job has 0 bytes and I don't have the time or inclination to debug CUPS.

I could not find a simple way to use IPP (there is pkipplib and also ipplib.py neither of which have much docs or an obvious way to submit a print job). PyCups is not an option, it relies on CUPS libraries which WinCE does not have.

I have found (in some Suse docs) a simple way to sidestep the problem.
On the server add this line to /etc/inetd.conf:

    9100 stream tcp nowait lp /usr/bin/lp lp -d <name_of_printer_queue>

then you can just send the report straight to port 9100 with a simple socket:

    string_pdf = base64.decodestring(report['result'])
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((PRINT_SERVER, 9100))
    s.send(string_pdf)
    s.close()

Revision history for this message
Davide Corio (enlightx-deactivatedaccount) said :
#2

what about the printjob addon?

Revision history for this message
Martin Collins (mkc-steadfast) said :
#3

From addons-extra. Yes, I noticed that a long time ago, decided I'd check it out one of these days, never got round to it and then when I actually needed it completely forgot it existed!
Oh well, at least I learned something useful instead. I wonder how long I'll remember it...

Revision history for this message
Martin Collins (mkc-steadfast) said :
#4

From addons-extra. Yes, I noticed that a long time ago, decided I'd check it out one of these days, never got round to it and then when I actually needed it completely forgot it existed!
Oh well, at least I learned something useful instead. I wonder how long I'll remember it...

Revision history for this message
Martin Collins (mkc-steadfast) said :
#5

Whoops, I forgot I already posted that :-)
Not really, it's Launchpad's fault, it said I couldn't connect and to try again.