Development
This commit is contained in:
parent
19f0bfa79c
commit
687e0a66d1
8 changed files with 142 additions and 1 deletions
23
docker/routlin-portal/app/config_utils.py
Normal file
23
docker/routlin-portal/app/config_utils.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import copy, json, os
|
||||
|
||||
CONFIGS_DIR = '/routlin_location'
|
||||
CONFIG_FILE = f'{CONFIGS_DIR}/config.json'
|
||||
CAPTIVE_QUEUE = f'{CONFIGS_DIR}/.captive-queue'
|
||||
|
||||
_config_cache = None
|
||||
_config_mtime = None
|
||||
|
||||
|
||||
def load_config():
|
||||
global _config_cache, _config_mtime
|
||||
try:
|
||||
mtime = os.path.getmtime(CONFIG_FILE)
|
||||
if _config_cache is not None and mtime == _config_mtime:
|
||||
return copy.deepcopy(_config_cache)
|
||||
with open(CONFIG_FILE) as f:
|
||||
data = json.load(f)
|
||||
_config_cache = data
|
||||
_config_mtime = mtime
|
||||
return copy.deepcopy(data)
|
||||
except Exception:
|
||||
return {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue