From 0ade577b29d319cc631a60265871e9ff3e654cc6 Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Wed, 7 Jun 2023 15:56:33 +0200 Subject: [PATCH] fix installer log file path and tests --- mpsd-software-environment.py | 13 +++++++------ tests.py | 6 +++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py index 5a78c28..94b41b9 100755 --- a/mpsd-software-environment.py +++ b/mpsd-software-environment.py @@ -151,21 +151,20 @@ def read_metadata_from_logfile(logfile: Union[str, Path]) -> dict: } -def get_installer_log_file(args: argparse.Namespace, script_dir: str) -> str: +def get_installer_log_file(mpsd_release: str, cmd: str, script_dir: str) -> str: """Get installer log file name.""" # Get machine configs os.environ.get("MPSD_OS", "UNKNOWN_OS") mpsd_microarch = get_native_microarchitecture() - mpsd_release = args.release # parse logging first # decide the log_file_name installer_log_name, build_log_name = create_log_file_names( - mpsd_release=mpsd_release, mpsd_microarch=mpsd_microarch, action=args.action + mpsd_release=mpsd_release, mpsd_microarch=mpsd_microarch, action=cmd ) - log_folder = script_dir / mpsd_release / mpsd_microarch / "logs" + log_folder = script_dir / mpsd_release / "logs" # if the log_folder dosent exist, dont log this message if # the command is a info-only command - if args.action not in ["status", "available"]: + if cmd not in ["status", "available"]: if not os.path.exists(log_folder): os.makedirs(log_folder) installer_log_file = log_folder / installer_log_name @@ -911,7 +910,9 @@ def main(): # target dir is the place where this script exists. the script_dir = Path(os.path.dirname(os.path.realpath(__file__))) - set_up_logging(args.loglevel, get_installer_log_file(args, script_dir)) + set_up_logging( + args.loglevel, get_installer_log_file(args.release, args.action, script_dir) + ) # Check the command and run related function if args.action == "remove": diff --git a/tests.py b/tests.py index fb43939..0860417 100644 --- a/tests.py +++ b/tests.py @@ -270,6 +270,10 @@ def test_install_environment_zlib(): f.write(lines) # install global_generic toolchain + mod.set_up_logging( + "WARNING", + mod.get_installer_log_file(mpsd_release_to_test, "install", script_dir), + ) mod.install_environment( mpsd_release=mpsd_release_to_test, toolchains=[toolchain_to_test], @@ -332,7 +336,7 @@ def test_install_environment_zlib(): f"{mpsd_release_to_test}_{mpsd_microarch}_*_install.log" ) ) - assert len(build_log) > 1 + assert len(build_log) > 2 def test_metadata_logging(tmp_path): -- GitLab