def getData(self):
try:
### Create Authentication Handler for the HTTP Request
pwdmgr = urllib2.HTTPPasswordMgr()
pwdmgr.add_password(None, CLUSTERURL, USERNAME, PASSWORD)
auth = urllib2.HTTPBasicAuthHandler(pwdmgr)
### Create Proxy Handler for the HTTP Request
proxy = urllib2.ProxyHandler({}) # Uses NO Proxy
### Create a HTTP Request with the authentication and proxy handlers
opener = urllib2.build_opener(proxy, auth)
urllib2.install_opener(opener)
### Get HTTP Response
response = urllib2.urlopen(CLUSTERURL, timeout=10)
### Parse the response data
if response.getcode() == 200:
bytedata = response.read()
output = bytedata.decode()
self.data = self.parseClusterData(output)
else:
self.data['msg'] = str(response.getcode())
self.status = 0
except Exception as e:
self.data['msg'] = str(e)
self.status = 0
return self.data
评论列表
文章目录