Skip to content

Instantly share code, notes, and snippets.

@mouseroot
Created August 31, 2012 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mouseroot/3549560 to your computer and use it in GitHub Desktop.
Save mouseroot/3549560 to your computer and use it in GitHub Desktop.
XMLRPC Client/Server
#!/usr/bin/python
import xmlrpclib,os
def main():
cli = xmlrpclib.Server("http://192.168.0.2:1337")
for file in os.listdir("send-files"):
print file
if os.path.isdir("send-files/" + file) == True:
print "Dir:",file
else:
data = open("send-files/" + file,"rb").read()
cli.send_file(file,xmlrpclib.Binary(data))
if __name__ == "__main__":
main()
#!/usr/bin/python
import SimpleXMLRPCServer
def send_file(name,data):
print "Recv filename: ",name
fh = open("recv-files/"+name,"w")
fh.write(data.data)
fh.close()
return True
def main():
print "Application server"
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0",1337))
server.register_function(send_file)
server.serve_forever()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment