2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 12:35:46 +00:00

Improve settings.py

- Load database config from either config.yaml or environment variables
- Mix and match, if you want!
- Move to use logging module rather than just printing stuff
- Error if required database parameters are not required
This commit is contained in:
Oliver Walters
2020-11-13 13:38:01 +11:00
parent 1d4b826d03
commit 0f42916521
9 changed files with 183 additions and 71 deletions

View File

@ -1,8 +1,13 @@
# -*- coding: utf-8 -*-
import logging
import plugins.plugin as plugin
logger = logging.getLogger(__name__)
class ActionPlugin(plugin.InvenTreePlugin):
"""
The ActionPlugin class is used to perform custom actions

View File

@ -3,12 +3,16 @@
import inspect
import importlib
import pkgutil
import logging
# Action plugins
import plugins.action as action
from plugins.action.action import ActionPlugin
logger = logging.getLogger(__name__)
def iter_namespace(pkg):
return pkgutil.iter_modules(pkg.__path__, pkg.__name__ + ".")
@ -52,14 +56,14 @@ def load_action_plugins():
Return a list of all registered action plugins
"""
print("Loading action plugins")
logger.debug("Loading action plugins")
plugins = get_plugins(action, ActionPlugin)
if len(plugins) > 0:
print("Discovered {n} action plugins:".format(n=len(plugins)))
logger.info("Discovered {n} action plugins:".format(n=len(plugins)))
for ap in plugins:
print(" - {ap}".format(ap=ap.PLUGIN_NAME))
logger.debug(" - {ap}".format(ap=ap.PLUGIN_NAME))
return plugins