[api version bump] Update API documentation in the example scripts

Give better examples, and rewrite options parsing to be more consistent across examples.
Make it more obvious that you can use "--user" and "--api-key" with our python examples.

This bumps our python bindings to v0.1.9

(imported from commit 297468088f864b7d585e567dc45523ea681f1856)
This commit is contained in:
acrefoot 2013-05-29 14:00:27 -04:00
parent 35b822b58d
commit dfb8a16a55
22 changed files with 92 additions and 87 deletions

View file

@ -25,7 +25,8 @@ 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. Test the script by running it manually, like this:
3. create a ~/.humbugrc, 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
@ -40,14 +41,6 @@ stream every 5 minutes is:
*/5 * * * * /usr/local/share/humbug/demos/rss-bot"""
parser = optparse.OptionParser(usage)
parser.add_option('--email',
dest='email',
help='The email address for your Humbug account.',
metavar='EMAIL')
parser.add_option('--api-key',
dest='api_key',
help='API key for that user [default: read ~/.humbug-api-key]',
action='store')
parser.add_option('--stream',
dest='stream',
help='The stream to which to send RSS messages.',
@ -63,11 +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('--site',
dest='site',
default="https://humbughq.com",
help=optparse.SUPPRESS_HELP,
action='store')
parser.add_option_group(humbug.generate_option_group(parser))
(opts, args) = parser.parse_args()
def mkdir_p(path):

View file

@ -16,7 +16,7 @@ def write_config(config, since_id, user):
parser = optparse.OptionParser(r"""
%prog --user foo@humbughq.com --twitter-id twitter_handle
%prog --user foo@example.com --api-key 0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --twitter-id twitter_handle
Slurp tweets on your timeline into a specific humbug stream.
@ -44,18 +44,9 @@ parser = optparse.OptionParser(r"""
Depends on: twitter-python
""")
parser.add_option('--user',
help='Humbug user email address',
metavar='EMAIL')
parser.add_option('--api-key',
help='API key for that user [default: read ~/.humbugrc]')
parser.add_option('--twitter-id',
help='Twitter username to poll for new tweets from"',
metavar='URL')
parser.add_option('--site',
default="https://humbughq.com",
help='Humbug site [default: https://humbughq.com]',
metavar='URL')
parser.add_option('--stream',
help='Default humbug stream to write tweets to')
parser.add_option('--limit-tweets',
@ -63,6 +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))
(options, args) = parser.parse_args()
if not options.twitter_id:

View file

@ -18,7 +18,7 @@ def write_config(config, since_id):
parser = optparse.OptionParser(r"""
%prog --user foo@humbughq.com --search="@nprnews,quantum physics"
%prog --user foo@humbughq.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 --search="@nprnews,quantum physics"
Send Twitter search results to a Humbug stream.
@ -63,20 +63,10 @@ Make sure to go the application you created and click "create my
access token" as well. Fill in the values displayed.
""")
parser.add_option('--user',
help='Humbug user email address',
metavar='EMAIL')
parser.add_option('--api-key',
help='API key for that user [default: read ~/.humbugrc]')
parser.add_option('--search',
dest='search_terms',
help='Terms to search on',
action='store')
parser.add_option('--site',
dest='site',
default="https://humbughq.com",
help=optparse.SUPPRESS_HELP,
action='store')
parser.add_option('--stream',
dest='stream',
help='The stream to which to send tweets',
@ -87,6 +77,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))
(opts, args) = parser.parse_args()
if not opts.search_terms: