Rename the 'humbug' API module to 'zulip'.
(imported from commit b3a3d7c05459cbb0110cd0fbe2197d779f3a6264)
This commit is contained in:
parent
9aaefde9b2
commit
084847b0d7
26 changed files with 78 additions and 78 deletions
|
@ -26,7 +26,7 @@ parser.add_option('--root-path',
|
|||
action='store')
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# The 'api' directory needs to go first, so that 'import humbug' won't pick up
|
||||
# The 'api' directory needs to go first, so that 'import zulip' won't pick up
|
||||
# some other directory named 'humbug'.
|
||||
sys.path[:0] = [os.path.join(options.root_path, "api/"),
|
||||
os.path.join(options.root_path, "python-zephyr"),
|
||||
|
@ -37,8 +37,8 @@ mit_user = 'tabbott/extra@ATHENA.MIT.EDU'
|
|||
humbug_user = 'tabbott/extra@mit.edu'
|
||||
|
||||
sys.path.append(".")
|
||||
import humbug
|
||||
humbug_client = humbug.Client(
|
||||
import zulip
|
||||
zulip_client = zulip.Client(
|
||||
email=humbug_user,
|
||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
verbose=True,
|
||||
|
@ -103,7 +103,7 @@ def print_status_and_exit(status):
|
|||
sys.exit(status)
|
||||
|
||||
def send_humbug(message):
|
||||
result = humbug_client.send_message(message)
|
||||
result = zulip_client.send_message(message)
|
||||
if result["result"] != "success":
|
||||
logger.error("Error sending zulip, args were:")
|
||||
logger.error(message)
|
||||
|
@ -128,7 +128,7 @@ def send_zephyr(zwrite_args, content):
|
|||
|
||||
# Subscribe to Zulip
|
||||
try:
|
||||
res = humbug_client.get_profile()
|
||||
res = zulip_client.get_profile()
|
||||
max_message_id = res.get('max_message_id')
|
||||
if max_message_id is None:
|
||||
logging.error("Error subscribing to Zulips!")
|
||||
|
@ -264,7 +264,7 @@ receive_zephyrs()
|
|||
logger.info("Starting receiving messages!")
|
||||
|
||||
# receive zulips
|
||||
messages = humbug_client.get_messages({'last': str(max_message_id)})['messages']
|
||||
messages = zulip_client.get_messages({'last': str(max_message_id)})['messages']
|
||||
logger.info("Finished receiving Zulip messages!")
|
||||
|
||||
receive_zephyrs()
|
||||
|
|
|
@ -4,7 +4,7 @@ from os import path
|
|||
import logging
|
||||
|
||||
sys.path.append(path.join(path.dirname(__file__), '../api'))
|
||||
import humbug
|
||||
import zulip
|
||||
|
||||
class StreamLogger(object):
|
||||
"""
|
||||
|
@ -32,12 +32,12 @@ sys.stdout = stdout_logger
|
|||
stderr_logger = StreamLogger(logging.getLogger("stderr"), logging.ERROR)
|
||||
sys.stderr = stderr_logger
|
||||
|
||||
prod_client = humbug.Client(
|
||||
prod_client = zulip.Client(
|
||||
email="feedback@zulip.com",
|
||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
verbose=True,
|
||||
site="https://api.zulip.com")
|
||||
staging_client = humbug.Client(
|
||||
staging_client = zulip.Client(
|
||||
email="feedback@zulip.com",
|
||||
api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
verbose=True,
|
||||
|
|
|
@ -9,7 +9,7 @@ import traceback
|
|||
from os import path
|
||||
|
||||
sys.path.append(path.join(path.dirname(__file__), '../api'))
|
||||
import humbug
|
||||
import zulip
|
||||
|
||||
parser = optparse.OptionParser(r"""
|
||||
|
||||
|
@ -43,7 +43,7 @@ parser.add_option('--interval',
|
|||
action='store',
|
||||
help='Minutes before event for reminder [default: 10]',
|
||||
metavar='MINUTES')
|
||||
parser.add_option_group(humbug.generate_option_group(parser))
|
||||
parser.add_option_group(zulip.generate_option_group(parser))
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
|
@ -66,7 +66,7 @@ def get_calendar_url():
|
|||
|
||||
calendar_url = get_calendar_url()
|
||||
|
||||
client = humbug.init_from_options(options)
|
||||
client = zulip.init_from_options(options)
|
||||
|
||||
def get_events():
|
||||
feed = CalendarClient().GetCalendarEventFeed(uri=calendar_url)
|
||||
|
|
|
@ -8,15 +8,15 @@ import subprocess
|
|||
import unicodedata
|
||||
|
||||
sys.path.append(path.join(path.dirname(__file__), '..', 'api'))
|
||||
import humbug
|
||||
import zulip
|
||||
|
||||
humbug_client = humbug.Client()
|
||||
zulip_client = zulip.Client()
|
||||
|
||||
def fetch_public_streams():
|
||||
public_streams = set()
|
||||
|
||||
try:
|
||||
res = humbug_client.get_public_streams()
|
||||
res = zulip_client.get_public_streams()
|
||||
if res.get("result") == "success":
|
||||
streams = res["streams"]
|
||||
else:
|
||||
|
|
|
@ -46,9 +46,9 @@ humbug_directory = path.join(path.dirname(__file__), '../api')
|
|||
|
||||
|
||||
sys.path.append(humbug_directory)
|
||||
import humbug
|
||||
import zulip
|
||||
|
||||
client = humbug.Client(
|
||||
client = zulip.Client(
|
||||
email = environ['HUMBUG_USER'],
|
||||
api_key = environ.get('HUMBUG_API_KEY'))
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ def send_zulip(zeph):
|
|||
logger.debug("Message is: %s" % (str(message),))
|
||||
return {'result': "success"}
|
||||
|
||||
return humbug_client.send_message(message)
|
||||
return zulip_client.send_message(message)
|
||||
|
||||
def send_error_zulip(error_msg):
|
||||
message = {"type": "private",
|
||||
|
@ -173,7 +173,7 @@ def send_error_zulip(error_msg):
|
|||
"to": zulip_account_email,
|
||||
"content": error_msg,
|
||||
}
|
||||
humbug_client.send_message(message)
|
||||
zulip_client.send_message(message)
|
||||
|
||||
current_zephyr_subs = set()
|
||||
def zephyr_bulk_subscribe(subs):
|
||||
|
@ -623,7 +623,7 @@ def zulip_to_zephyr(options):
|
|||
logger.info("Starting syncing messages.")
|
||||
while True:
|
||||
try:
|
||||
humbug_client.call_on_each_message(maybe_forward_to_zephyr)
|
||||
zulip_client.call_on_each_message(maybe_forward_to_zephyr)
|
||||
except Exception:
|
||||
logger.exception("Error syncing messages:")
|
||||
time.sleep(1)
|
||||
|
@ -675,7 +675,7 @@ def add_zulip_subscriptions(verbose):
|
|||
zephyr_subscriptions.add(cls)
|
||||
|
||||
if len(zephyr_subscriptions) != 0:
|
||||
res = humbug_client.add_subscriptions(list({"name": stream} for stream in zephyr_subscriptions))
|
||||
res = zulip_client.add_subscriptions(list({"name": stream} for stream in zephyr_subscriptions))
|
||||
if res.get("result") != "success":
|
||||
logger.error("Error subscribing to streams:\n%s" % (res["msg"],))
|
||||
return
|
||||
|
@ -866,7 +866,7 @@ if __name__ == "__main__":
|
|||
logger = open_logger()
|
||||
configure_logger(logger, "parent")
|
||||
|
||||
# The 'api' directory needs to go first, so that 'import humbug' won't pick
|
||||
# The 'api' directory needs to go first, so that 'import zulip' won't pick
|
||||
# up some other directory named 'humbug'.
|
||||
pyzephyr_lib_path = "python-zephyr/build/lib.linux-" + os.uname()[4] + "-2.6/"
|
||||
sys.path[:0] = [os.path.join(options.root_path, 'api'),
|
||||
|
@ -892,8 +892,8 @@ or specify the --api-key-file option.""" % (options.api_key_file,))))
|
|||
os.environ["HUMBUG_API_KEY"] = api_key
|
||||
|
||||
zulip_account_email = options.user + "@mit.edu"
|
||||
import humbug
|
||||
humbug_client = humbug.Client(
|
||||
import zulip
|
||||
zulip_client = zulip.Client(
|
||||
email=zulip_account_email,
|
||||
api_key=api_key,
|
||||
verbose=True,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue