diff --git a/bots/check-mirroring b/bots/check-mirroring index 39d4322..e1ab8ad 100755 --- a/bots/check-mirroring +++ b/bots/check-mirroring @@ -6,6 +6,7 @@ import os import random import logging import subprocess +from os import path parser = optparse.OptionParser() parser.add_option('--verbose', @@ -33,13 +34,14 @@ mit_user = 'tabbott/extra@ATHENA.MIT.EDU' humbug_user = 'tabbott/extra@mit.edu' sys.path.append(".") -sys.path.append(os.path.dirname(os.path.dirname(__file__))) -import api.common -humbug_client = api.common.HumbugAPI(email=humbug_user, - api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - verbose=True, - client="test: Humbug API", - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +humbug_client = humbug.HumbugAPI( + email=humbug_user, + api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + verbose=True, + client="test: Humbug API", + site=options.site) # Configure logging log_file = "/home/humbug/check-mirroring-log" diff --git a/bots/feedback-bot b/bots/feedback-bot index 1845d28..7013a82 100755 --- a/bots/feedback-bot +++ b/bots/feedback-bot @@ -2,17 +2,20 @@ import sys import os import optparse +from os import path -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) -import api.common -prod_client = api.common.HumbugAPI(email="feedback@humbughq.com", - api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - verbose=True, - site="https://humbughq.com") -staging_client = api.common.HumbugAPI(email="feedback@humbughq.com", - api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - verbose=True, - site="https://staging.humbughq.com") +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +prod_client = humbug.HumbugAPI( + email="feedback@humbughq.com", + api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + verbose=True, + site="https://humbughq.com") +staging_client = humbug.HumbugAPI( + email="feedback@humbughq.com", + api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + verbose=True, + site="https://staging.humbughq.com") def forward_message(message): if message["type"] != "personal": diff --git a/bots/gcal-bot b/bots/gcal-bot index 8447caa..0eb4c91 100755 --- a/bots/gcal-bot +++ b/bots/gcal-bot @@ -10,8 +10,8 @@ import itertools import traceback from os import path -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug parser = optparse.OptionParser(r""" @@ -91,10 +91,11 @@ def get_calendar_url(): calendar_url = get_calendar_url() -humbug = api.common.HumbugAPI(email=options.user, - api_key=options.api_key, - site=options.site, - verbose=True) +humbug = humbug.HumbugAPI( + email=options.user, + api_key=options.api_key, + site=options.site, + verbose=True) def get_events(): feed = CalendarClient().GetCalendarEventFeed(uri=calendar_url) diff --git a/bots/humbug_trac.py b/bots/humbug_trac.py index c45df8c..3ebec98 100644 --- a/bots/humbug_trac.py +++ b/bots/humbug_trac.py @@ -18,11 +18,12 @@ from trac.core import Component, implements from trac.ticket import ITicketChangeListener import sys -sys.path.append("/home/humbug/humbug") -import api.common -client = api.common.HumbugAPI(email="humbug+trac@humbughq.com", - site="https://staging.humbughq.com", - api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") +sys.path.append("/home/humbug/humbug/api") +import humbug +client = humbug.HumbugAPI( + email="humbug+trac@humbughq.com", + site="https://staging.humbughq.com", + api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") def markdown_ticket_url(ticket, heading="ticket"): return "[%s #%s](https://trac.humbughq.com/ticket/%s)" % (heading, ticket.id, ticket.id) diff --git a/bots/send-nagios-notification b/bots/send-nagios-notification index 77a6b35..4a6a452 100755 --- a/bots/send-nagios-notification +++ b/bots/send-nagios-notification @@ -3,8 +3,8 @@ import sys import optparse from os import path -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug # Nagios passes the notification details as command line options. # In Nagios, "output" means "first line of output", and "long @@ -43,7 +43,7 @@ if output: # Block-quote any command output. msg['content'] += ('\n\n' + '\n'.join('> ' + ln for ln in output.splitlines())) -client = api.common.HumbugAPI( +client = humbug.HumbugAPI( 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 f9a5680..917a3a8 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -774,7 +774,9 @@ if __name__ == "__main__": (options, args) = parse_args() - sys.path[:0] = [options.root_path, os.path.join(options.root_path, "python-zephyr"), + sys.path[:0] = [options.root_path, + os.path.join(options.root_path, 'api'), + os.path.join(options.root_path, "python-zephyr"), os.path.join(options.root_path, "python-zephyr/build/lib.linux-x86_64-2.6/")] # In case this is an automated restart of the mirroring script, @@ -794,12 +796,13 @@ or specify the --api-key-file option.""" % (options.api_key_file,))) # don't need to read it in os.environ["HUMBUG_API_KEY"] = api_key - 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) + import humbug + humbug_client = humbug.HumbugAPI( + email=options.user + "@mit.edu", + api_key=api_key, + verbose=True, + client="zephyr_mirror", + site=options.site) start_time = time.time() diff --git a/examples/get-public-streams b/examples/get-public-streams index b999e12..b73449b 100755 --- a/examples/get-public-streams +++ b/examples/get-public-streams @@ -37,11 +37,12 @@ parser.add_option('--api-key') parser.add_option('--user') (options, args) = parser.parse_args() -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common -client = api.common.HumbugAPI(email=options.user, - api_key=options.api_key, - verbose=True, - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +client = humbug.HumbugAPI( + email=options.user, + api_key=options.api_key, + verbose=True, + site=options.site) print client.get_public_streams() diff --git a/examples/list-subscriptions b/examples/list-subscriptions index 60c2587..2e85d76 100755 --- a/examples/list-subscriptions +++ b/examples/list-subscriptions @@ -37,11 +37,12 @@ parser.add_option('--api-key') parser.add_option('--user') (options, args) = parser.parse_args() -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common -client = api.common.HumbugAPI(email=options.user, - api_key=options.api_key, - verbose=True, - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +client = humbug.HumbugAPI( + email=options.user, + api_key=options.api_key, + verbose=True, + site=options.site) print client.list_subscriptions() diff --git a/examples/print-messages b/examples/print-messages index 3556824..07b9a84 100755 --- a/examples/print-messages +++ b/examples/print-messages @@ -37,12 +37,13 @@ parser.add_option('--api-key') parser.add_option('--user') (options, args) = parser.parse_args() -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common -client = api.common.HumbugAPI(email=options.user, - api_key=options.api_key, - verbose=True, - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +client = humbug.HumbugAPI( + email=options.user, + api_key=options.api_key, + verbose=True, + site=options.site) def print_message(message): print message diff --git a/examples/print-next-message b/examples/print-next-message index dd3eea4..9b12da0 100755 --- a/examples/print-next-message +++ b/examples/print-next-message @@ -37,11 +37,12 @@ parser.add_option('--api-key') parser.add_option('--user') (options, args) = parser.parse_args() -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common -client = api.common.HumbugAPI(email=options.user, - api_key=options.api_key, - verbose=True, - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +client = humbug.HumbugAPI( + email=options.user, + api_key=options.api_key, + verbose=True, + site=options.site) print client.get_messages({}) diff --git a/examples/send-message b/examples/send-message index 15ee25d..237ba50 100755 --- a/examples/send-message +++ b/examples/send-message @@ -44,12 +44,13 @@ parser.add_option('--type', default='private') if len(args) == 0: parser.error("You must specify recipients") -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common -client = api.common.HumbugAPI(email=options.sender, - api_key=options.api_key, - verbose=True, - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +client = humbug.HumbugAPI( + email=options.sender, + api_key=options.api_key, + verbose=True, + site=options.site) message_data = { "type": options.type, diff --git a/examples/subscribe b/examples/subscribe index d391be1..fd102c7 100755 --- a/examples/subscribe +++ b/examples/subscribe @@ -38,12 +38,13 @@ parser.add_option('--site', default='https://humbughq.com') parser.add_option('--streams', default='') (options, args) = parser.parse_args() -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common -client = api.common.HumbugAPI(email=options.user, - api_key=options.api_key, - verbose=True, - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +client = humbug.HumbugAPI( + email=options.user, + api_key=options.api_key, + verbose=True, + site=options.site) if options.streams == "": print >>sys.stderr, "Usage:", parser.usage diff --git a/examples/unsubscribe b/examples/unsubscribe index 0a1ad83..ad3a5ed 100755 --- a/examples/unsubscribe +++ b/examples/unsubscribe @@ -38,12 +38,13 @@ parser.add_option('--site', default='https://humbughq.com') parser.add_option('--streams', default='') (options, args) = parser.parse_args() -sys.path.append(path.join(path.dirname(__file__), '../..')) -import api.common -client = api.common.HumbugAPI(email=options.user, - api_key=options.api_key, - verbose=True, - site=options.site) +sys.path.append(path.join(path.dirname(__file__), '..')) +import humbug +client = humbug.HumbugAPI( + email=options.user, + api_key=options.api_key, + verbose=True, + site=options.site) if options.streams == "": print >>sys.stderr, "Usage:", parser.usage diff --git a/common.py b/humbug.py similarity index 100% rename from common.py rename to humbug.py