jabber_mirror: Report a useful error message when fetching initial Zulip streams/subscriptions

(imported from commit 1133cb0ddb349cda7e16586fba4ba72888e66887)
This commit is contained in:
Zev Benjamin 2014-03-04 19:22:25 -05:00
parent 799953e7df
commit 83afe8f6f8

View file

@ -270,10 +270,17 @@ class ZulipToJabberBot(object):
self.jabber.leave_muc(stream_to_room(stream)) self.jabber.leave_muc(stream_to_room(stream))
def get_rooms(zulip): def get_rooms(zulip):
def get_stream_infos(key, method):
ret = method()
if ret.get("result") != "success":
logging.error(ret)
sys.exit("Could not get initial list of Zulip %s" % (key,))
return ret[key]
if options.mode == 'public': if options.mode == 'public':
stream_infos = zulip.client.get_streams()['streams'] stream_infos = get_stream_infos("streams", zulip.client.get_streams)
else: else:
stream_infos = zulip.client.list_subscriptions()['subscriptions'] stream_infos = get_stream_infos("subscriptions", zulip.client.list_subscriptions)
rooms = [] rooms = []
for stream_info in stream_infos: for stream_info in stream_infos: