Changeset 20411


Ignore:
Timestamp:
03/31/16 14:18:06 (9 years ago)
Author:
Mathieu Morlighem
Message:

CHG: print error messages in python

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/runme.py

    r20182 r20411  
    1 #! /usr/bin/env python
     1#!/usr/bin/env python
    22import os
    33import glob
     
    66import netCDF4
    77import sys
     8import traceback
    89
    910def runme(id=None,exclude=None,benchmark='nightly',procedure='check',output='none',rank=1,numprocs=1):
     
    6364        # }}}
    6465        #GET output {{{
    65         if not ismember(output,['nightly','daily','none']):
     66        if not ismember(output,['nightly','none']):
    6667                print "runme warning: output '%s' not supported, defaulting to test 'none'." % output
    6768                output='none'
     
    199200                                                                (error_diff,tolerance,id,id_string,fieldname)
    200201
    201                                         except Exception as me2:
     202                                        except Exception as message:
    202203
    203204                                                #something went wrong, print failure message:
     205                                                print traceback.format_exc()
    204206                                                directory=os.getcwd().split('/')    #  not used?
    205                                                 message=me2
    206207                                                if   strcmpi(output,'nightly'):
    207208                                                        fid=open(os.path.join(ISSM_DIR,'nightlylog','pythonerror.log'), 'a')
     
    210211                                                        fid.close()
    211212                                                        print 'FAILURE difference: N/A test id: %i test name: %s field: %s' % (id,id_string,fieldname)
    212                                                 elif strcmpi(output,'daily'):
    213                                                         fid=open(os.path.join(ISSM_DIR,'dailylog','pythonerror.log'), 'a')
    214                                                         fid.write('%s' % message)
    215                                                         fid.write('\n------------------------------------------------------------------\n')
    216                                                         fid.close()
    217                                                         print 'FAILURE difference: N/A test id: %i test name: %s field: %s' % (id,id_string,fieldname)
    218213                                                else:
    219214                                                        print 'FAILURE difference: N/A test id: %i test name: %s field: %s' % (id,id_string,fieldname)
     
    222217                                f.close()
    223218
    224                 except Exception as me:
     219                except Exception as message:
    225220
    226221                        #something went wrong, print failure message:
     222                        print traceback.format_exc()
    227223                        directory=os.getcwd().split('/')    #  not used?
    228                         message=me
    229224                        if   strcmpi(output,'nightly'):
    230225                                fid=open(os.path.join(ISSM_DIR,'nightlylog','pythonerror.log'), 'a')
    231                                 fid.write('%s' % message)
    232                                 fid.write('\n------------------------------------------------------------------\n')
    233                                 fid.close()
    234                                 print 'FAILURE difference: N/A test id: %i test name: %s field: %s' % (id,id_string,'N/A')
    235                         elif strcmpi(output,'daily'):
    236                                 fid=open(os.path.join(ISSM_DIR,'dailylog','pythonerror.log'), 'a')
    237226                                fid.write('%s' % message)
    238227                                fid.write('\n------------------------------------------------------------------\n')
Note: See TracChangeset for help on using the changeset viewer.