Make the client name a global property of the Humbug client.
(imported from commit 3401686986a2670b3636e99fb11761c07a934bca)
This commit is contained in:
parent
958b566333
commit
31f6e3be77
|
@ -11,19 +11,19 @@ assert(requests.__version__ > '0.12')
|
||||||
|
|
||||||
class HumbugAPI():
|
class HumbugAPI():
|
||||||
def __init__(self, email, api_key, verbose=False, retry_on_errors=True,
|
def __init__(self, email, api_key, verbose=False, retry_on_errors=True,
|
||||||
site="https://app.humbughq.com"):
|
site="https://app.humbughq.com", client="API"):
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
self.email = email
|
self.email = email
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.base_url = site
|
self.base_url = site
|
||||||
self.retry_on_errors = retry_on_errors
|
self.retry_on_errors = retry_on_errors
|
||||||
|
self.client_name = client
|
||||||
|
|
||||||
def do_api_query(self, request, url):
|
def do_api_query(self, request, url):
|
||||||
had_error_retry = False
|
had_error_retry = False
|
||||||
request["email"] = self.email
|
request["email"] = self.email
|
||||||
request["api-key"] = self.api_key
|
request["api-key"] = self.api_key
|
||||||
if "client" not in request:
|
request["client"] = self.client_name
|
||||||
request["client"] = "API"
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
res = requests.post(urlparse.urljoin(self.base_url, url), data=request, verify=True)
|
res = requests.post(urlparse.urljoin(self.base_url, url), data=request, verify=True)
|
||||||
|
|
|
@ -69,6 +69,7 @@ import api.common
|
||||||
humbug_client = api.common.HumbugAPI(email=options.user + "@mit.edu",
|
humbug_client = api.common.HumbugAPI(email=options.user + "@mit.edu",
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
verbose=True,
|
verbose=True,
|
||||||
|
client="zephyr_mirror",
|
||||||
site=options.site)
|
site=options.site)
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
@ -99,7 +100,6 @@ def send_humbug(zeph):
|
||||||
elif isinstance(zeph[key], str):
|
elif isinstance(zeph[key], str):
|
||||||
zeph[key] = zeph[key].decode("utf-8")
|
zeph[key] = zeph[key].decode("utf-8")
|
||||||
|
|
||||||
zeph['client'] = "zephyr_mirror"
|
|
||||||
return humbug_client.send_message(zeph)
|
return humbug_client.send_message(zeph)
|
||||||
|
|
||||||
def fetch_fullname(username):
|
def fetch_fullname(username):
|
||||||
|
|
Loading…
Reference in a new issue