Skip to content
Snippets Groups Projects
Commit 845b5d8c authored by vlorentz's avatar vlorentz
Browse files

cli: Don't show a traceback or warning if the config file does not exist

parent 57400588
No related branches found
Tags v0.5.3
No related merge requests found
......@@ -66,23 +66,27 @@ def fuse(ctx, config_file):
if not config_file:
config_file = DEFAULT_CONFIG_PATH
try:
conf = config.read_raw_config(config.config_basepath(config_file))
if not conf:
raise ValueError(f"Cannot parse configuration file: {config_file}")
if config_file == DEFAULT_CONFIG_PATH:
try:
conf = conf["swh"]["fuse"]
except KeyError:
pass
# recursive merge not done by config.read
conf = config.merge_configs(DEFAULT_CONFIG, conf)
except Exception:
logging.warning(
"Using default configuration (cannot load custom one)", exc_info=True
)
if os.path.isfile(config_file):
try:
conf = config.read_raw_config(config.config_basepath(config_file))
if not conf:
raise ValueError(f"Cannot parse configuration file: {config_file}")
if config_file == DEFAULT_CONFIG_PATH:
try:
conf = conf["swh"]["fuse"]
except KeyError:
pass
# recursive merge not done by config.read
conf = config.merge_configs(DEFAULT_CONFIG, conf)
except Exception:
logging.warning(
"Using default configuration (cannot load custom one)", exc_info=True
)
conf = DEFAULT_CONFIG
else:
logging.info("Using default configuration")
conf = DEFAULT_CONFIG
logging.debug("Read configuration: \n%s", yaml.dump(conf))
......
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