diff --git a/conf.sh b/conf.sh index 56323b32878d4b5aaa38aab45608eb187b829f8b..1c77a455b8a2e5c84c69ca9ebd426e1eac3ca19e 100644 --- a/conf.sh +++ b/conf.sh @@ -1,3 +1,5 @@ #!/bin/bash # Envsetup local configuration file # See default configuration in default-conf.sh +# +# Put your configuration here diff --git a/envsetup.py b/envsetup.py index 35eef5850a91ce9a90cc3a2065db174a16238d60..e0d01453d736317e575c58ef13809775ae9165a7 100755 --- a/envsetup.py +++ b/envsetup.py @@ -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 diff --git a/utils.py b/utils.py index c59ee2e44d46af798cf6e9e3bbec1123242c42d4..2de2ac0aa3dcc78136c9d151a6059d50af226a63 100644 --- a/utils.py +++ b/utils.py @@ -1,7 +1,7 @@ #!/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):