b74405729e83584ddf5f767cf9204cf31d1121ac
[tests.git] / system / url_scanner.py
1 # a utility for testing xmlrpclib URL's
2 # should probably 
3 import xmlrpclib
4 auth={'AuthMethod':'password','Username':'root@test.onelab.eu','AuthString':'test++'}
5
6 host='vplc21'
7
8 import socket
9 hostname="%s.pl.sophia.inria.fr"%host
10 ip=socket.gethostbyname(hostname)
11
12 import traceback
13 verbose=True
14
15 def try_url (url,xmlrpclib_verbose=False):
16     try:
17         xmlrpclib.ServerProxy (url, verbose=xmlrpclib_verbose, allow_none=True).GetNodes(auth)
18         print 'YES',url
19     except xmlrpclib.ProtocolError as e:
20         print '... (http error %s)'%e.errcode,url
21     except Exception as e:
22         print '---',type(e).__name__,url
23         if verbose: traceback.print_exc()
24
25 def scan():
26     for protocol in ['http','https']:
27         for dest in [ hostname, ip ]:
28             for port in [ '',':80',':443']:
29 #            for port in [ ':80',':443']:
30                 for path in ['PLCAPI','PLCAPI/']:
31                     if protocol=='http' and port==':443': continue
32                     if protocol=='https' and port==':80': continue
33                     url="%s://%s%s/%s"%(protocol,dest,port,path)
34                     try_url (url)
35