2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-13 18:45:40 +00:00
This commit is contained in:
Oliver Walters
2024-11-17 06:24:40 +00:00
parent 4c7d248bf6
commit a40c85d47d

View File

@ -5,15 +5,11 @@ The main code for plugin special sauce is in the plugin registry in `InvenTree/p
"""
import logging
import pathlib
import sys
from django.apps import AppConfig
from django.conf import settings
from maintenance_mode.core import set_maintenance_mode
from InvenTree.config import get_plugin_dir
from InvenTree.ready import canAppAccessDatabase, isInMainThread, isInWorkerThread
from plugin import registry
@ -27,8 +23,6 @@ class PluginAppConfig(AppConfig):
def ready(self):
"""The ready method is extended to initialize plugins."""
self.update_python_path()
if not isInMainThread() and not isInWorkerThread():
return
@ -48,29 +42,3 @@ class PluginAppConfig(AppConfig):
# drop out of maintenance
# makes sure we did not have an error in reloading and maintenance is still active
set_maintenance_mode(False)
def update_python_path(self):
"""Update the PYTHONPATH to include the plugin directory."""
if not settings.PLUGINS_ENABLED:
# Custom plugins disabled - no need to update PYTHONPATH
logger.info('Custom plugins are not enabled')
return
plugin_dir = get_plugin_dir()
if not plugin_dir:
logger.warning('Plugins directory not specified')
return
if plugin_dir := get_plugin_dir():
path = pathlib.Path(plugin_dir)
if not path.exists():
try:
path.mkdir(parents=True, exist_ok=True)
except Exception:
logger.error(f'Failed to create plugin directory: {plugin_dir}')
return
if plugin_dir not in sys.path:
sys.path.append(plugin_dir)