1
0
Fork 0
gnuviechadmin-historic/backend/xmlrpcservertest.py

27 lines
654 B
Python
Raw Normal View History

from DocXMLRPCServer import DocXMLRPCServer
import traceback
import pwd
class TestService:
def listUsers(self):
"""Lists all system users."""
entries = [":".join((item[0], str(item[2]), str(item[3]), item[4])) for item in pwd.getpwall() if item[0].find("usr")==0]
return "\n".join(entries)
def startRPCServer():
server = DocXMLRPCServer(("localhost", 8080))
server.register_introspection_functions()
server.register_instance(TestService())
try:
server.serve_forever()
except KeyboardInterrupt:
server.server_close()
if __name__ == "__main__":
service = TestService()
print service.listUsers()
startRPCServer()