Skip to content

Check missing requirements in check command #2411

@kamil-certat

Description

@kamil-certat

Currently, bots check their requirements only during startup. It would be helpful, if the check() method of bots does it as well, so we'll get the clear information when verifying IntelMQ installation. Probably it would be also useful to have a helper that gets the modules and versions, and can be then reused.

Pseudo-code idea:

# importing with fallback to None as usual
try:
   import requests
except ImportError:
  requests = None

from intelmq.lib.utils import DependencyValidator

deps = DependencyValidator()
deps.register(module=requests, version=(1, 1, 1), validator=lambda module, version: module.__version__ >= version)
# ^ validator only optional when the package has some non-standard version check or so

# ...  in init()
    deps.validate(raise=True)

# ... in check()
    errors.extend(deps.validate(raise=False))

Maybe it would be even possible to do a method for dependency auto-discovery from corresponding REQUIREMENTS.txt file - but this could be tricky.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions