bots: Fix error handling for bot not found.
The following logic in zulip_bots/zulip_bots/run.py can use some more testing. In particular, it's not clear the intent behind the provision check in the else block.
84 result = finder.resolve_bot_path(args.bot)
85 if result:
86 bot_path, bot_name = result
87 sys.path.insert(0, os.path.dirname(bot_path))
88
89 if args.provision:
90 provision_bot(os.path.dirname(bot_path), args.force)
91
92 try:
93 lib_module = finder.import_module_from_source(bot_path, bot_name)
94 except ImportError as e:
95 req_path = os.path.join(os.path.dirname(bot_path), "requirements.txt")
96 with open(req_path) as fp:
97 deps_list = fp.read()
98
99 dep_err_msg = ("ERROR: The following dependencies for the {bot_name} bot are not installed:\n\n"
100 "{deps_list}\n"
101 "If you'd like us to install these dependencies, run:\n"
102 " zulip-run-bot {bot_name} --provision")
103 print(dep_err_msg.format(bot_name=bot_name, deps_list=deps_list))
104 sys.exit(1)
105 else:
106 lib_module = finder.import_module_by_name(args.bot)
107 if lib_module:
108 bot_name = lib_module.__name__
109 if args.provision:
110 print("ERROR: Could not load bot's module for '{}'. Exiting now.")
111 sys.exit(1)
@zulipbot claim
Welcome to Zulip, @BhaskarJoshi-01! We just sent you an invite to collaborate on this repository at https://github.com/zulip/python-zulip-api/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!
Here's some tips to get you off to a good start:
- Join me on the Zulip developers' server, to get help, chat about this issue, and meet the other developers.
- Unwatch this repository, so that you don't get 100 emails a day.
As you work on this issue, you'll also want to refer to the Zulip code contribution guide, as well as the rest of the developer documentation on that site.
See you on the other side (that is, the pull request side)!
Hello @BhaskarJoshi-01, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.
You can reclaim this issue or claim any other issue by commenting @zulipbot claim on that issue.
Thanks for your contributions, and hope to see you again soon!
@zulipbot claim
Welcome to Zulip, @arnavkohli! We just sent you an invite to collaborate on this repository at https://github.com/zulip/python-zulip-api/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!
Here's some tips to get you off to a good start:
- Join me on the Zulip developers' server, to get help, chat about this issue, and meet the other developers.
- Unwatch this repository, so that you don't get 100 emails a day.
As you work on this issue, you'll also want to refer to the Zulip code contribution guide, as well as the rest of the developer documentation on that site.
See you on the other side (that is, the pull request side)!
Hello @arnavkohli, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.
You can reclaim this issue or claim any other issue by commenting @zulipbot claim on that issue.
Thanks for your contributions, and hope to see you again soon!
The following logic in
zulip_bots/zulip_bots/run.pycan use some more testing. In particular, it's not clear the intent behind the provision check in theelseblock.84 result = finder.resolve_bot_path(args.bot) 85 if result: 86 bot_path, bot_name = result 87 sys.path.insert(0, os.path.dirname(bot_path)) 88 89 if args.provision: 90 provision_bot(os.path.dirname(bot_path), args.force) 91 92 try: 93 lib_module = finder.import_module_from_source(bot_path, bot_name) 94 except ImportError as e: 95 req_path = os.path.join(os.path.dirname(bot_path), "requirements.txt") 96 with open(req_path) as fp: 97 deps_list = fp.read() 98 99 dep_err_msg = ("ERROR: The following dependencies for the {bot_name} bot are not installed:\n\n" 100 "{deps_list}\n" 101 "If you'd like us to install these dependencies, run:\n" 102 " zulip-run-bot {bot_name} --provision") 103 print(dep_err_msg.format(bot_name=bot_name, deps_list=deps_list)) 104 sys.exit(1) 105 else: 106 lib_module = finder.import_module_by_name(args.bot) 107 if lib_module: 108 bot_name = lib_module.__name__ 109 if args.provision: 110 print("ERROR: Could not load bot's module for '{}'. Exiting now.") 111 sys.exit(1)
Hello @showell , I want to contribute to this, but I am not clear about what the update should be. How do you think this can be improved to handle more testing?
@zulipbot claim
Hello @vinitwadgaonkar, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.
You can reclaim this issue or claim any other issue by commenting @zulipbot claim on that issue.
Thanks for your contributions, and hope to see you again soon!