From 9125489c2008c577bef02f48f1243a47e81d37ec Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Mon, 3 Dec 2012 12:24:49 -0500 Subject: [PATCH] Rename class HumbugAPI to Client (imported from commit 4270f31fc5febcd9c444d0d133a1dad3860618f0) --- api/bots/check-mirroring | 2 +- api/bots/feedback-bot | 4 ++-- api/bots/gcal-bot | 2 +- api/bots/humbug_trac.py | 2 +- api/bots/send-nagios-notification | 2 +- api/bots/zephyr_mirror_backend.py | 2 +- api/examples/get-public-streams | 2 +- api/examples/list-subscriptions | 2 +- api/examples/print-messages | 2 +- api/examples/print-next-message | 2 +- api/examples/send-message | 2 +- api/examples/subscribe | 2 +- api/examples/unsubscribe | 2 +- api/humbug.py | 16 ++++++++-------- tools/inject-messages/inject-messages | 2 +- tools/post-receive | 2 +- tools/review | 2 +- 17 files changed, 25 insertions(+), 25 deletions(-) diff --git a/api/bots/check-mirroring b/api/bots/check-mirroring index e1ab8adb72..67f95dda6f 100755 --- a/api/bots/check-mirroring +++ b/api/bots/check-mirroring @@ -36,7 +36,7 @@ humbug_user = 'tabbott/extra@mit.edu' sys.path.append(".") sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -humbug_client = humbug.HumbugAPI( +humbug_client = humbug.Client( email=humbug_user, api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", verbose=True, diff --git a/api/bots/feedback-bot b/api/bots/feedback-bot index 7013a82595..b1d521ebfc 100755 --- a/api/bots/feedback-bot +++ b/api/bots/feedback-bot @@ -6,12 +6,12 @@ from os import path sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -prod_client = humbug.HumbugAPI( +prod_client = humbug.Client( email="feedback@humbughq.com", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", verbose=True, site="https://humbughq.com") -staging_client = humbug.HumbugAPI( +staging_client = humbug.Client( email="feedback@humbughq.com", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", verbose=True, diff --git a/api/bots/gcal-bot b/api/bots/gcal-bot index 0eb4c91025..4e8a4379f3 100755 --- a/api/bots/gcal-bot +++ b/api/bots/gcal-bot @@ -91,7 +91,7 @@ def get_calendar_url(): calendar_url = get_calendar_url() -humbug = humbug.HumbugAPI( +humbug = humbug.Client( email=options.user, api_key=options.api_key, site=options.site, diff --git a/api/bots/humbug_trac.py b/api/bots/humbug_trac.py index 3ebec98838..2e1bf2e5fb 100644 --- a/api/bots/humbug_trac.py +++ b/api/bots/humbug_trac.py @@ -20,7 +20,7 @@ import sys sys.path.append("/home/humbug/humbug/api") import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email="humbug+trac@humbughq.com", site="https://staging.humbughq.com", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") diff --git a/api/bots/send-nagios-notification b/api/bots/send-nagios-notification index 4a6a452a69..fc41a595f9 100755 --- a/api/bots/send-nagios-notification +++ b/api/bots/send-nagios-notification @@ -43,7 +43,7 @@ if output: # Block-quote any command output. msg['content'] += ('\n\n' + '\n'.join('> ' + ln for ln in output.splitlines())) -client = humbug.HumbugAPI( +client = humbug.Client( email = 'humbug+nagios@humbughq.com', api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', site = 'https://staging.humbughq.com') diff --git a/api/bots/zephyr_mirror_backend.py b/api/bots/zephyr_mirror_backend.py index 917a3a8e7a..d9f5413260 100755 --- a/api/bots/zephyr_mirror_backend.py +++ b/api/bots/zephyr_mirror_backend.py @@ -797,7 +797,7 @@ or specify the --api-key-file option.""" % (options.api_key_file,))) os.environ["HUMBUG_API_KEY"] = api_key import humbug - humbug_client = humbug.HumbugAPI( + humbug_client = humbug.Client( email=options.user + "@mit.edu", api_key=api_key, verbose=True, diff --git a/api/examples/get-public-streams b/api/examples/get-public-streams index b73449bccb..e21ef62cff 100755 --- a/api/examples/get-public-streams +++ b/api/examples/get-public-streams @@ -39,7 +39,7 @@ parser.add_option('--user') sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email=options.user, api_key=options.api_key, verbose=True, diff --git a/api/examples/list-subscriptions b/api/examples/list-subscriptions index 2e85d762fe..63c575204f 100755 --- a/api/examples/list-subscriptions +++ b/api/examples/list-subscriptions @@ -39,7 +39,7 @@ parser.add_option('--user') sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email=options.user, api_key=options.api_key, verbose=True, diff --git a/api/examples/print-messages b/api/examples/print-messages index 07b9a84ae9..de23e9a77d 100755 --- a/api/examples/print-messages +++ b/api/examples/print-messages @@ -39,7 +39,7 @@ parser.add_option('--user') sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email=options.user, api_key=options.api_key, verbose=True, diff --git a/api/examples/print-next-message b/api/examples/print-next-message index 9b12da0b22..b5ff53eef9 100755 --- a/api/examples/print-next-message +++ b/api/examples/print-next-message @@ -39,7 +39,7 @@ parser.add_option('--user') sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email=options.user, api_key=options.api_key, verbose=True, diff --git a/api/examples/send-message b/api/examples/send-message index 237ba50916..f00e953474 100755 --- a/api/examples/send-message +++ b/api/examples/send-message @@ -46,7 +46,7 @@ if len(args) == 0: sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email=options.sender, api_key=options.api_key, verbose=True, diff --git a/api/examples/subscribe b/api/examples/subscribe index fd102c737a..fb756576db 100755 --- a/api/examples/subscribe +++ b/api/examples/subscribe @@ -40,7 +40,7 @@ parser.add_option('--streams', default='') sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email=options.user, api_key=options.api_key, verbose=True, diff --git a/api/examples/unsubscribe b/api/examples/unsubscribe index ad3a5ed4bb..59ab4deb68 100755 --- a/api/examples/unsubscribe +++ b/api/examples/unsubscribe @@ -40,7 +40,7 @@ parser.add_option('--streams', default='') sys.path.append(path.join(path.dirname(__file__), '..')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email=options.user, api_key=options.api_key, verbose=True, diff --git a/api/humbug.py b/api/humbug.py index 97651730d4..fe02713213 100644 --- a/api/humbug.py +++ b/api/humbug.py @@ -34,7 +34,7 @@ import os assert(requests.__version__ > '0.12') API_VERSTRING = "/api/v1/" -class HumbugAPI(object): +class Client(object): def __init__(self, email, api_key=None, api_key_file=None, verbose=False, retry_on_errors=True, site="https://humbughq.com", client="API"): @@ -173,10 +173,10 @@ class HumbugAPI(object): def _mk_subs(streams): return {'subscriptions': streams} -HumbugAPI._register('send_message', make_request=(lambda request: request)) -HumbugAPI._register('get_messages', longpolling=True) -HumbugAPI._register('get_profile') -HumbugAPI._register('get_public_streams') -HumbugAPI._register('list_subscriptions', url='subscriptions/list') -HumbugAPI._register('add_subscriptions', url='subscriptions/add', make_request=_mk_subs) -HumbugAPI._register('remove_subscriptions', url='subscriptions/remove', make_request=_mk_subs) +Client._register('send_message', make_request=(lambda request: request)) +Client._register('get_messages', longpolling=True) +Client._register('get_profile') +Client._register('get_public_streams') +Client._register('list_subscriptions', url='subscriptions/list') +Client._register('add_subscriptions', url='subscriptions/add', make_request=_mk_subs) +Client._register('remove_subscriptions', url='subscriptions/remove', make_request=_mk_subs) diff --git a/tools/inject-messages/inject-messages b/tools/inject-messages/inject-messages index ec25040d50..1639368df1 100755 --- a/tools/inject-messages/inject-messages +++ b/tools/inject-messages/inject-messages @@ -35,7 +35,7 @@ next_user = gen_next_user() def connect_all(users): for user in users: - users[user]['client'] = humbug.HumbugAPI( + users[user]['client'] = humbug.Client( email=user + '@humbughq.com', api_key=users[user]['api-key'], site=options.site, diff --git a/tools/post-receive b/tools/post-receive index 1f5580980d..ce64b75d2e 100755 --- a/tools/post-receive +++ b/tools/post-receive @@ -24,7 +24,7 @@ from os import path sys.path.append(path.join(path.dirname(os.readlink(__file__)), '../api')) import humbug -client = humbug.HumbugAPI( +client = humbug.Client( email="humbug+commits@humbughq.com", site="https://staging.humbughq.com", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", diff --git a/tools/review b/tools/review index 20527f877a..47346205f8 100755 --- a/tools/review +++ b/tools/review @@ -301,7 +301,7 @@ def main(args): sys.path.append(os.path.join(os.path.dirname(__file__), '../api')) import humbug me = get_current_user(repo) - client = humbug.HumbugAPI( + client = humbug.Client( email=me[me.index("<") + 1:me.index('>')], site="https://staging.humbughq.com", verbose=True)