-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmlapi.py
More file actions
executable file
·31 lines (26 loc) · 805 Bytes
/
xmlapi.py
File metadata and controls
executable file
·31 lines (26 loc) · 805 Bytes
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
import urllib2
import sys
import re
import base64
from urlparse import urlparse
import os
import getopt
def api(arg):
theurl = 'http://127.0.0.1:2086/xml-api/' + arg
if os.path.exists('/root/.accesshash'):
hash = open("/root/.accesshash", 'r')
hashstring = hash.read()
hashstring = hashstring.replace('\n', '')
else:
print "Access key doesn't exist, Please Generate it in WHM"
sys.exit(1)
auth = 'WHM root:' + hashstring
req = urllib2.Request(theurl)
req.add_header("Authorization", auth)
try:
handle = urllib2.urlopen(req)
except IOError, e:
print "The Access key found but It looks like logins not working, Please regenerate it in WHM."
sys.exit(1)
thepage = handle.read()
return thepage