xmlrpclib mapping method names in dictionary
Patrick Price
no-email at nowhere.com
Fri Mar 14 14:31:25 EST 2003
I figured this out: I had to use the _dispatch method
> #!/bin/python
import SimpleXMLRPCServer
import os
cmds={'ps':'ps -eaf',
'df':'df -k',
'uptime':'uptime',
'who':'who',
'last':'last',
'iostat':'iostat',
}
class RegisteredFunctions:
def _dispatch(self, name, args):
if name in cmds:
a = os.popen(cmds[name])
l = a.readlines()
a.close()
return l
if __name__ == '__main__':
server=SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 9000))
server.register_instance(RegisteredFunctions())
server.serve_forever()
More information about the Python-list
mailing list