Created
July 28, 2020 20:51
-
-
Save restump/8e2b34f55088d53b966a6beb62af7ba2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def doHttpRequest(self, verb, url, headers=None, data=None): | |
options = {} | |
if headers: | |
options["headers"] = headers | |
if data: | |
options["data"] = data | |
try: | |
r = self.http._request(verb.lower(), url, options) | |
r.raise_for_status() | |
except requests.exceptions.HTTPError as e: | |
msg = "request error: {}".format(e) | |
self.log.error(msg) | |
self.service_check(self.service_check_name, 2, message=msg, tags=self.tags) | |
return None | |
except Exception as e: | |
msg = "request error: {}".format(e) | |
self.log.error(msg) | |
self.service_check(self.service_check_name, 2, message=msg, tags=self.tags) | |
return None | |
return r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment