Skip to content

Commit

Permalink
more exception handling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Oct 10, 2017
1 parent 5a2c68c commit 8e51ac3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
25 changes: 17 additions & 8 deletions scripts/lib/CIME/SystemTests/system_tests_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@ def build(self, sharedlib_only=False, model_only=False):
try:
self.build_phase(sharedlib_only=(phase_name==SHAREDLIB_BUILD_PHASE),
model_only=(phase_name==MODEL_BUILD_PHASE))
except:
except BaseException as e:
success = False
msg = sys.exc_info()[1].message

try:
msg = e.message
except:
msg = str(e)
if "BUILD FAIL" in msg:
# Don't want to print stacktrace for a model failure since that
# is not a CIME/infrastructure problem.
excmsg = msg
else:
excmsg = "Exception during build:\n{}\n{}".format(sys.exc_info()[1], traceback.format_exc())
excmsg = "Exception during build:\n{}\n{}".format(msg, traceback.format_exc())

logger.warning(excmsg)
append_testlog(excmsg)
Expand Down Expand Up @@ -155,9 +157,12 @@ def run(self):

self._check_for_memleak()

except BaseException as msg:
except BaseException as e:
success = False
msg = str(msg)
try:
msg = e.message
except:
msg = str(e)
if "RUN FAIL" in msg:
# Don't want to print stacktrace for a model failure since that
# is not a CIME/infrastructure problem.
Expand Down Expand Up @@ -242,8 +247,12 @@ def _coupler_log_indicates_run_complete(self):
try:
if six.b("SUCCESSFUL TERMINATION") in gzip.open(cpllog, 'rb').read():
allgood = allgood - 1
except BaseException as msg:

except BaseException as e:
try:
msg = e.message
except:
msg = str(e)

logger.info("{} is not compressed, assuming run failed {}".format(cpllog, msg))

return allgood==0
Expand Down
1 change: 0 additions & 1 deletion scripts/lib/CIME/XML/env_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Base class for env files. This class inherits from EntryID.py
"""
import string
from CIME.XML.standard_module_setup import *
from CIME.XML.entry_id import EntryID
from CIME.XML.headers import Headers
Expand Down
1 change: 0 additions & 1 deletion scripts/lib/CIME/buildlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from CIME.case import Case
from CIME.utils import parse_args_and_handle_standard_logging_options, setup_standard_logging_options
import sys, os, argparse, doctest
import six
logger = logging.getLogger(__name__)

###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2434,8 +2434,8 @@ def _main_func():

try:
unittest.main(verbosity=2, catchbreak=True)
except SystemExit as had_fails:
if had_fails:
except SystemExit as e:
if e.__str__() != "False":
print("Detected failures, leaving directory:", TEST_ROOT)
else:
print("All pass, removing directory:", TEST_ROOT)
Expand Down

0 comments on commit 8e51ac3

Please sign in to comment.