XMLRPC Solution Code

Steve Holden steve at holdenweb.com
Tue Jul 18 02:32:38 EDT 2006


dylpkls91 wrote:
> costello.bob at gmail.com wrote:
> 
>>Mind posting it for us lesser beings? ;)
> 
> 
> Not at all. I have yet to test it on networked computers, but it works
> fine when I run both scripts on my machine.
> 
> The hard part now is getting the server code to run as a Windows
> service- argh!!!
> I can get it installed and started using modified code from:
> http://www.schooltool.org/products/schooltool-calendar/documentation/how-to/running-as-a-windows-service/schooltool-service.py/view
> 
> but for some reason when the server is a service the client refuses to
> connect properly!
> Grrr... anybody know why?
> 
Because there are specific requirements for Windows services, that your 
program isn't comlpying with.

> Here is the code for the server, the machine that will execute the
> commands:
> 
> import SimpleXMLRPCServer, os
> server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000))
> server.register_function(lambda command: os.popen4(command)[1].read(),
> "execute")
> server.serve_forever()
> 
> And here's the code for the client, the computer that will tell the
> server what command to execute:
> 
> import xmlrpclib
> server = xmlrpclib.Server("http://" + raw_input("Enter the IP address
> of the server: ") + ":8000")
> output = server.execute(raw_input("Enter a command for the server to
> execute: "))
> print output
> 

I'm afraid you'll need to Google for "python windows service" or 
similar: in essence the main thing the service has to do (besides serve) 
is ensure a continuous flow of messages through the system. It's ugly, 
but people have done it before.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list