I'm setting up a server accepting XML-RPC calls using the SimpleXMLRPCServer class. Basically, what I have to do is send a zip-compressed file to the server, have the server unzip it and process it, after processing it the server is supposed to zip the file again, and send it back to the client.
I found a solution, but wanted to ask you if you think there's an easier way of doing this.
What I do at the client first is to compress the file (which is a .txt) using os.system("zip blah blah.txt"). Then I obtain the name of the compressed file (let's assume it is blah.zip). Once I have the name of the zip file, I do the following:
fd = open("blah.zip", 'r')
bin = xmlrpclib.Binary(fd.read())
bin = xmlrpclib.Binary(fd.read())
server.process(bin)
I obtain a file descriptor, read the data and stuff it in a Binary object, and send it to the server as a parameter to the process method.
Then, at the server script, I create a file, and write into it the data contained in that Binary object using the attribute .data. That way I'll have a new file with the data passed to the server. Then again I use os.system
(...) to unzip the data and recover the original content.
When I need to send content back to the client, the whole process is repeated.
My question is: do you think this is an appropiate way to exchange files between client and server? I'm relativately new to Python, and the task of the file exchange has been assigned to me. I haven't been able to find documentation on the subject, so any help would be appreciated.
If you need any more information about what I'm trying to do, just ask.
Thank you so much for your attention :)
-- http://mail.python.org/mailman/listinfo/python-list