From d99dbd725e2f24b65b06117c52c09aa5202f73b7 Mon Sep 17 00:00:00 2001
From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de>
Date: Tue, 6 Jun 2023 17:13:28 +0200
Subject: [PATCH] firest attempt at relocation of variables

---
 mpsd-software-environment.py | 19 +++++++++++--------
 tests.py                     |  4 ++--
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py
index 569d3a5..be87124 100755
--- a/mpsd-software-environment.py
+++ b/mpsd-software-environment.py
@@ -792,19 +792,22 @@ def main():
 
     # Get machine configs
     os.environ.get("MPSD_OS", "UNKNOWN_OS")
-    os.environ.get("MPSD_MICROARCH", "UNKNOWN_MICROARCH")
+    mpsd_microarch = os.environ.get("MPSD_MICROARCH", "UNKNOWN_MICROARCH")
+    # release `dev` in script_dir/dev-23a
+    script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
+    mpsd_release = args.release
     # parse logging first
     # decide the log_file_name
-    (
-        config_vars["build_log_file"]
-        .replace("mpsd_spack_ver_", f"{mpsd_release}_")
-        .replace("_toolchains_", f"_{toolchain}_")
+    installer_log_name, build_log_name = create_log_file_names(
+        mpsd_release=mpsd_release, mpsd_microarch=mpsd_microarch, action=args.action
+    )
+    installer_log_file = (
+        script_dir / mpsd_release / mpsd_microarch / "logs" / installer_log_name
     )
-    set_up_logging(args.loglevel)
+
+    set_up_logging(args.loglevel, installer_log_file)
 
     # target dir is the place where this script exists. the
-    # release `dev` in script_dir/dev-23a
-    script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
 
     # Check the command and run related function
     if args.action == "remove":
diff --git a/tests.py b/tests.py
index 9fa9897..d2a35f2 100644
--- a/tests.py
+++ b/tests.py
@@ -385,7 +385,7 @@ def test_create_log_file_names():
         toolchain=toolchain,
     )
     assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_status.log"
-    assert build_log_file == None
+    assert build_log_file is None
     # test no build log file for incorrect toolchain
     installer_log_file, build_log_file = create_log_file_names(
         mpsd_microarch=mpsd_microarch,
@@ -395,7 +395,7 @@ def test_create_log_file_names():
         toolchain=None,
     )
     assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_reinstall.log"
-    assert build_log_file == None
+    assert build_log_file is None
 
 
 def test_interface(tmp_path):
-- 
GitLab