From 084847b0d76d9d549833d67b93ccda748eeade9a Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 7 Aug 2013 11:51:03 -0400 Subject: [PATCH] Rename the 'humbug' API module to 'zulip'. (imported from commit b3a3d7c05459cbb0110cd0fbe2197d779f3a6264) --- README.md | 6 +++--- bin/humbug-send | 6 +++--- bots/check-mirroring | 12 ++++++------ bots/feedback-bot | 6 +++--- bots/gcal-bot | 6 +++--- bots/sync-public-streams | 6 +++--- bots/tddium-notify-humbug | 4 ++-- bots/zephyr_mirror_backend.py | 14 +++++++------- demos/rss-bot | 6 +++--- demos/twitter-bot | 6 +++--- demos/twitter-search-bot | 6 +++--- examples/edit-message | 6 +++--- examples/get-public-streams | 6 +++--- examples/list-members | 6 +++--- examples/list-subscriptions | 6 +++--- examples/print-messages | 6 +++--- examples/print-next-message | 6 +++--- examples/send-message | 6 +++--- examples/subscribe | 6 +++--- examples/unsubscribe | 6 +++--- integrations/git/post-receive | 4 ++-- integrations/nagios/nagios-notify-humbug | 4 ++-- integrations/svn/post-commit | 4 ++-- integrations/trac/humbug_trac.py | 4 ++-- setup.py | 8 ++++---- {humbug => zulip}/__init__.py | 0 26 files changed, 78 insertions(+), 78 deletions(-) rename {humbug => zulip}/__init__.py (100%) diff --git a/README.md b/README.md index f8086e1..d094a04 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ A typical simple bot sending API messages will look as follows: At the top of the file: # Make sure the Zulip API distribution's root directory is in sys.path, then: - import humbug - humbug_client = humbug.Client(email="your-bot@example.com") + import zulip + zulip_client = zulip.Client(email="your-bot@example.com") When you want to send a message: @@ -53,7 +53,7 @@ When you want to send a message: "subject": "your subject", "content": "your content", } - humbug_client.send_message(message) + zulip_client.send_message(message) Additional examples: diff --git a/bin/humbug-send b/bin/humbug-send index 9e1f4c0..fe706b2 100755 --- a/bin/humbug-send +++ b/bin/humbug-send @@ -65,12 +65,12 @@ def main(argv=None): sys.path.append(os.path.join(os.path.dirname(__file__), '..')) - import humbug + import zulip parser = optparse.OptionParser(usage=usage) # Grab parser options from the API common set - parser.add_option_group(humbug.generate_option_group(parser)) + parser.add_option_group(zulip.generate_option_group(parser)) parser.add_option('-m', '--message', help='Specifies the message to send, prevents interactive prompting.') @@ -99,7 +99,7 @@ def main(argv=None): if len(recipients) == 0 and not (options.stream and options.subject): parser.error('You must specify a stream/subject or at least one recipient.') - client = humbug.init_from_options(options) + client = zulip.init_from_options(options) if not options.message: options.message = sys.stdin.read() diff --git a/bots/check-mirroring b/bots/check-mirroring index 4c1891d..7ce3024 100755 --- a/bots/check-mirroring +++ b/bots/check-mirroring @@ -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() diff --git a/bots/feedback-bot b/bots/feedback-bot index 0d003bc..9e2a4c7 100755 --- a/bots/feedback-bot +++ b/bots/feedback-bot @@ -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, diff --git a/bots/gcal-bot b/bots/gcal-bot index 03e2c52..38957bf 100755 --- a/bots/gcal-bot +++ b/bots/gcal-bot @@ -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) diff --git a/bots/sync-public-streams b/bots/sync-public-streams index 4d03314..9c66db3 100755 --- a/bots/sync-public-streams +++ b/bots/sync-public-streams @@ -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: diff --git a/bots/tddium-notify-humbug b/bots/tddium-notify-humbug index d15ef60..b3d91f4 100755 --- a/bots/tddium-notify-humbug +++ b/bots/tddium-notify-humbug @@ -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')) diff --git a/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index 7b505c3..34e0bba 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -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, diff --git a/demos/rss-bot b/demos/rss-bot index b236e05..8749c52 100755 --- a/demos/rss-bot +++ b/demos/rss-bot @@ -11,7 +11,7 @@ import time import urlparse import feedparser -import humbug +import zulip RSS_DATA_DIR = os.path.expanduser(os.path.join('~', '.cache', 'humbug-rss')) OLDNESS_THRESHOLD = 30 # days @@ -56,7 +56,7 @@ parser.add_option('--feed-file', help='The file containing a list of RSS feed URLs to follow, one URL per line', default=os.path.join(RSS_DATA_DIR, "rss-feeds"), action='store') -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (opts, args) = parser.parse_args() def mkdir_p(path): @@ -131,7 +131,7 @@ try: except IOError: log_error_and_exit("Unable to read feed file at %s." % (opts.feed_file,)) -client = humbug.Client(email=opts.email, api_key=opts.api_key, +client = zulip.Client(email=opts.email, api_key=opts.api_key, site=opts.site) first_message = True diff --git a/demos/twitter-bot b/demos/twitter-bot index cbe9d0f..6835026 100755 --- a/demos/twitter-bot +++ b/demos/twitter-bot @@ -4,7 +4,7 @@ import sys import optparse import ConfigParser -import humbug +import zulip CONFIGFILE = os.path.expanduser("~/.humbug_twitterrc") @@ -54,7 +54,7 @@ parser.add_option('--limit-tweets', type='int', help='Maximum number of tweets to push at once') -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() if not options.twitter_id: @@ -101,7 +101,7 @@ try: except ConfigParser.NoOptionError: user_id = options.twitter_id -client = humbug.Client( +client = zulip.Client( email=options.user, api_key=options.api_key, site=options.site, diff --git a/demos/twitter-search-bot b/demos/twitter-search-bot index dcf715c..33a6259 100755 --- a/demos/twitter-search-bot +++ b/demos/twitter-search-bot @@ -4,7 +4,7 @@ import sys import optparse import ConfigParser -import humbug +import zulip CONFIGFILE = os.path.expanduser("~/.humbug_twitterrc") @@ -76,7 +76,7 @@ parser.add_option('--limit-tweets', type='int', help='Maximum number of tweets to send at once') -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (opts, args) = parser.parse_args() if not opts.search_terms: @@ -118,7 +118,7 @@ if not user.GetId(): Please double-check and try again." sys.exit() -client = humbug.Client( +client = zulip.Client( email=opts.user, api_key=opts.api_key, site=opts.site, diff --git a/examples/edit-message b/examples/edit-message index dbeb583..e9119f7 100755 --- a/examples/edit-message +++ b/examples/edit-message @@ -35,16 +35,16 @@ You can omit --user and --api-key arguments if you have a properly set up ~/.zul """ sys.path.insert(0, path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) parser.add_option('--message-id', default="") parser.add_option('--subject', default="") parser.add_option('--content', default="") -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) message_data = { "message_id": options.message_id, diff --git a/examples/get-public-streams b/examples/get-public-streams index fa736f9..6eeed50 100755 --- a/examples/get-public-streams +++ b/examples/get-public-streams @@ -35,12 +35,12 @@ You can omit --user and --api-key arguments if you have a properly set up ~/.zul """ sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) print client.get_public_streams() diff --git a/examples/list-members b/examples/list-members index 3cc2155..0976f66 100755 --- a/examples/list-members +++ b/examples/list-members @@ -33,13 +33,13 @@ You can omit --user and --api-key arguments if you have a properly set up ~/.zul """ sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) for user in client.get_members()["members"]: print user["full_name"], user["email"] diff --git a/examples/list-subscriptions b/examples/list-subscriptions index 11c1b73..00623af 100755 --- a/examples/list-subscriptions +++ b/examples/list-subscriptions @@ -34,12 +34,12 @@ Example: list-subscriptions --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) print client.list_subscriptions() diff --git a/examples/print-messages b/examples/print-messages index 50a6de5..8b2186b 100755 --- a/examples/print-messages +++ b/examples/print-messages @@ -34,13 +34,13 @@ Example: print-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) def print_message(message): print message diff --git a/examples/print-next-message b/examples/print-next-message index 5c15892..5c0d3cb 100755 --- a/examples/print-next-message +++ b/examples/print-next-message @@ -34,12 +34,12 @@ Example: print-next-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7 You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) print client.get_messages({}) diff --git a/examples/send-message b/examples/send-message index bc2bad2..f9edabc 100755 --- a/examples/send-message +++ b/examples/send-message @@ -25,7 +25,7 @@ import sys from os import path import optparse sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip usage = """send-message --user= --api-key= [options] @@ -40,13 +40,13 @@ parser = optparse.OptionParser(usage=usage) parser.add_option('--subject', default="test") parser.add_option('--message', default="test message") parser.add_option('--type', default='private') -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) (options, args) = parser.parse_args() if len(args) == 0: parser.error("You must specify recipients") -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) message_data = { "type": options.type, diff --git a/examples/subscribe b/examples/subscribe index 9925481..1593fe8 100755 --- a/examples/subscribe +++ b/examples/subscribe @@ -35,14 +35,14 @@ Examples: subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) parser.add_option('--streams', default='') (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) if options.streams == "": print >>sys.stderr, "Usage:", parser.usage diff --git a/examples/unsubscribe b/examples/unsubscribe index 3085952..104e03e 100755 --- a/examples/unsubscribe +++ b/examples/unsubscribe @@ -35,14 +35,14 @@ Examples: unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.append(path.join(path.dirname(__file__), '..')) -import humbug +import zulip parser = optparse.OptionParser(usage=usage) -parser.add_option_group(humbug.generate_option_group(parser)) +parser.add_option_group(zulip.generate_option_group(parser)) parser.add_option('--streams', default='') (options, args) = parser.parse_args() -client = humbug.init_from_options(options) +client = zulip.init_from_options(options) if options.streams == "": print >>sys.stderr, "Usage:", parser.usage diff --git a/integrations/git/post-receive b/integrations/git/post-receive index 6387b81..c11fe36 100755 --- a/integrations/git/post-receive +++ b/integrations/git/post-receive @@ -40,8 +40,8 @@ import humbug_git_config as config if config.HUMBUG_API_PATH is not None: sys.path.append(config.HUMBUG_API_PATH) -import humbug -client = humbug.Client( +import zulip +client = zulip.Client( email=config.HUMBUG_USER, site=config.HUMBUG_SITE, api_key=config.HUMBUG_API_KEY) diff --git a/integrations/nagios/nagios-notify-humbug b/integrations/nagios/nagios-notify-humbug index 56fe91d..0e92e40 100755 --- a/integrations/nagios/nagios-notify-humbug +++ b/integrations/nagios/nagios-notify-humbug @@ -1,6 +1,6 @@ #!/usr/bin/env python import optparse -import humbug +import zulip # Nagios passes the notification details as command line options. # In Nagios, "output" means "first line of output", and "long @@ -14,7 +14,7 @@ for opt in ('type', 'host', 'service', 'state'): parser.add_option('--' + opt) (opts, args) = parser.parse_args() -client = humbug.Client(config_file=opts.config) +client = zulip.Client(config_file=opts.config) msg = dict(type='stream', to=opts.stream) diff --git a/integrations/svn/post-commit b/integrations/svn/post-commit index 1cc7dc2..0e1b698 100755 --- a/integrations/svn/post-commit +++ b/integrations/svn/post-commit @@ -40,8 +40,8 @@ import humbug_svn_config as config if config.HUMBUG_API_PATH is not None: sys.path.append(config.HUMBUG_API_PATH) -import humbug -client = humbug.Client( +import zulip +client = zulip.Client( email=config.HUMBUG_USER, site=config.HUMBUG_SITE, api_key=config.HUMBUG_API_KEY) diff --git a/integrations/trac/humbug_trac.py b/integrations/trac/humbug_trac.py index 15e9577..f89d69e 100644 --- a/integrations/trac/humbug_trac.py +++ b/integrations/trac/humbug_trac.py @@ -44,8 +44,8 @@ import humbug_trac_config as config if config.HUMBUG_API_PATH is not None: sys.path.append(config.HUMBUG_API_PATH) -import humbug -client = humbug.Client( +import zulip +client = zulip.Client( email=config.HUMBUG_USER, site=config.HUMBUG_SITE, api_key=config.HUMBUG_API_KEY) diff --git a/setup.py b/setup.py index a0db66c..33976fc 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import humbug +import zulip import os from distutils.core import setup @@ -12,8 +12,8 @@ def recur_expand(target_root, dir): if len(paths): yield os.path.join(target_root, root), paths -setup(name='humbug', - version=humbug.__version__, +setup(name='zulip', + version=zulip.__version__, description='Bindings for the Zulip message API', author='Zulip, Inc.', author_email='humbug@humbughq.com', @@ -25,7 +25,7 @@ setup(name='humbug', 'Topic :: Communications :: Chat', ], url='https://www.zulip.com/dist/api/', - packages=['humbug'], + packages=['zulip'], data_files=[('share/humbug/examples', ["examples/zuliprc", "examples/send-message", "examples/subscribe", "examples/get-public-streams", "examples/unsubscribe", "examples/list-members", "examples/list-subscriptions", diff --git a/humbug/__init__.py b/zulip/__init__.py similarity index 100% rename from humbug/__init__.py rename to zulip/__init__.py