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

bug: ctl: handle non-existing bot modules #2443

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions intelmq/bin/intelmqctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,12 @@ def check(self, no_connections=False, check_executables=True):
check_logger.error('SyntaxError in bot %r: %r', bot_id, exc)
retval = 1
continue
except AttributeError:
# if module does not exist, utils.get_bot_module_name returns None. import_module then raises
# AttributeError: 'NoneType' object has no attribute 'startswith'
check_logger.error('Incomplete installation: Bot %r not importable.', bot_id,)
retval = 1
continue
bot = getattr(bot_module, 'BOT')
bot_parameters = copy.deepcopy(global_settings)
bot_parameters.update(bot_config.get('parameters', {})) # the parameters field may not exist
Expand Down
5 changes: 4 additions & 1 deletion intelmq/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,10 @@ def _get_console_entry_points():
return entries.get("console_scripts", []) # it's a dict


def get_bot_module_name(bot_name: str) -> str:
def get_bot_module_name(bot_name: str) -> Optional[str]:
"""
Returns None if the bot does not exist
"""
entries = entry_points()
if hasattr(entries, "select"):
entries = tuple(entries.select(name=bot_name, group="console_scripts"))
Expand Down
Loading