Commit 175aca9f authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch '3376-no-message-on-session-yaml-loading-error' into 'master'

Resolve "No message on session yaml loading error"

Closes #3376

See merge request !4679
parents 71f4fe32 e49b6557
Pipeline #75558 failed with stages
in 109 minutes and 4 seconds
......@@ -832,7 +832,7 @@ class Config(metaclass=Singleton):
def parsing_report(self):
if self.invalid_yaml_files:
report = "YAML parsing error(s):\n"
report = f"Ignored {len(self.invalid_yaml_files)} YAML file(s) due to parsing error(s):\n"
for path, msg in self.invalid_yaml_files.items():
report += f" - {path}:\n"
report += f"{indent(msg, ' |')}\n"
......
......@@ -555,7 +555,7 @@ def initialize(
if config.invalid_yaml_files:
print()
print(
f"Found {len(config.invalid_yaml_files)} YAML parsing error(s), use config.parsing_report() for details.\n"
f"Ignored {len(config.invalid_yaml_files)} YAML file(s) due to parsing error(s), use config.parsing_report() for details.\n"
)
# Setup(s)
......
......@@ -165,13 +165,18 @@ def main():
sys.exit(0)
# check beacon connection
static.get_config()
config = static.get_config()
# Start a specific session
if arguments["--session"]:
session_name = arguments["--session"]
if session_name not in get_sessions_list():
print(("'%s' does not seem to be a valid session, exiting." % session_name))
print(f"\n'{session_name}' does not seem to be a valid session, ", end="")
if config.invalid_yaml_files:
print("it may relate to the following yaml error(s):")
config.parsing_report()
else:
print("exiting.")
print_sessions_list(get_sessions_list())
sys.exit(0)
else:
......
......@@ -10,6 +10,7 @@ import os
from unittest.mock import patch
import pytest
import ruamel
import subprocess
from bliss.config.conductor import client
from bliss.config.static import ConfigNode
......@@ -162,6 +163,26 @@ def test_ruamel_load_error(beacon, beacon_directory):
assert error_msg.startswith("YAML parser failure:")
def test_broken_session_yml(beacon, beacon_directory):
broken_session = f"{beacon_directory}/broken_session.yml"
with open(broken_session, "w") as f:
f.write("foo")
bliss_shell = subprocess.Popen(
[sys.executable, "-m", "bliss.shell.main", "-s", "broken_session"],
stdout=subprocess.PIPE,
)
output, err = bliss_shell.communicate()
expected = "'broken_session' does not seem to be a valid session, "
expected += "it may relate to the following yaml error(s):\n"
expected += "Ignored 1 YAML file(s) due to parsing error(s):\n"
expected += " - broken_session.yml:\n"
expected += " |'str' object has no attribute 'items'\n"
assert expected in output.decode()
@pytest.mark.parametrize(
"object_name, get_func_name, copy",
[["refs_test", "get", False], ["refs_test_cpy", "get_config", True]],
......
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