Rename api.common to humbug

Fixes #482.

(imported from commit 1bd6a7fd993d8d5e225e0311c288dbce0c369a40)
This commit is contained in:
Keegan McAllister
2012-12-03 12:23:06 -05:00
parent f61c26c361
commit bd7b7adb6b
18 changed files with 120 additions and 98 deletions

View File

@@ -6,6 +6,7 @@ import os
import random import random
import logging import logging
import subprocess import subprocess
from os import path
parser = optparse.OptionParser() parser = optparse.OptionParser()
parser.add_option('--verbose', parser.add_option('--verbose',
@@ -33,9 +34,10 @@ mit_user = 'tabbott/extra@ATHENA.MIT.EDU'
humbug_user = 'tabbott/extra@mit.edu' humbug_user = 'tabbott/extra@mit.edu'
sys.path.append(".") sys.path.append(".")
sys.path.append(os.path.dirname(os.path.dirname(__file__))) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
humbug_client = api.common.HumbugAPI(email=humbug_user, humbug_client = humbug.HumbugAPI(
email=humbug_user,
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
verbose=True, verbose=True,
client="test: Humbug API", client="test: Humbug API",

View File

@@ -2,14 +2,17 @@
import sys import sys
import os import os
import optparse import optparse
from os import path
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
prod_client = api.common.HumbugAPI(email="feedback@humbughq.com", prod_client = humbug.HumbugAPI(
email="feedback@humbughq.com",
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
verbose=True, verbose=True,
site="https://humbughq.com") site="https://humbughq.com")
staging_client = api.common.HumbugAPI(email="feedback@humbughq.com", staging_client = humbug.HumbugAPI(
email="feedback@humbughq.com",
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
verbose=True, verbose=True,
site="https://staging.humbughq.com") site="https://staging.humbughq.com")

View File

@@ -10,8 +10,8 @@ import itertools
import traceback import traceback
from os import path from os import path
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
parser = optparse.OptionParser(r""" parser = optparse.OptionParser(r"""
@@ -91,7 +91,8 @@ def get_calendar_url():
calendar_url = get_calendar_url() calendar_url = get_calendar_url()
humbug = api.common.HumbugAPI(email=options.user, humbug = humbug.HumbugAPI(
email=options.user,
api_key=options.api_key, api_key=options.api_key,
site=options.site, site=options.site,
verbose=True) verbose=True)

View File

@@ -18,9 +18,10 @@ from trac.core import Component, implements
from trac.ticket import ITicketChangeListener from trac.ticket import ITicketChangeListener
import sys import sys
sys.path.append("/home/humbug/humbug") sys.path.append("/home/humbug/humbug/api")
import api.common import humbug
client = api.common.HumbugAPI(email="humbug+trac@humbughq.com", client = humbug.HumbugAPI(
email="humbug+trac@humbughq.com",
site="https://staging.humbughq.com", site="https://staging.humbughq.com",
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

View File

@@ -3,8 +3,8 @@ import sys
import optparse import optparse
from os import path from os import path
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
# Nagios passes the notification details as command line options. # Nagios passes the notification details as command line options.
# In Nagios, "output" means "first line of output", and "long # In Nagios, "output" means "first line of output", and "long
@@ -43,7 +43,7 @@ if output:
# Block-quote any command output. # Block-quote any command output.
msg['content'] += ('\n\n' + '\n'.join('> ' + ln for ln in output.splitlines())) msg['content'] += ('\n\n' + '\n'.join('> ' + ln for ln in output.splitlines()))
client = api.common.HumbugAPI( client = humbug.HumbugAPI(
email = 'humbug+nagios@humbughq.com', email = 'humbug+nagios@humbughq.com',
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
site = 'https://staging.humbughq.com') site = 'https://staging.humbughq.com')

View File

@@ -774,7 +774,9 @@ if __name__ == "__main__":
(options, args) = parse_args() (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/")] 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, # In case this is an automated restart of the mirroring script,
@@ -794,8 +796,9 @@ or specify the --api-key-file option.""" % (options.api_key_file,)))
# don't need to read it in # don't need to read it in
os.environ["HUMBUG_API_KEY"] = api_key os.environ["HUMBUG_API_KEY"] = api_key
import api.common import humbug
humbug_client = api.common.HumbugAPI(email=options.user + "@mit.edu", humbug_client = humbug.HumbugAPI(
email=options.user + "@mit.edu",
api_key=api_key, api_key=api_key,
verbose=True, verbose=True,
client="zephyr_mirror", client="zephyr_mirror",

View File

@@ -37,9 +37,10 @@ parser.add_option('--api-key')
parser.add_option('--user') parser.add_option('--user')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
client = api.common.HumbugAPI(email=options.user, client = humbug.HumbugAPI(
email=options.user,
api_key=options.api_key, api_key=options.api_key,
verbose=True, verbose=True,
site=options.site) site=options.site)

View File

@@ -37,9 +37,10 @@ parser.add_option('--api-key')
parser.add_option('--user') parser.add_option('--user')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
client = api.common.HumbugAPI(email=options.user, client = humbug.HumbugAPI(
email=options.user,
api_key=options.api_key, api_key=options.api_key,
verbose=True, verbose=True,
site=options.site) site=options.site)

View File

@@ -37,9 +37,10 @@ parser.add_option('--api-key')
parser.add_option('--user') parser.add_option('--user')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
client = api.common.HumbugAPI(email=options.user, client = humbug.HumbugAPI(
email=options.user,
api_key=options.api_key, api_key=options.api_key,
verbose=True, verbose=True,
site=options.site) site=options.site)

View File

@@ -37,9 +37,10 @@ parser.add_option('--api-key')
parser.add_option('--user') parser.add_option('--user')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
client = api.common.HumbugAPI(email=options.user, client = humbug.HumbugAPI(
email=options.user,
api_key=options.api_key, api_key=options.api_key,
verbose=True, verbose=True,
site=options.site) site=options.site)

View File

@@ -44,9 +44,10 @@ parser.add_option('--type', default='private')
if len(args) == 0: if len(args) == 0:
parser.error("You must specify recipients") parser.error("You must specify recipients")
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
client = api.common.HumbugAPI(email=options.sender, client = humbug.HumbugAPI(
email=options.sender,
api_key=options.api_key, api_key=options.api_key,
verbose=True, verbose=True,
site=options.site) site=options.site)

View File

@@ -38,9 +38,10 @@ parser.add_option('--site', default='https://humbughq.com')
parser.add_option('--streams', default='') parser.add_option('--streams', default='')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
client = api.common.HumbugAPI(email=options.user, client = humbug.HumbugAPI(
email=options.user,
api_key=options.api_key, api_key=options.api_key,
verbose=True, verbose=True,
site=options.site) site=options.site)

View File

@@ -38,9 +38,10 @@ parser.add_option('--site', default='https://humbughq.com')
parser.add_option('--streams', default='') parser.add_option('--streams', default='')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
sys.path.append(path.join(path.dirname(__file__), '../..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import api.common import humbug
client = api.common.HumbugAPI(email=options.user, client = humbug.HumbugAPI(
email=options.user,
api_key=options.api_key, api_key=options.api_key,
verbose=True, verbose=True,
site=options.site) site=options.site)

View File

@@ -4,4 +4,4 @@ if [ -z "$ref" ]; then
echo "You must specify the ref to base the API tarball on." echo "You must specify the ref to base the API tarball on."
exit 1 exit 1
fi fi
git archive --prefix=humbug-api/ -o /tmp/humbug-api.tar.gz "$ref" api/examples/ api/common.py api/__init__.py api/README git archive --prefix=humbug-api/ -o /tmp/humbug-api.tar.gz "$ref" api/examples/ api/humbug.py api/__init__.py api/README

View File

@@ -3,6 +3,7 @@ import sys
import os import os
import optparse import optparse
import re import re
from os import path
usage = """inject-messages [options] usage = """inject-messages [options]
@@ -15,8 +16,8 @@ parser.add_option("--site",
action="store") action="store")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(path.join(path.dirname(__file__), '../../api'))
import api.common import humbug
characters = {'othello': {'api-key': '4e5d97591bec64bf57d2698ffbb563e3', 'intro': ''}, characters = {'othello': {'api-key': '4e5d97591bec64bf57d2698ffbb563e3', 'intro': ''},
'iago': {'api-key': 'd43b53c27a8106195b46781abc67901a', 'intro': ''}} 'iago': {'api-key': 'd43b53c27a8106195b46781abc67901a', 'intro': ''}}
@@ -34,7 +35,8 @@ next_user = gen_next_user()
def connect_all(users): def connect_all(users):
for user in users: for user in users:
users[user]['client'] = api.common.HumbugAPI(email=user + '@humbughq.com', users[user]['client'] = humbug.HumbugAPI(
email=user + '@humbughq.com',
api_key=users[user]['api-key'], api_key=users[user]['api-key'],
site=options.site, site=options.site,
verbose=True) verbose=True)

View File

@@ -20,10 +20,12 @@ import os
import sys import sys
import subprocess import subprocess
import time import time
from os import path
sys.path.append(os.path.dirname(os.path.dirname(os.readlink(__file__)))) sys.path.append(path.join(path.dirname(os.readlink(__file__)), '../api'))
import api.common import humbug
client = api.common.HumbugAPI(email="humbug+commits@humbughq.com", client = humbug.HumbugAPI(
email="humbug+commits@humbughq.com",
site="https://staging.humbughq.com", site="https://staging.humbughq.com",
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
verbose=False) verbose=False)

View File

@@ -298,10 +298,11 @@ def main(args):
print >>sys.stdout print >>sys.stdout
print >>sys.stdout, msg.get_payload(decode=True), print >>sys.stdout, msg.get_payload(decode=True),
else: else:
sys.path.append(os.path.dirname(os.path.dirname(__file__))) sys.path.append(os.path.join(os.path.dirname(__file__), '../api'))
import api.common import humbug
me = get_current_user(repo) me = get_current_user(repo)
client = api.common.HumbugAPI(email=me[me.index("<") + 1:me.index('>')], client = humbug.HumbugAPI(
email=me[me.index("<") + 1:me.index('>')],
site="https://staging.humbughq.com", site="https://staging.humbughq.com",
verbose=True) verbose=True)
client.send_message({'type': "private", client.send_message({'type': "private",