Skip to content
Snippets Groups Projects
Commit 66f5eb6e authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

reduce os.path and pathlib mixes

parent 1678853d
No related branches found
No related tags found
2 merge requests!19Move linux-debian11 into main,!1Resolve "First draft for user interface for top level install command"
......@@ -74,12 +74,9 @@ def setup_log_cmd(msg=None,*args, **kwargs):
def create_dir_structure(mpsd_release, script_dir):
# Create the directory structure for the release
release_base_dir = os.path.join(script_dir, mpsd_release)
if not os.path.exists(release_base_dir):
os.makedirs(release_base_dir)
else:
# Warn that the target directory already exists.
print(">Target directory already exists. Continuing...")
release_base_dir = script_dir / mpsd_release
release_base_dir.mkdir(parents=True, exist_ok=True)
with os_chdir(release_base_dir):
# Clone the spack-environments repo if it doesn't exist
if not os.path.exists("spack-environments"):
......@@ -98,7 +95,7 @@ def create_dir_structure(mpsd_release, script_dir):
def get_release_info(mpsd_release, script_dir):
# Get the info for release
release_base_dir = os.path.join(script_dir, mpsd_release)
release_base_dir = script_dir / mpsd_release
if not os.path.exists(release_base_dir):
raise Exception("Release directory does not exist. Run create_dir_structure() first.")
with os_chdir(release_base_dir):
......@@ -136,7 +133,7 @@ def install_environment(
print(f"Installing release {mpsd_release} with toolchains {toolchains} to {script_dir}")
# Set required variables
release_base_dir = Path(os.path.join(script_dir, mpsd_release))
release_base_dir = script_dir / mpsd_release
mpsd_os = os.environ.get("MPSD_OS", "UNKNOWN_OS")
mpsd_microarch = os.environ.get("MPSD_MICROARCH", "UNKNOWN_MICROARCH")
toolchain_dir = release_base_dir / mpsd_microarch
......@@ -228,7 +225,7 @@ def main():
args = parser.parse_args()
# target dir is the place where this script exists. the release `dev` in script_dir/dev-23a
script_dir = os.path.dirname(os.path.realpath(__file__))
script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
# Check the command and run related function
if args.action == "remove":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment