From 2ea1bb05a58e583f325021055a380109c25fbdc3 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 7 Aug 2013 11:36:46 -0400 Subject: [PATCH] Rename ~/.humbugrc to ~/.zuliprc. (imported from commit a0d53dd20097a56971874dc1d84c6f95267e84f2) --- api/README.md | 4 ++-- api/bin/humbug-send | 2 +- api/demos/rss-bot | 2 +- api/examples/edit-message | 2 +- api/examples/get-public-streams | 2 +- api/examples/list-members | 2 +- api/examples/list-subscriptions | 2 +- api/examples/print-messages | 2 +- api/examples/print-next-message | 2 +- api/examples/send-message | 2 +- api/examples/subscribe | 2 +- api/examples/unsubscribe | 2 +- api/examples/{humbugrc => zuliprc} | 2 +- api/humbug/__init__.py | 7 +++++-- api/integrations/nagios/nagios-notify-humbug | 2 +- .../nagios/{humbugrc.example => zuliprc.example} | 2 +- api/setup.py | 2 +- .../modules/zulip/files/nagios3/{humbugrc => zuliprc} | 0 templates/zerver/api.html | 4 ++-- templates/zerver/integrations.html | 8 ++++---- tools/do-destroy-rebuild-database | 2 +- zerver/management/commands/sync_api_key.py | 4 ++-- 22 files changed, 31 insertions(+), 28 deletions(-) rename api/examples/{humbugrc => zuliprc} (73%) rename api/integrations/nagios/{humbugrc.example => zuliprc.example} (74%) rename servers/puppet/modules/zulip/files/nagios3/{humbugrc => zuliprc} (100%) diff --git a/api/README.md b/api/README.md index 9ce5078057..f8086e1e04 100644 --- a/api/README.md +++ b/api/README.md @@ -22,7 +22,7 @@ as we make any changes to them. The easiest way to use these API bindings is to base your tools off of the example tools under examples/ in this distribution. -If you place your API key in the config file `~/.humbugrc` the Python +If you place your API key in the config file `~/.zuliprc` the Python API bindings will automatically read it in. The format of the config file is as follows: @@ -75,7 +75,7 @@ API directly from existing scripts. humbug-send hamlet@example.com cordelia@example.com -m \ "Conscience doth make cowards of us all." -Alternatively, if you don't want to use your ~/.humbugrc file: +Alternatively, if you don't want to use your ~/.zuliprc file: humbug-send --user shakespeare-bot@example.com \ --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \ diff --git a/api/bin/humbug-send b/api/bin/humbug-send index 0b505a4883..9e1f4c0373 100755 --- a/api/bin/humbug-send +++ b/api/bin/humbug-send @@ -59,7 +59,7 @@ def main(argv=None): Examples: %prog --stream denmark --subject castle -m "Something is rotten in the state of Denmark." %prog hamlet@example.com cordelia@example.com -m "Conscience doth make cowards of us all." - These examples assume you have a proper '~/.humbugrc'. You may also set your credentials with the + These examples assume you have a proper '~/.zuliprc'. You may also set your credentials with the '--user' and '--api-key' arguments. """ diff --git a/api/demos/rss-bot b/api/demos/rss-bot index 89e1e81de2..b236e05ee0 100755 --- a/api/demos/rss-bot +++ b/api/demos/rss-bot @@ -25,7 +25,7 @@ To use this script: 1. Create an RSS feed file containing 1 feed URL per line (default feed file location: ~/.cache/humbug-rss/rss-feeds) 2. Subscribe to the stream that will receive RSS updates (default stream: rss) -3. create a ~/.humbugrc, or specify user and api-key with command line arguments +3. create a ~/.zuliprc, or specify user and api-key with command line arguments 4. Test the script by running it manually, like this: /usr/local/share/humbug/demos/rss-bot diff --git a/api/examples/edit-message b/api/examples/edit-message index 405cf5f1c1..dbeb58329a 100755 --- a/api/examples/edit-message +++ b/api/examples/edit-message @@ -31,7 +31,7 @@ Edits a message that you sent Example: edit-message --message-id="348135" --subject="my subject" --content="test message" --user=othello-bot@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.insert(0, path.join(path.dirname(__file__), '..')) diff --git a/api/examples/get-public-streams b/api/examples/get-public-streams index 1b708e146f..fa736f97b8 100755 --- a/api/examples/get-public-streams +++ b/api/examples/get-public-streams @@ -31,7 +31,7 @@ Prints out all the public streams in the realm. Example: get-public-streams --user=othello-bot@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.append(path.join(path.dirname(__file__), '..')) diff --git a/api/examples/list-members b/api/examples/list-members index c062d064c6..3cc2155b8e 100755 --- a/api/examples/list-members +++ b/api/examples/list-members @@ -29,7 +29,7 @@ usage = """list-members --user= --api-key= [ List the names and e-mail addresses of the people in your realm. -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ sys.path.append(path.join(path.dirname(__file__), '..')) diff --git a/api/examples/list-subscriptions b/api/examples/list-subscriptions index af36916ad0..11c1b73d2c 100755 --- a/api/examples/list-subscriptions +++ b/api/examples/list-subscriptions @@ -31,7 +31,7 @@ Prints out a list of the user's subscriptions. Example: list-subscriptions --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +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 diff --git a/api/examples/print-messages b/api/examples/print-messages index 88a9e87435..50a6de5ce8 100755 --- a/api/examples/print-messages +++ b/api/examples/print-messages @@ -31,7 +31,7 @@ Prints out each message received by the indicated bot or user. Example: print-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +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 diff --git a/api/examples/print-next-message b/api/examples/print-next-message index 8a8334cd8c..5c15892e51 100755 --- a/api/examples/print-next-message +++ b/api/examples/print-next-message @@ -31,7 +31,7 @@ Prints out the next message received by the user. Example: print-next-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +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 diff --git a/api/examples/send-message b/api/examples/send-message index c6aa38495a..bc2bad2f87 100755 --- a/api/examples/send-message +++ b/api/examples/send-message @@ -34,7 +34,7 @@ Sends a test message to the specified recipients. Example: send-message --user=your-bot@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --type=stream commits --subject="my subject" --message="test message" Example: send-message --user=your-bot@example.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 user1@example.com user2@example.com -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +You can omit --user and --api-key arguments if you have a properly set up ~/.zuliprc """ parser = optparse.OptionParser(usage=usage) parser.add_option('--subject', default="test") diff --git a/api/examples/subscribe b/api/examples/subscribe index b2f8791756..99254818af 100755 --- a/api/examples/subscribe +++ b/api/examples/subscribe @@ -32,7 +32,7 @@ Ensures the user is subscribed to the listed streams. Examples: subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar' -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +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 diff --git a/api/examples/unsubscribe b/api/examples/unsubscribe index 3a10c5f4e4..3085952952 100755 --- a/api/examples/unsubscribe +++ b/api/examples/unsubscribe @@ -32,7 +32,7 @@ Ensures the user is not subscribed to the listed streams. Examples: unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar' -You can omit --user and --api-key arguments if you have a properly set up ~/.humbugrc +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 diff --git a/api/examples/humbugrc b/api/examples/zuliprc similarity index 73% rename from api/examples/humbugrc rename to api/examples/zuliprc index 45fb0a8210..9ce425338d 100644 --- a/api/examples/humbugrc +++ b/api/examples/zuliprc @@ -1,4 +1,4 @@ -; Save this file as ~/.humbugrc +; Save this file as ~/.zuliprc [api] key= email= diff --git a/api/humbug/__init__.py b/api/humbug/__init__.py index 5f095aad31..9d7cb3eb61 100644 --- a/api/humbug/__init__.py +++ b/api/humbug/__init__.py @@ -55,7 +55,7 @@ def generate_option_group(parser): help='Email address of the calling bot or user.') group.add_option('--config-file', action='store', - help='Location of an ini file containing the\nabove information. (default ~/.humbugrc)') + help='Location of an ini file containing the\nabove information. (default ~/.zuliprc)') group.add_option('-v', '--verbose', action='store_true', help='Provide detailed output.') @@ -72,7 +72,10 @@ class Client(object): site=None, client="API: Python"): if None in (api_key, email): if config_file is None: - config_file = os.path.join(os.environ["HOME"], ".humbugrc") + config_file = os.path.join(os.environ["HOME"], ".zuliprc") + if (not os.path.exists(config_file) and + os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))): + raise RuntimeError("The Zulip API configuration file is now ~/.zuliprc; please run:\n\n mv ~/.humbugrc ~/.zuliprc\n") if not os.path.exists(config_file): raise RuntimeError("api_key or email not specified and %s does not exist" % (config_file,)) diff --git a/api/integrations/nagios/nagios-notify-humbug b/api/integrations/nagios/nagios-notify-humbug index 059399d24a..56fe91df65 100755 --- a/api/integrations/nagios/nagios-notify-humbug +++ b/api/integrations/nagios/nagios-notify-humbug @@ -9,7 +9,7 @@ parser = optparse.OptionParser() parser.add_option('--output', default='') parser.add_option('--long-output', default='') parser.add_option('--stream', default='nagios') -parser.add_option('--config', default='/etc/nagios3/humbugrc') +parser.add_option('--config', default='/etc/nagios3/zuliprc') for opt in ('type', 'host', 'service', 'state'): parser.add_option('--' + opt) (opts, args) = parser.parse_args() diff --git a/api/integrations/nagios/humbugrc.example b/api/integrations/nagios/zuliprc.example similarity index 74% rename from api/integrations/nagios/humbugrc.example rename to api/integrations/nagios/zuliprc.example index cb7cc97278..6fb0a6b450 100644 --- a/api/integrations/nagios/humbugrc.example +++ b/api/integrations/nagios/zuliprc.example @@ -1,5 +1,5 @@ # Fill these values in with the appropriate values for your realm, and -# then install this value at /etc/nagios3/humbugrc +# then install this value at /etc/nagios3/zuliprc [api] email = nagios-bot@example.com key = 0123456789abcdef0123456789abcdef diff --git a/api/setup.py b/api/setup.py index 61d797008c..a0db66cc0f 100644 --- a/api/setup.py +++ b/api/setup.py @@ -26,7 +26,7 @@ setup(name='humbug', ], url='https://www.zulip.com/dist/api/', packages=['humbug'], - data_files=[('share/humbug/examples', ["examples/humbugrc", "examples/send-message", "examples/subscribe", + data_files=[('share/humbug/examples', ["examples/zuliprc", "examples/send-message", "examples/subscribe", "examples/get-public-streams", "examples/unsubscribe", "examples/list-members", "examples/list-subscriptions", "examples/print-messages"])] + \ diff --git a/servers/puppet/modules/zulip/files/nagios3/humbugrc b/servers/puppet/modules/zulip/files/nagios3/zuliprc similarity index 100% rename from servers/puppet/modules/zulip/files/nagios3/humbugrc rename to servers/puppet/modules/zulip/files/nagios3/zuliprc diff --git a/templates/zerver/api.html b/templates/zerver/api.html index e625aae80d..8a2ce75ca5 100644 --- a/templates/zerver/api.html +++ b/templates/zerver/api.html @@ -69,7 +69,7 @@ to pull out the resulting HTML :) import humbug import sys -# Keyword arguments 'email' and 'api_key' are optional if you are using ~/.humbugrc +# Keyword arguments 'email' and 'api_key' are optional if you are using ~/.zuliprc client = humbug.Client(email="othello-bot@example.com", api_key="a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5") @@ -134,7 +134,7 @@ to pull out the resulting HTML :)

If you prefer to send messages as your own user, you can also find your API key on your settings page.

When using our python bindings, you may either specify the user and API key for each Client object that you initialize, or let the binding look for - them in your ~/.humbugrc, which you can create as follows:

+ them in your ~/.zuliprc, which you can create as follows:

[api]
 key=BOT_API_KEY
 email=BOT_EMAIL_ADDRESS
diff --git a/templates/zerver/integrations.html b/templates/zerver/integrations.html
index 9fb4177049..eb749f4a9f 100644
--- a/templates/zerver/integrations.html
+++ b/templates/zerver/integrations.html
@@ -91,7 +91,7 @@
   desc "Post a message to Zulip that we've deployed"
   task :humbug do
     # this will post to Zulip as the user defined in
-    # ~/.humbugrc if you omit --user and --api-key
+    # ~/.zuliprc if you omit --user and --api-key
     run_locally "echo ':beers: I just deployed to #{stage}! :beers:' | humbug-send \
     --user capistrano-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \
     --stream commits --subject deployments || true"
@@ -101,7 +101,7 @@
 
       

Some notes:

    -
  • If you prefer not to use --user and --api-key above, you can fill out ~/.humbugrc on your Capistrano +
  • If you prefer not to use --user and --api-key above, you can fill out ~/.zuliprc on your Capistrano machine. For instructions on how to write that file, see the API page.
  • You may need to change the deploy above to another step of your deployment process, if you'd like the @@ -314,10 +314,10 @@ following, to the stream commits with a subject that matches the re

    First, download and install our Python bindings and example scripts on your Nagios server.

    -

    Next, open integrations/nagios/humbugrc.example +

    Next, open integrations/nagios/zuliprc.example in your favorite editor, and change the following lines to specify the email address and API key for your Nagios bot, - saving it to /etc/nagios3/humbugrc on your Nagios + saving it to /etc/nagios3/zuliprc on your Nagios server:

    [api]
    diff --git a/tools/do-destroy-rebuild-database b/tools/do-destroy-rebuild-database
    index dbc508f045..526e05a70b 100755
    --- a/tools/do-destroy-rebuild-database
    +++ b/tools/do-destroy-rebuild-database
    @@ -6,5 +6,5 @@ python manage.py syncdb --noinput
     python manage.py migrate
     python manage.py createcachetable third_party_api_results
     python manage.py populate_db -n100 --threads=1
    -# Ensure that the local user's API key is synced from ~/.humbugrc
    +# Ensure that the local user's API key is synced from ~/.zuliprc
     python manage.py sync_api_key
    diff --git a/zerver/management/commands/sync_api_key.py b/zerver/management/commands/sync_api_key.py
    index c2469f3e29..1c89a9a1bd 100644
    --- a/zerver/management/commands/sync_api_key.py
    +++ b/zerver/management/commands/sync_api_key.py
    @@ -9,9 +9,9 @@ class Command(BaseCommand):
         help = """Reset all colors for a person to the default grey"""
     
         def handle(self, *args, **options):
    -        config_file = os.path.join(os.environ["HOME"], ".humbugrc")
    +        config_file = os.path.join(os.environ["HOME"], ".zuliprc")
             if not os.path.exists(config_file):
    -            raise RuntimeError("No ~/.humbugrc found")
    +            raise RuntimeError("No ~/.zuliprc found")
             config = SafeConfigParser()
             with file(config_file, 'r') as f:
                 config.readfp(f, config_file)