From 8e9c6cd22e0a6644b3c49b3e413aa73161ac95e6 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Mon, 2 Oct 2017 13:49:20 -0700 Subject: [PATCH] bots: zulip_bot_output.py: Check for failed bot module import. --- zulip_bots/zulip_bots/zulip_bot_output.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zulip_bots/zulip_bots/zulip_bot_output.py b/zulip_bots/zulip_bots/zulip_bot_output.py index 8113b07..c5c13bb 100644 --- a/zulip_bots/zulip_bots/zulip_bot_output.py +++ b/zulip_bots/zulip_bots/zulip_bot_output.py @@ -61,7 +61,11 @@ def main(): bot_dir = os.path.dirname(bot_path) if args.provision: provision_bot(os.path.dirname(bot_path), args.force) - lib_module = import_module_from_source(bot_path, bot_name) + try: + lib_module = import_module_from_source(bot_path, bot_name) + except IOError: + print("Could not find and import bot '{}'".format(bot_name)) + sys.exit(1) message = {'content': args.message, 'sender_email': 'foo_sender@zulip.com'} message_handler = lib_module.handler_class()