mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45: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:
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import hashlib
|
||||
import logging
|
||||
|
||||
from InvenTree import plugins as InvenTreePlugins
|
||||
from barcode import plugins as BarcodePlugins
|
||||
@ -10,6 +11,9 @@ from stock.serializers import StockItemSerializer, LocationSerializer
|
||||
from part.serializers import PartSerializer
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def hash_barcode(barcode_data):
|
||||
"""
|
||||
Calculate an MD5 hash of barcode data
|
||||
@ -130,18 +134,17 @@ def load_barcode_plugins(debug=False):
|
||||
Function to load all barcode plugins
|
||||
"""
|
||||
|
||||
if debug:
|
||||
print("Loading barcode plugins")
|
||||
logger.debug("Loading barcode plugins")
|
||||
|
||||
plugins = InvenTreePlugins.get_plugins(BarcodePlugins, BarcodePlugin)
|
||||
|
||||
if debug:
|
||||
if len(plugins) > 0:
|
||||
print("Discovered {n} plugins:".format(n=len(plugins)))
|
||||
logger.info(f"Discovered {len(plugins)} barcode plugins")
|
||||
|
||||
for p in plugins:
|
||||
print(" - {p}".format(p=p.PLUGIN_NAME))
|
||||
logger.debug(" - {p}".format(p=p.PLUGIN_NAME))
|
||||
else:
|
||||
print("No barcode plugins found")
|
||||
logger.debug("No barcode plugins found")
|
||||
|
||||
return plugins
|
||||
|
Reference in New Issue
Block a user