File: xmlrpcserver.py

package info (click to toggle)
libvirt 0.4.6-10%2Blenny2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 29,084 kB
  • ctags: 8,508
  • sloc: ansic: 75,483; xml: 11,901; sh: 10,518; python: 4,309; makefile: 863; perl: 356; awk: 48; sed: 16
file content (49 lines) | stat: -rwxr-xr-x 961 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python

#
# xmlrpcserver.py: simple server for XML-RPC tests
#
# Copyright (C) 2005 Red Hat, Inc.
#
# See COPYING.LIB for the License of this software
#
# Karel Zak <kzak@redhat.com>
#
# $Id: xmlrpcserver.py,v 1.1 2006/05/09 15:35:46 kzak Exp $
#
#
# simple client:
#
# >>> import xmlrpclib
# >>> s=xmlrpclib.Server('http://localhost:8000')
# >>> s.plus(10,10)
# 20
#

import sys
from SimpleXMLRPCServer import SimpleXMLRPCServer

SERVER_PORT = 8000


class VirtRPCServer(SimpleXMLRPCServer):
    def _dispatch(self, method, params):
        try:
            func = getattr(self, 'test_' + method)
        except AttributeError:
            raise Exception('method "%s" is not supported' % method)
        else:
            return func(*params)

    def test_plus(self, x, y):
        return x + y


server = VirtRPCServer(("localhost", SERVER_PORT))
server.serve_forever()



# vim: set tabstop=4:
# vim: set shiftwidth=4:
# vim: set expandtab: