python-zulip-api/examples/subscribe
Tim Abbott 584743eca8 [manual] Uniformize the subscriptions API method names.
This requires a zephyr_mirror deployment when it is pushed to prod.

(imported from commit 6543441fb264b518f8705d7989d068a1d50ce5d6)
2012-11-16 17:06:01 -05:00

42 lines
1.3 KiB
Python
Executable file

#!/usr/bin/python
import sys
import os
import optparse
usage = """subscribe --user=<email address> [options] --streams=<streams>
Ensures the user is subscribed to the listed streams.
Example: subscribe --user=tabbott@humbughq.com --site=http://127.0.0.1:8000
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option('--site',
dest='site',
default="https://humbughq.com",
action='store')
parser.add_option('--api-key',
dest='api_key',
default="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
action='store')
parser.add_option('--streams',
dest='streams',
default="",
action='store')
parser.add_option('--user',
dest='user',
action='store')
(options, args) = parser.parse_args()
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
import api.common
client = api.common.HumbugAPI(email=options.user,
api_key=options.api_key,
verbose=True,
site=options.site)
if options.streams == "":
print >>sys.stderr, "Usage:", parser.usage
sys.exit(1)
print client.add_subscriptions(options.streams.split())