xmlrpclib mapping method names in dictionary

Patrick Price no-email at nowhere.com
Fri Mar 14 20:31:25 CET 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',

class RegisteredFunctions:

         def _dispatch(self, name, args):
                 if name in cmds:
                         a = os.popen(cmds[name])
                         l = a.readlines()
                         return l

if __name__ == '__main__':
         server=SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 9000))

More information about the Python-list mailing list