From a127d2d76616f329eb9ee34dd993517c04dab513 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Mon, 22 Jan 2024 15:01:06 -0700 Subject: [PATCH 1/2] check .cime for a machine directory first --- CIME/XML/machines.py | 12 +++++++++++- CIME/non_py/cprnc | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CIME/XML/machines.py b/CIME/XML/machines.py index ec26438f1f0..0fab6dc14e3 100644 --- a/CIME/XML/machines.py +++ b/CIME/XML/machines.py @@ -318,7 +318,7 @@ def set_machine(self, machine, schema=None): return machine elif self.get_version() == 3: machines_file = os.path.join( - self.machines_dir, machine, "config_machines.xml" + os.environ.get("HOME"), ".cime", machine, "config_machines.xml" ) if os.path.isfile(machines_file): GenericXML.read( @@ -326,6 +326,16 @@ def set_machine(self, machine, schema=None): machines_file, schema=schema, ) + else: + machines_file = os.path.join( + self.machines_dir, machine, "config_machines.xml" + ) + if os.path.isfile(machines_file): + GenericXML.read( + self, + machines_file, + schema=schema, + ) self.machine_node = super(Machines, self).get_child( "machine", {"MACH": machine}, diff --git a/CIME/non_py/cprnc b/CIME/non_py/cprnc index 845bb11f142..d17494561ac 160000 --- a/CIME/non_py/cprnc +++ b/CIME/non_py/cprnc @@ -1 +1 @@ -Subproject commit 845bb11f14260006899117b3b56f5fa0c9b6171b +Subproject commit d17494561ace91fc86387c83591c0382a2c79566 From 5f675340fff98c7a006f6664e05c62a6c7677020 Mon Sep 17 00:00:00 2001 From: Jason Boutte Date: Tue, 23 Jan 2024 17:40:24 -0800 Subject: [PATCH 2/2] Converts to pathlib --- CIME/XML/machines.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CIME/XML/machines.py b/CIME/XML/machines.py index 0fab6dc14e3..dc56b290ccf 100644 --- a/CIME/XML/machines.py +++ b/CIME/XML/machines.py @@ -7,6 +7,7 @@ from CIME.utils import convert_to_unknown_type, get_cime_config import socket +from pathlib import Path logger = logging.getLogger(__name__) @@ -317,20 +318,20 @@ def set_machine(self, machine, schema=None): if machine == "Query": return machine elif self.get_version() == 3: - machines_file = os.path.join( - os.environ.get("HOME"), ".cime", machine, "config_machines.xml" - ) - if os.path.isfile(machines_file): + machines_file = Path.home() / ".cime" / machine / "config_machines.xml" + + if machines_file.exists(): GenericXML.read( self, machines_file, schema=schema, ) else: - machines_file = os.path.join( - self.machines_dir, machine, "config_machines.xml" + machines_file = ( + Path(self.machines_dir) / machine / "config_machines.xml" ) - if os.path.isfile(machines_file): + + if machines_file.exists(): GenericXML.read( self, machines_file,