Skip to content

Commit

Permalink
Merge pull request #25 from mundialis/pc_templates_configurable
Browse files Browse the repository at this point in the history
made location of pc templates configurable
  • Loading branch information
linakrisztian authored Aug 15, 2022
2 parents 6eb954e + 4ee6e6b commit ff73679
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 2 deletions.
15 changes: 15 additions & 0 deletions actinia_module_plugin/resources/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import configparser
import glob
from pathlib import Path
import os

# config can be overwritten by mounting *.ini files into folders inside
# the config folder.
Expand All @@ -36,6 +37,12 @@
GENERATED_CONFIG = DEFAULT_CONFIG_PATH + '/actinia-module-plugin.cfg'


class PCTEMPLATECONFIG:
""" Default path for 'templates/pc_templates'
"""
pathfile = '/src/actinia-module-plugin/config/templates/pc_templates'


class LOGCONFIG:
"""Default config for logging
"""
Expand Down Expand Up @@ -74,5 +81,13 @@ def __init__(self):
if config.has_option("LOGCONFIG", "type"):
LOGCONFIG.type = config.get("LOGCONFIG", "type")

# TEMPLATE PATH
if os.getenv("PCTEMPLATES") is not None:
PCTEMPLATECONFIG.pathfile = os.getenv("PCTEMPLATES")
elif config.has_section("PCTEMPLATECONFIG"):
if config.has_option("PCTEMPLATECONFIG", "pathfile"):
PCTEMPLATECONFIG.pathfile = config.get("PCTEMPLATECONFIG",
"pathfile")


init = Configfile()
8 changes: 6 additions & 2 deletions actinia_module_plugin/resources/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
__license__ = "Apache-2.0"


from jinja2 import Environment, PackageLoader
from jinja2 import Environment, PackageLoader, FileSystemLoader

from actinia_module_plugin.resources.config import PCTEMPLATECONFIG


# this environment is used for all cases where individual templates are loaded
tplEnv = Environment(
Expand All @@ -33,5 +36,6 @@

# this environment is used for process chain templates only
pcTplEnv = Environment(
loader=PackageLoader('actinia_module_plugin', 'templates/pc_templates')
# loader=PackageLoader('actinia_module_plugin', 'templates/pc_templates')
loader=FileSystemLoader(PCTEMPLATECONFIG.pathfile)
)
2 changes: 2 additions & 0 deletions config/mount/sample.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[PCTEMPLATECONFIG]
pathfile = '/src/actinia-module-plugin/config/templates/pc_templates'
[LOGCONFIG]
logfile = actinia-module-plugin.log
level = DEBUG
Expand Down

0 comments on commit ff73679

Please sign in to comment.