Commit 9ec8672d authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Config as open file object

parent 79fde9b2
__version__='0.5.3'
__version__='0.5.4'
......@@ -82,7 +82,7 @@ def scan_volumes(volumes):
@click.command()
@click.option('--config-file', 'configfile', type=click.Path(), help='Configuration file path', envvar='CONFIG_FILE', show_default=True, default=f"{os.path.dirname(os.path.realpath(__file__))}/config.yml")
@click.option('--config-file', 'configfile', type=click.File(), help='Configuration file path', envvar='CONFIG_FILE', show_default=True, default=f"{os.path.dirname(os.path.realpath(__file__))}/config.yml")
def cli(configfile):
try:
......@@ -90,12 +90,15 @@ def cli(configfile):
except Error as e:
print(f"Error reading file {configfile}")
print("Config:")
print(configfile.name)
print(cfg)
validate_config(cfg)
# At this point we ensure that configuration is sane.
logger_file = cfg['logger_file']
if not logger_file.startswith('/'):
logger_file = os.path.dirname(os.path.realpath(configfile))+'/'+logger_file
logger_file = os.path.split(configfile.name)[0]+'/'+logger_file
logging.config.fileConfig(logger_file)
logger = logging.getLogger("resif_data_reporter")
logger.info("Starting")
......@@ -107,7 +110,7 @@ def cli(configfile):
cache_file = cfg['cache_file']
try:
if not cache_file.startswith('/'):
cache_file = os.path.dirname(os.path.realpath(configfile))+'/'+cache_file
cache_file = os.path.split(configfile.name)[0]+'/'+cache_file
with open(cache_file, 'r') as ymlfile:
cache = yaml.load(ymlfile)
# Compare volumes in cfg and in cache
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment