Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing twisted to process files
    primarykey
    data
    text
    <p>I'm trying to set up a twisted xmlrpc server, which will accept files from a client, process them, and return a file and result dictionary back.</p> <p>I've used python before, but never the twisted libraries. For my purposes security is a non issue, and the ssh protocol seems like overkill. It also has problems on the windows server, since <code>termios</code> is not available. </p> <p>So all of my research points to xmlrpc being the best way to accomplish this. However, there are two methods of file transfer available. Using the <code>xml binary data</code> method, or the <code>http request</code> method.</p> <p>Files can be up to a few hundred megs either way, so which method should I use? Sample code is appreciated, since I could find no documentation for file transfers over xml with twisted.</p> <p><strong>Update:</strong></p> <p>So it seems that serializing the file with <code>xmlrpclib.Binary</code> does not work for large files, or I'm using it wrong. Test code below:</p> <pre><code>from twisted.web import xmlrpc, server class Example(xmlrpc.XMLRPC): """ An example object to be published. """ def xmlrpc_echo(self, x): """ Return all passed args. """ return x def xmlrpc_add(self, a, b): """ Return sum of arguments. """ return a + b def xmlrpc_fault(self): """ Raise a Fault indicating that the procedure should not be used. """ raise xmlrpc.Fault(123, "The fault procedure is faulty.") def xmlrpc_write(self, f, location): with open(location, 'wb') as fd: fd.write(f.data) if __name__ == '__main__': from twisted.internet import reactor r = Example(allowNone=True) reactor.listenTCP(7080, server.Site(r)) reactor.run() </code></pre> <p>And the client code:</p> <pre><code>import xmlrpclib s = xmlrpclib.Server('http://localhost:7080/') with open('test.pdf', 'rb') as fd: f = xmlrpclib.Binary(fd.read()) s.write(f, 'output.pdf') </code></pre> <p>I get <code>xmlrpclib.Fault: &lt;Fault 8002: "Can't deserialize input: "&gt;</code> when I test this. Is it because the file is a pdf?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload