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 {}
def check(self): self.uri = self.uri.lstrip('/') resp = requests.get(self.url) if resp.status_code != 200: return False return True