elasticsearchcluster.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:plugins 作者: site24x7 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号