Skip to content

Commit

Permalink
Change implementation of default caseroot for check_lockedfiles
Browse files Browse the repository at this point in the history
For some reason, some tests in scripts_regression_tests were failing for me with
the old version of this code - maybe because default arguments are evaluated
when the function is defined (not when it is called)?

This new version seems more likely to be what's wanted - i.e., getting the
current working directory at the time when the function is called, not the time
when it's defined.

In particular, this seems like it could (in principle) be important in
case_setup, which does:

    os.chdir(caseroot)

before calling:

            check_lockedfiles()

Test suite: None
Test baseline: N/A
Test namelist changes: N/A
Test status: N/A

Fixes: None

User interface changes?: No

Code review: None
  • Loading branch information
billsacks committed Aug 15, 2016
1 parent 492e038 commit f210e1c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion utils/python/CIME/check_lockedfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

import glob

def check_lockedfiles(caseroot=os.getcwd()):
def check_lockedfiles(caseroot=None):
"""
Check that all lockedfiles match what's in case
If caseroot is not specified, it is set to the current working directory
"""
if caseroot is None:
caseroot = os.getcwd()
lockedfiles = glob.glob(os.path.join(caseroot, "LockedFiles", "*.xml"))
for lfile in lockedfiles:
fpart = os.path.basename(lfile)
Expand Down

0 comments on commit f210e1c

Please sign in to comment.