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

Changed configuration status var (refs #19005).

parent fe44e558
No related branches found
No related tags found
No related merge requests found
......@@ -136,14 +136,14 @@ class EnvSetup():
elif target == 'c':
# Display current configuration
log('Configuration status:')
status = utils.get_conf('_config_status')
if not status:
log('No configuration.')
override = utils.get_conf('_override')
if not override:
log('Configuration status not available.')
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']))
for name, is_overriden in override.items():
is_default = '\033[93m no ' if is_overriden else '\033[94m yes'
log('%s\033[0m | \033[95m%s\033[0m | \033[96m%s\033[0m' % (is_default, name, utils.get_conf(name)))
else:
# Run an action
found = False
......
......@@ -41,12 +41,13 @@ def exec_cmd(cmd, get_out=False):
def load_conf():
base_dir = get_dir(__file__)
files = (
(DEFAULT_CONF_PATH, True),
(CONF_PATH, False),
(os.path.join(base_dir, DEFAULT_CONF_PATH), True),
(os.path.join(base_dir, CONF_PATH), False),
)
only_default = True
status = OrderedDict()
override = 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)
......@@ -64,21 +65,19 @@ def load_conf():
val = ('='.join(val)).strip(' \t\'\"')
CONF[name] = val
if is_default:
status[name] = dict(value=val, using_default=True)
override[name] = False
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
override[name] = True
CONF['_override'] = override
# 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('Path of configuration file: %s' % os.path.join(base_dir, CONF_PATH))
log('Perhaps you want to quit this script to change the configuration?\n')
return CONF
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