apache.py 文件源码

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

项目:plugins 作者: site24x7 项目源码 文件源码
def metricCollector2(self):
        try:
            if (self._userName and self._userPass):
                    password_mgr = urllib2.HTTPPasswordMgr()
                    password_mgr.add_password(self._realm, self._url, self._userName, self._userPass)
                    auth_handler = urllib2.HTTPBasicAuthHandler(password_mgr)
                    opener = urllib2.build_opener(auth_handler)
                    urllib2.install_opener(opener)
            response = urllib2.urlopen(self._url, timeout=10)
            if response.getcode() == 200:
                byte_responseData = response.read()
                str_responseData = byte_responseData.decode('UTF-8')
                self._parseStats(str_responseData)
            else:
                self.dictApacheData['status'] = 0
                self.dictApacheData['msg'] = 'Error_code' + str(response.getcode())
        except HTTPError as e:
            self.dictApacheData['status'] = 0
            self.dictApacheData['msg'] = 'Error_code : HTTP Error ' + str(e.code)
        except URLError as e:
            self.dictApacheData['status'] = 0
            self.dictApacheData['msg'] = 'Error_code : URL Error ' + str(e.reason)
        except InvalidURL as e:
            self.dictApacheData['status'] = 0
            self.dictApacheData['msg'] = 'Error_code : Invalid URL'
        except Exception as e:
            self.dictApacheData['status'] = 0
            self.dictApacheData['msg'] = 'Exception occured in collecting data : ' + str(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号