Skip to content
Snippets Groups Projects
Commit 5fe2179f authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Changed configuration status display (refs #19005).

parent 3c9ce297
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Envsetup local configuration file
# See default configuration in default-conf.sh
#
# Put your configuration here
......@@ -85,7 +85,7 @@ class EnvSetup():
log(' \033[1;94m%s\033[0m' % (action['label']))
log('')
log(' t: Run tests')
log(' c: Configuration import status')
log(' c: Configuration status')
log(' e: Exit\n')
log('Info:')
log('\033[0;36m To setup a system entirely for a determined purpose (Worker, MS, CM, ...), you can use envsetup-launcher:\033[0m')
......@@ -135,8 +135,15 @@ class EnvSetup():
log(' %s: \033[91mfailure\033[0m' % test_path)
elif target == 'c':
# Display current configuration
log('Configuration import status:')
log(utils.get_conf('config_import_status', 'Configuration file has been overwritten.'))
log('Configuration status:')
status = utils.get_conf('_config_status')
if not status:
log('No configuration.')
else:
log('Is default | Name | Value')
for name, info in status.items():
is_default = '\033[94m yes' if info['using_default'] else '\033[93m no '
log('%s\033[0m | \033[95m%s\033[0m | \033[96m%s\033[0m' % (is_default, name, info['value']))
else:
# Run an action
found = False
......
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import OrderedDict
import os
import re
import subprocess
import sys
......@@ -45,10 +45,12 @@ def load_conf():
(DEFAULT_CONF_PATH, True),
(CONF_PATH, False),
)
for path, mandatory in files:
only_default = True
status = OrderedDict()
for path, is_default in files:
if not os.path.exists(path):
log('The configuration file for EnvSetup script does not exist.\nPath of configuration file: %s' % path, error=True)
if mandatory:
if is_default:
sys.exit(1)
# Load conf
with open(path, 'r') as fo:
......@@ -61,18 +63,22 @@ def load_conf():
name = name.strip(' \t\'\"')
val = ('='.join(val)).strip(' \t\'\"')
CONF[name] = val
# Check a value to know if the config file has been changed
try:
value = getattr(CONF, 'MS_SERVER_NAME')
except Exception as e:
log('The configuration file for EnvSetup script is missing a required value: MS_SERVER_NAME.\nPlease check that the configuration file is correct.\nPath of configuration file: %s\nError:\n %s' % (CONF_PATH, e))
sys.exit(1)
if value == 'mediaserver':
log('\033[93mWarning:\033[0m')
log('The configuration file for EnvSetup script contains the default value for MS_SERVER_NAME.')
log('Perhaps you forget to change the configuration.')
log('Path of configuration file: %s' % CONF_PATH)
log('Perhaps you want to quit this script to change the configuration?\n')
if is_default:
status[name] = dict(value=val, using_default=True)
else:
only_default = False
if name not in status:
status[name] = dict()
status[name]['value'] = val
status[name]['using_default'] = False
CONF['_config_status'] = status
# Check a value to know if the config file has been changed
if only_default:
log('\033[93mWarning:\033[0m')
log('The configuration is using only default values.')
log('Perhaps you forget to change the configuration.')
log('Path of configuration file: %s' % CONF_PATH)
log('Perhaps you want to quit this script to change the configuration?\n')
def get_conf(name, default=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment