File: xmlrpc_test2.py

package info (click to toggle)
kamailio 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 56,100 kB
  • sloc: ansic: 552,832; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (29 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (2)
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
import xmlrpclib, httplib, sys

# Usage:  python xmlrpc_test2.py command [params...]
#
# python script for sending an xmlrpc command to ser's xmlrpc module.
# This script uses python xmlrpclib directly and expects the remote side to
# immediately close the connection after answering (broken xmlrpclib 
# behaviour).
# There are 2 way to make it work with ser xmlrpc module: define a
# better transport class (that's what the xmlrpc_test.py script is doing) or
# change ser xmlrpc route so that it will close the connection after each
# processes xmlrpc request (e.g. add a drop -1 at the end).
#
# See also: xmlrpc_test.py (better version, using a redefined transport class).
#
# History:
# --------
#  2009-07-13  initial version (andrei)
#

XMLRPC_SERVER = "127.0.0.1"
XMLRPC_PORT = 5060


if len(sys.argv) < 2:
	sys.exit("Usage: "+sys.argv[0]+" rpc_command [args...]");
c=xmlrpclib.ServerProxy("http://" + XMLRPC_SERVER+ ":" + str(XMLRPC_PORT))
res=getattr(c, sys.argv[1])(*sys.argv[2:])
print res;