From 31f6e3be77b57cdbf750a7909f0e24b6691262dc Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 23 Oct 2012 10:59:42 -0400 Subject: [PATCH] Make the client name a global property of the Humbug client. (imported from commit 3401686986a2670b3636e99fb11761c07a934bca) --- common.py | 6 +++--- zephyr_mirror.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common.py b/common.py index 494a2f1..3fd3f84 100644 --- a/common.py +++ b/common.py @@ -11,19 +11,19 @@ assert(requests.__version__ > '0.12') class HumbugAPI(): 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.email = email self.verbose = verbose self.base_url = site self.retry_on_errors = retry_on_errors + self.client_name = client def do_api_query(self, request, url): had_error_retry = False request["email"] = self.email request["api-key"] = self.api_key - if "client" not in request: - request["client"] = "API" + request["client"] = self.client_name while True: try: res = requests.post(urlparse.urljoin(self.base_url, url), data=request, verify=True) diff --git a/zephyr_mirror.py b/zephyr_mirror.py index 9b55917..0725149 100755 --- a/zephyr_mirror.py +++ b/zephyr_mirror.py @@ -69,6 +69,7 @@ import api.common humbug_client = api.common.HumbugAPI(email=options.user + "@mit.edu", api_key=api_key, verbose=True, + client="zephyr_mirror", site=options.site) start_time = time.time() @@ -99,7 +100,6 @@ def send_humbug(zeph): elif isinstance(zeph[key], str): zeph[key] = zeph[key].decode("utf-8") - zeph['client'] = "zephyr_mirror" return humbug_client.send_message(zeph) def fetch_fullname(username):