mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Revert python path update
This commit is contained in:
		@@ -5,15 +5,11 @@ The main code for plugin special sauce is in the plugin registry in `InvenTree/p
 | 
				
			|||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
import pathlib
 | 
					 | 
				
			||||||
import sys
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django.apps import AppConfig
 | 
					from django.apps import AppConfig
 | 
				
			||||||
from django.conf import settings
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from maintenance_mode.core import set_maintenance_mode
 | 
					from maintenance_mode.core import set_maintenance_mode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from InvenTree.config import get_plugin_dir
 | 
					 | 
				
			||||||
from InvenTree.ready import canAppAccessDatabase, isInMainThread, isInWorkerThread
 | 
					from InvenTree.ready import canAppAccessDatabase, isInMainThread, isInWorkerThread
 | 
				
			||||||
from plugin import registry
 | 
					from plugin import registry
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -27,8 +23,6 @@ class PluginAppConfig(AppConfig):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def ready(self):
 | 
					    def ready(self):
 | 
				
			||||||
        """The ready method is extended to initialize plugins."""
 | 
					        """The ready method is extended to initialize plugins."""
 | 
				
			||||||
        self.update_python_path()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if not isInMainThread() and not isInWorkerThread():
 | 
					        if not isInMainThread() and not isInWorkerThread():
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -48,29 +42,3 @@ class PluginAppConfig(AppConfig):
 | 
				
			|||||||
                # drop out of maintenance
 | 
					                # drop out of maintenance
 | 
				
			||||||
                # makes sure we did not have an error in reloading and maintenance is still active
 | 
					                # makes sure we did not have an error in reloading and maintenance is still active
 | 
				
			||||||
                set_maintenance_mode(False)
 | 
					                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)
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user