From 83afe8f6f89de6be3bcb562f45641e49724b2b72 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Tue, 4 Mar 2014 19:22:25 -0500 Subject: [PATCH] jabber_mirror: Report a useful error message when fetching initial Zulip streams/subscriptions (imported from commit 1133cb0ddb349cda7e16586fba4ba72888e66887) --- bots/jabber_mirror.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bots/jabber_mirror.py b/bots/jabber_mirror.py index 1bba081..2530c72 100755 --- a/bots/jabber_mirror.py +++ b/bots/jabber_mirror.py @@ -270,10 +270,17 @@ class ZulipToJabberBot(object): self.jabber.leave_muc(stream_to_room(stream)) 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': - stream_infos = zulip.client.get_streams()['streams'] + stream_infos = get_stream_infos("streams", zulip.client.get_streams) else: - stream_infos = zulip.client.list_subscriptions()['subscriptions'] + stream_infos = get_stream_infos("subscriptions", zulip.client.list_subscriptions) rooms = [] for stream_info in stream_infos: