Пример #1
0
 def get_stats(self):
     try:
         resp = requests.get(self.url)
         if self.parser == "json":
             parsed = self._parse_stats_json(resp.json())
         else:
             parsed = self._parse_stats_lines(resp.text)
         return parsed
     except RequestException as exc:
         self.logger.warn(
                 "Could not fetch statistics (%s), assume service down",
                 str(exc))
         return {}
Пример #2
0
 def check(self):
     self.uri = self.uri.lstrip('/')
     resp = requests.get(self.url)
     if resp.status_code != 200:
         return False
     return True