-
Notifications
You must be signed in to change notification settings - Fork 23
/
xmlrpctest.py
executable file
·34 lines (29 loc) · 932 Bytes
/
xmlrpctest.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Quick XMLRPC connection test via /RPC2"""
import sys
import socket
import xmlrpclib
from datetime import datetime
def main(args):
"""XMLRPC /RPC2 test."""
host = 'localhost'
if len(args) >= 1:
host = args[0]
url = "https://{}/RPC2".format(host)
print("Connecting to {!r}...".format(url))
server = xmlrpclib.ServerProxy(url)
print(server)
try:
print("Session: %s" % server.session.name())
print("XMLRPC methods: %d" % len(server.system.listMethods()))
time_usec = server.system.time_usec()
print("Time (µsec): %d (%s)" % (
time_usec, datetime.fromtimestamp(time_usec/1E6).isoformat()))
except (socket.error, xmlrpclib.Error) as cause:
print("ERROR: %s" % cause)
return 1
else:
print("OK")
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))