errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.13k stars 615 forks source link

Plugin Manager: 'NoneType' object has no attribute 'is_activated' #1619

Closed chadleeshaw closed 1 year ago

chadleeshaw commented 1 year ago

I'm not able to load my plugin called axbot. I keep getting this error.

errbot 9.9.9 errbot-backend-slackv3 0.2.1 errbot-plugin-axbot 1.1

21:30:08 DEBUG    errbot.plugins.VersionChe Checking version in background.
21:30:08 DEBUG    errbot.botplugin          Programming the polling of version_check every 86400 seconds with args [] and kwargs {}
21:30:08 DEBUG    urllib3.connectionpool    Starting new HTTPS connection (1): errbot.io:443
21:30:08 DEBUG    errbot.botplugin          Init storage for VersionChecker.
21:30:08 DEBUG    errbot.storage            Opening storage 'VersionChecker'
21:30:08 DEBUG    errbot.storage.shelf      Open shelf storage ./data/VersionChecker.db
21:30:08 INFO     errbot.core_plugins.wsvie Checking VersionChecker for webhooks
21:30:08 ERROR    errbot.plugin_manager     Error loading Axbot.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/errbot/plugin_manager.py", line 445, in activate_non_started_plugins
    if not plugin.is_activated:
AttributeError: 'NoneType' object has no attribute 'is_activated'

https://github.com/errbotio/errbot/blob/b1a6408eca4834f7f6b557c35fdf137cdacb074f/errbot/plugin_manager.py#L445

setup.py

from setuptools import setup, find_packages

setup(
    name="errbot-plugin-axbot",
    version="1.1",
    description="Errbot axbot plugin",
    author="Errbot",
    packages=find_packages(where="src"),
    package_dir={'': 'src'},
    package_data={
        "axbot": [
            "*.plug",
        ],
    },
    include_package_data=True,
    entry_points={
        "errbot.plugins": [
            "axbot = axbot:Axbot",
        ]
    },
)

./src/axbot/axbot.py has the Axbot class: class Axbot(BotPlugin):

./src/axbot/axbot.plug:

[Core]
name = Axbot
module = axbot

[Documentation]
description = Chat bot commands

[Python]
version = 3

config.py

BACKEND="SlackV3"
BOT_PREFIX = '<@redacted>'
BOT_DATA_DIR = './data'
BOT_EXTRA_PLUGIN_DIR = './src'
BOT_EXTRA_BACKEND_DIR="./backend"
BOT_LOG_FILE = './errbot.log'
BOT_LOG_LEVEL = logging.DEBUG
CHATROOM_PRESENCE = ()
CORE_PLUGINS = ()
HIDE_RESTRICTED_COMMANDS = True
DIVERT_TO_PRIVATE = ("help")

Dockerfile:

ARG INSTALL_EXTRAS=slack

FROM ${BASE_IMAGE} AS build
ARG INSTALL_EXTRAS
WORKDIR /wheel
RUN apt update && apt install -y build-essential git
RUN git clone https://github.com/errbotio/errbot.git /wheel
RUN pip3 wheel --wheel-dir=/wheel \
    wheel . .[${INSTALL_EXTRAS}]

FROM ${BASE_IMAGE} AS base
ARG INSTALL_EXTRAS
COPY --from=build /wheel /wheel
RUN apt update && \
    apt install -y git && \
    cd /wheel && \
    pip3 -vv install --no-cache-dir --no-index --find-links /wheel \
    errbot errbot[${INSTALL_EXTRAS}] && \
    rm -rf /wheel /var/lib/apt/lists/*
RUN useradd -m errbot

FROM base
WORKDIR /opt/errbot
RUN mkdir data && mkdir backend
EXPOSE 3141 3142
VOLUME /opt/errbot
COPY ./ /opt/errbot
RUN pip install -r ./src/axbot/requirments.txt
RUN pip install .
RUN git clone https://github.com/errbotio/err-backend-slackv3 backend/slackv3
RUN cd ./backend/slackv3 && pip install .
STOPSIGNAL SIGINT
ENTRYPOINT [ "/usr/local/bin/errbot" ]
chadleeshaw commented 1 year ago

Also getting this error:

23:19:27 ERROR    errbot.bootstrap          Some plugins failed to load:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/errbot/plugin_manager.py", line 289, in _load_plugins_generic
    plugin_classes = plugin_info.load_plugin_classes(
  File "/usr/local/lib/python3.9/site-packages/errbot/plugin_info.py", line 100, in load_plugin_classes
    spec.loader.exec_module(modu1e)
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ModuleNotFoundError: No module named 'errbot.plugins'

https://github.com/errbotio/errbot/blob/master/errbot/plugin_manager.py#L314

chadleeshaw commented 1 year ago

Turns out I didn't have my python code properly in a module. Once I fixed this everything worked. Error messaging threw me off.

sijis commented 1 year ago

Good to know.