Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bots: Fix error handling for bot not found. #489

Open
showell opened this issue Nov 30, 2018 · 11 comments · May be fixed by #548 or #855
Open

bots: Fix error handling for bot not found. #489

showell opened this issue Nov 30, 2018 · 11 comments · May be fixed by #548 or #855

Comments

@showell
Copy link
Contributor

showell commented Nov 30, 2018

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)
@BhaskarJoshi-01
Copy link
Collaborator

@zulipbot claim

@zulipbot
Copy link
Member

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:

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)!

@zulipbot
Copy link
Member

zulipbot commented Mar 3, 2020

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!

@arnavkohli
Copy link
Collaborator

@zulipbot claim

@zulipbot
Copy link
Member

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:

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)!

@zulipbot
Copy link
Member

zulipbot commented Mar 24, 2020

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!

@mharyam
Copy link

mharyam commented Nov 2, 2021

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)

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?

@vinitwadgaonkar
Copy link
Collaborator

@zulipbot claim

@zulipbot
Copy link
Member

zulipbot commented Dec 18, 2021

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!

@pranavrockz
Copy link
Collaborator

@zulipbot claim

@zulipbot
Copy link
Member

Hello @pranavrockz!

Thanks for your interest in Zulip! You have attempted to claim an issue without the label "help wanted". You can only claim and submit pull requests for issues with the help wanted label.

If this is your first time here, we recommend reading our guide for new contributors before getting started.

@shiva-sai-824 shiva-sai-824 linked a pull request Feb 6, 2025 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants