From b9325a09fa252b27305d9ca4aca706d22a2b3727 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) --- bots/check-mirroring | 2 +- bots/feedback-bot | 4 ++-- bots/gcal-bot | 2 +- bots/humbug_trac.py | 2 +- bots/send-nagios-notification | 2 +- bots/zephyr_mirror_backend.py | 2 +- examples/get-public-streams | 2 +- examples/list-subscriptions | 2 +- examples/print-messages | 2 +- examples/print-next-message | 2 +- examples/send-message | 2 +- examples/subscribe | 2 +- examples/unsubscribe | 2 +- humbug.py | 16 ++++++++-------- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bots/check-mirroring b/bots/check-mirroring index e1ab8ad..67f95dd 100755 --- a/bots/check-mirroring +++ b/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/bots/feedback-bot b/bots/feedback-bot index 7013a82..b1d521e 100755 --- a/bots/feedback-bot +++ b/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/bots/gcal-bot b/bots/gcal-bot index 0eb4c91..4e8a437 100755 --- a/bots/gcal-bot +++ b/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/bots/humbug_trac.py b/bots/humbug_trac.py index 3ebec98..2e1bf2e 100644 --- a/bots/humbug_trac.py +++ b/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/bots/send-nagios-notification b/bots/send-nagios-notification index 4a6a452..fc41a59 100755 --- a/bots/send-nagios-notification +++ b/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/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index 917a3a8..d9f5413 100755 --- a/bots/zephyr_mirror_backend.py +++ b/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/examples/get-public-streams b/examples/get-public-streams index b73449b..e21ef62 100755 --- a/examples/get-public-streams +++ b/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/examples/list-subscriptions b/examples/list-subscriptions index 2e85d76..63c5752 100755 --- a/examples/list-subscriptions +++ b/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/examples/print-messages b/examples/print-messages index 07b9a84..de23e9a 100755 --- a/examples/print-messages +++ b/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/examples/print-next-message b/examples/print-next-message index 9b12da0..b5ff53e 100755 --- a/examples/print-next-message +++ b/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/examples/send-message b/examples/send-message index 237ba50..f00e953 100755 --- a/examples/send-message +++ b/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/examples/subscribe b/examples/subscribe index fd102c7..fb75657 100755 --- a/examples/subscribe +++ b/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/examples/unsubscribe b/examples/unsubscribe index ad3a5ed..59ab4de 100755 --- a/examples/unsubscribe +++ b/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/humbug.py b/humbug.py index 9765173..fe02713 100644 --- a/humbug.py +++ b/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)