diff --git a/scripts/lib/CIME/SystemTests/system_tests_common.py b/scripts/lib/CIME/SystemTests/system_tests_common.py index 7f849c06c7b..c8846c29215 100644 --- a/scripts/lib/CIME/SystemTests/system_tests_common.py +++ b/scripts/lib/CIME/SystemTests/system_tests_common.py @@ -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) @@ -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. @@ -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 diff --git a/scripts/lib/CIME/XML/env_base.py b/scripts/lib/CIME/XML/env_base.py index e5fa2e33830..3acfb36a3cd 100644 --- a/scripts/lib/CIME/XML/env_base.py +++ b/scripts/lib/CIME/XML/env_base.py @@ -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 diff --git a/scripts/lib/CIME/buildlib.py b/scripts/lib/CIME/buildlib.py index a2f97fc6a93..551f6325d75 100644 --- a/scripts/lib/CIME/buildlib.py +++ b/scripts/lib/CIME/buildlib.py @@ -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__) ############################################################################### diff --git a/scripts/tests/scripts_regression_tests.py b/scripts/tests/scripts_regression_tests.py index de746573829..760a18774b7 100755 --- a/scripts/tests/scripts_regression_tests.py +++ b/scripts/tests/scripts_regression_tests.py @@ -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)