Rename ~/.humbugrc to ~/.zuliprc.

(imported from commit a0d53dd20097a56971874dc1d84c6f95267e84f2)
This commit is contained in:
Tim Abbott
2013-08-07 11:36:46 -04:00
committed by Tim Abbott
parent d6c87f35e2
commit 2ea1bb05a5
22 changed files with 31 additions and 28 deletions

View File

@@ -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 The easiest way to use these API bindings is to base your tools off
of the example tools under examples/ in this distribution. 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 API bindings will automatically read it in. The format of the config
file is as follows: file is as follows:
@@ -75,7 +75,7 @@ API directly from existing scripts.
humbug-send hamlet@example.com cordelia@example.com -m \ humbug-send hamlet@example.com cordelia@example.com -m \
"Conscience doth make cowards of us all." "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 \ humbug-send --user shakespeare-bot@example.com \
--api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \ --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \

View File

@@ -59,7 +59,7 @@ def main(argv=None):
Examples: %prog --stream denmark --subject castle -m "Something is rotten in the state of Denmark." 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." %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. '--user' and '--api-key' arguments.
""" """

View File

@@ -25,7 +25,7 @@ To use this script:
1. Create an RSS feed file containing 1 feed URL per line (default feed 1. Create an RSS feed file containing 1 feed URL per line (default feed
file location: ~/.cache/humbug-rss/rss-feeds) file location: ~/.cache/humbug-rss/rss-feeds)
2. Subscribe to the stream that will receive RSS updates (default stream: rss) 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: 4. Test the script by running it manually, like this:
/usr/local/share/humbug/demos/rss-bot /usr/local/share/humbug/demos/rss-bot

View File

@@ -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 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__), '..')) sys.path.insert(0, path.join(path.dirname(__file__), '..'))

View File

@@ -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 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__), '..')) sys.path.append(path.join(path.dirname(__file__), '..'))

View File

@@ -29,7 +29,7 @@ usage = """list-members --user=<bot's email address> --api-key=<bot's api key> [
List the names and e-mail addresses of the people in your realm. 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__), '..')) sys.path.append(path.join(path.dirname(__file__), '..'))

View File

@@ -31,7 +31,7 @@ Prints out a list of the user's subscriptions.
Example: list-subscriptions --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 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__), '..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug import humbug

View File

@@ -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 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__), '..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug import humbug

View File

@@ -31,7 +31,7 @@ Prints out the next message received by the user.
Example: print-next-messages --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 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__), '..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug import humbug

View File

@@ -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 --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 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 = optparse.OptionParser(usage=usage)
parser.add_option('--subject', default="test") parser.add_option('--subject', default="test")

View File

@@ -32,7 +32,7 @@ Ensures the user is subscribed to the listed streams.
Examples: subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo Examples: subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo
subscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar' 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__), '..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug import humbug

View File

@@ -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 Examples: unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams=foo
unsubscribe --user=tabbott@zulip.com --api-key=a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --streams='foo bar' 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__), '..')) sys.path.append(path.join(path.dirname(__file__), '..'))
import humbug import humbug

View File

@@ -1,4 +1,4 @@
; Save this file as ~/.humbugrc ; Save this file as ~/.zuliprc
[api] [api]
key=<your bot's api key from the web interface> key=<your bot's api key from the web interface>
email=<your bot's email address> email=<your bot's email address>

View File

@@ -55,7 +55,7 @@ def generate_option_group(parser):
help='Email address of the calling bot or user.') help='Email address of the calling bot or user.')
group.add_option('--config-file', group.add_option('--config-file',
action='store', 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', group.add_option('-v', '--verbose',
action='store_true', action='store_true',
help='Provide detailed output.') help='Provide detailed output.')
@@ -72,7 +72,10 @@ class Client(object):
site=None, client="API: Python"): site=None, client="API: Python"):
if None in (api_key, email): if None in (api_key, email):
if config_file is None: 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): if not os.path.exists(config_file):
raise RuntimeError("api_key or email not specified and %s does not exist" raise RuntimeError("api_key or email not specified and %s does not exist"
% (config_file,)) % (config_file,))

View File

@@ -9,7 +9,7 @@ parser = optparse.OptionParser()
parser.add_option('--output', default='') parser.add_option('--output', default='')
parser.add_option('--long-output', default='') parser.add_option('--long-output', default='')
parser.add_option('--stream', default='nagios') 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'): for opt in ('type', 'host', 'service', 'state'):
parser.add_option('--' + opt) parser.add_option('--' + opt)
(opts, args) = parser.parse_args() (opts, args) = parser.parse_args()

View File

@@ -1,5 +1,5 @@
# Fill these values in with the appropriate values for your realm, and # 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] [api]
email = nagios-bot@example.com email = nagios-bot@example.com
key = 0123456789abcdef0123456789abcdef key = 0123456789abcdef0123456789abcdef

View File

@@ -26,7 +26,7 @@ setup(name='humbug',
], ],
url='https://www.zulip.com/dist/api/', url='https://www.zulip.com/dist/api/',
packages=['humbug'], 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/get-public-streams", "examples/unsubscribe",
"examples/list-members", "examples/list-subscriptions", "examples/list-members", "examples/list-subscriptions",
"examples/print-messages"])] + \ "examples/print-messages"])] + \

View File

@@ -69,7 +69,7 @@ to pull out the resulting HTML :)
<span class="kn">import</span> <span class="nn">humbug</span> <span class="kn">import</span> <span class="nn">humbug</span>
<span class="kn">import</span> <span class="nn">sys</span> <span class="kn">import</span> <span class="nn">sys</span>
<span class="c"># Keyword arguments 'email' and 'api_key' are optional if you are using ~/.humbugrc</span> <span class="c"># Keyword arguments 'email' and 'api_key' are optional if you are using ~/.zuliprc</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">humbug</span><span class="o">.</span><span class="n">Client</span><span class="p">(</span><span class="p">email</span><span class="o">=</span><span class="s">"othello-bot@example.com"</span><span class="p">,</span> <span class="n">client</span> <span class="o">=</span> <span class="n">humbug</span><span class="o">.</span><span class="n">Client</span><span class="p">(</span><span class="p">email</span><span class="o">=</span><span class="s">"othello-bot@example.com"</span><span class="p">,</span>
<span class="n">api_key</span><span class="o">=</span><span class="s">"a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5"</span><span class="p">)</span> <span class="n">api_key</span><span class="o">=</span><span class="s">"a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5"</span><span class="p">)</span>
@@ -134,7 +134,7 @@ to pull out the resulting HTML :)
<p>If you prefer to send messages as your own user, you can also find your API key on your <a href="/#settings" target="_blank">settings page</a>.</p> <p>If you prefer to send messages as your own user, you can also find your API key on your <a href="/#settings" target="_blank">settings page</a>.</p>
<p>When using our python bindings, you may either specify the user <p>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 and API key for each Client object that you initialize, or let the binding look for
them in your <code>~/.humbugrc</code>, which you can create as follows:</p> them in your <code>~/.zuliprc</code>, which you can create as follows:</p>
<div class="codehilite"><pre><span class="k">[api]</span> <div class="codehilite"><pre><span class="k">[api]</span>
<span class="na">key</span><span class="o">=</span><span class="s">BOT_API_KEY</span> <span class="na">key</span><span class="o">=</span><span class="s">BOT_API_KEY</span>
<span class="na">email</span><span class="o">=</span><span class="s">BOT_EMAIL_ADDRESS</span> <span class="na">email</span><span class="o">=</span><span class="s">BOT_EMAIL_ADDRESS</span>

View File

@@ -91,7 +91,7 @@
<span class="n">desc</span> <span class="s2">"Post a message to Zulip that we've deployed"</span> <span class="n">desc</span> <span class="s2">"Post a message to Zulip that we've deployed"</span>
<span class="n">task</span> <span class="ss">:humbug</span> <span class="k">do</span> <span class="n">task</span> <span class="ss">:humbug</span> <span class="k">do</span>
<span class="c1"># this will post to Zulip as the user defined in <span class="c1"># this will post to Zulip as the user defined in
# ~/.humbugrc if you omit --user and --api-key</span> # ~/.zuliprc if you omit --user and --api-key</span>
<span class="n">run_locally</span> <span class="s2">"echo ':beers: I just deployed to </span><span class="si">#{</span><span class="n">stage</span><span class="si">}</span><span class="s2">! :beers:' | humbug-send \ <span class="n">run_locally</span> <span class="s2">"echo ':beers: I just deployed to </span><span class="si">#{</span><span class="n">stage</span><span class="si">}</span><span class="s2">! :beers:' | humbug-send \
--user capistrano-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \ --user capistrano-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \
--stream commits --subject deployments || true"</span> --stream commits --subject deployments || true"</span>
@@ -101,7 +101,7 @@
<p>Some notes:</p> <p>Some notes:</p>
<ul> <ul>
<li>If you prefer not to use <code>--user</code> and <code>--api-key</code> above, you can fill out <code>~/.humbugrc</code> on your Capistrano <li>If you prefer not to use <code>--user</code> and <code>--api-key</code> above, you can fill out <code>~/.zuliprc</code> on your Capistrano
machine. For instructions on how to write that file, see <a href="/api">the API page</a>.</li> machine. For instructions on how to write that file, see <a href="/api">the API page</a>.</li>
<li>You may need to change the <code>deploy</code> above to <li>You may need to change the <code>deploy</code> above to
another step of your deployment process, if you'd like the another step of your deployment process, if you'd like the
@@ -314,10 +314,10 @@ following, to the stream <code>commits</code> with a subject that matches the re
<p>First, download and install our <a href="/api">Python <p>First, download and install our <a href="/api">Python
bindings and example scripts</a> on your Nagios server.</p> bindings and example scripts</a> on your Nagios server.</p>
<p>Next, open <code>integrations/nagios/humbugrc.example</code> <p>Next, open <code>integrations/nagios/zuliprc.example</code>
in your favorite editor, and change the following lines to in your favorite editor, and change the following lines to
specify the email address and API key for your Nagios bot, specify the email address and API key for your Nagios bot,
saving it to <code>/etc/nagios3/humbugrc</code> on your Nagios saving it to <code>/etc/nagios3/zuliprc</code> on your Nagios
server:</p> server:</p>
<div class="codehilite"><pre>[api] <div class="codehilite"><pre>[api]

View File

@@ -6,5 +6,5 @@ python manage.py syncdb --noinput
python manage.py migrate python manage.py migrate
python manage.py createcachetable third_party_api_results python manage.py createcachetable third_party_api_results
python manage.py populate_db -n100 --threads=1 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 python manage.py sync_api_key

View File

@@ -9,9 +9,9 @@ class Command(BaseCommand):
help = """Reset all colors for a person to the default grey""" help = """Reset all colors for a person to the default grey"""
def handle(self, *args, **options): 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): if not os.path.exists(config_file):
raise RuntimeError("No ~/.humbugrc found") raise RuntimeError("No ~/.zuliprc found")
config = SafeConfigParser() config = SafeConfigParser()
with file(config_file, 'r') as f: with file(config_file, 'r') as f:
config.readfp(f, config_file) config.readfp(f, config_file)