From 80d5e6168f0eab97e84a46a1f1e18aef244e8efc Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 5 Dec 2024 07:49:31 -0700 Subject: [PATCH 1/2] remove the rootdir from glob to support older python versions --- cime_config/buildnml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cime_config/buildnml b/cime_config/buildnml index 41f5f926..151dd917 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -247,8 +247,9 @@ def _create_namelists(case, confdir, infile, nmlgen, inst_string): # find the most recent file matching pattern cice_ptr = None pattern = "rpointer.ice*" - files = glob.glob(pattern, root_dir=rundir) - files.sort(key=lambda x: os.path.getmtime(os.path.join(rundir,x))) + with chdir(rundir): + files = glob.glob(pattern) + files.sort(key=lambda x: os.path.getmtime(os.path.join(rundir,x))) if files: cice_ptr = files[-1] From f450b48c2bf4e797e9a9a4cc2f8cf0a74289a9a1 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 5 Dec 2024 09:25:02 -0700 Subject: [PATCH 2/2] cant use context manager --- cime_config/buildnml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cime_config/buildnml b/cime_config/buildnml index 151dd917..f0c65970 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -247,9 +247,10 @@ def _create_namelists(case, confdir, infile, nmlgen, inst_string): # find the most recent file matching pattern cice_ptr = None pattern = "rpointer.ice*" - with chdir(rundir): - files = glob.glob(pattern) - files.sort(key=lambda x: os.path.getmtime(os.path.join(rundir,x))) + os.chdir(rundir) + files = glob.glob(pattern) + files.sort(key=lambda x: os.path.getmtime(os.path.join(rundir,x))) + os.chdir(case.get_case_root()) if files: cice_ptr = files[-1]