Skip to content

Commit

Permalink
Merge pull request #1868 from jedwards4b/is_python_a_file
Browse files Browse the repository at this point in the history
make sure file exists

When testing branches or sandboxes that do not have files currently on master the
is_python_executable subroutine may be called with filepaths that do not exist. Instead of failing just return False so that testing may continue

Test suite: hand tested, scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes

User interface changes?:

Update gh-pages html (Y/N)?:

Code review:
  • Loading branch information
jgfouca authored Sep 6, 2017
2 parents 7f34aa0 + 606330d commit 4d9a8d7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/lib/CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,10 +1285,12 @@ def analyze_build_log(comp, log, compiler):
logger.info("Component {} build complete with {} warnings".format(comp, warncnt))

def is_python_executable(filepath):
with open(filepath, "r") as f:
first_line = f.readline()
if os.path.isfile(filepath):
with open(filepath, "r") as f:
first_line = f.readline()

return first_line.startswith("#!") and "python" in first_line
return first_line.startswith("#!") and "python" in first_line
return False

def get_umask():
current_umask = os.umask(0)
Expand Down

0 comments on commit 4d9a8d7

Please sign in to comment.