Skip to content

Commit

Permalink
Move auto reloader attachment into development plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Nov 25, 2024
1 parent 52b589a commit 5dd408d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
18 changes: 18 additions & 0 deletions integration_testing/development_plugin/kolibri_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
import os

from magicbus.plugins import SimplePlugin
from magicbus.plugins.tasks import Autoreloader

from kolibri.core.content.hooks import ShareFileHook
from kolibri.core.device.hooks import CheckIsMeteredHook
Expand Down Expand Up @@ -70,3 +72,19 @@ def RUN(self):
@register_hook
class DeveloperAppUrlLogger(KolibriProcessHook):
MagicBusPluginClass = AppUrlLoggerPlugin


class KolibriAutoReloader(Autoreloader):
def __init__(self, bus):
super().__init__(bus)
from kolibri.utils import conf

plugins = os.path.join(conf.KOLIBRI_HOME, "plugins.json")
options = os.path.join(conf.KOLIBRI_HOME, "options.ini")
self.files.add(plugins)
self.files.add(options)


@register_hook
class KolibriAutoReloadHook(KolibriProcessHook):
MagicBusPluginClass = KolibriAutoReloader
9 changes: 0 additions & 9 deletions kolibri/utils/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from magicbus.plugins.servers import wait_for_free_port
from magicbus.plugins.servers import wait_for_occupied_port
from magicbus.plugins.signalhandler import SignalHandler as BaseSignalHandler
from magicbus.plugins.tasks import Autoreloader
from magicbus.plugins.tasks import Monitor
from zeroconf import get_all_addresses
from zeroconf import InterfaceChoice
Expand Down Expand Up @@ -755,14 +754,6 @@ def __init__(

signal_handler.subscribe()

if getattr(settings, "DEVELOPER_MODE", False):
autoreloader = Autoreloader(self)
plugins = os.path.join(conf.KOLIBRI_HOME, "plugins.json")
options = os.path.join(conf.KOLIBRI_HOME, "options.ini")
autoreloader.files.add(plugins)
autoreloader.files.add(options)
autoreloader.subscribe()

reload_plugin = ProcessControlPlugin(self)
reload_plugin.subscribe()

Expand Down

0 comments on commit 5dd408d

Please sign in to comment.