Ignore:
Timestamp:
06/02/21 11:03:35 (3 years ago)
Author:
jderouillat
Message:

Update Python error management. Importing unit test from trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/xios_test_suite/TEST_SUITE/step2.py

    r1915 r2139  
    1818def OSinfo(runthis): 
    1919    red = lambda text: '\033[0;31m' + text + '\033[0m' 
    20     osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) 
    21     theInfo = osstdout.communicate()[0].strip() 
    22     if osstdout.returncode!=0: 
     20    osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) 
     21    theInfo, theErr = osstdout.communicate() 
     22    #print(theInfo) 
     23    if theErr: 
    2324        print(red(runthis+" FAILED")) 
    24         print(theInfo) 
     25        print(theErr) 
    2526        sys.exit() 
     27 
     28#def OSinfo(runthis): 
     29#    red = lambda text: '\033[0;31m' + text + '\033[0m' 
     30#    osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) 
     31#    theInfo = osstdout.communicate()[0].strip() 
     32#    if osstdout.returncode!=0: 
     33#        print(red(runthis+" FAILED")) 
     34#        print(theInfo) 
     35#        sys.exit() 
    2636 
    2737 
     
    7282                for checkfile in checkfiles: 
    7383                    if os.path.exists(config+"/"+checkfile) and os.path.exists("reference/ref_"+config+"/"+checkfile): 
    74                         OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"reference/ref_"+config+"/"+checkfile+" | > diff.txt") 
    75                         if os.stat("diff.txt").st_size==0: 
     84                        OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"reference/ref_"+config+"/"+checkfile+"  2>&1 |grep -v 'Found more than one time variable'|grep -v 'cdo diffn: Processed'|grep -v 'dimensional variables are not supported'|grep -v 'Time variable >time_counter< not found!' > diff_"+checkfile+".txt") 
     85                        if os.stat("diff_"+checkfile+".txt").st_size==0: # if no diff -> set 0 
    7686                            report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(1)+"\n") 
    77                     elif os.path.exists(config+"/"+checkfile): 
     87                        else: # if cdo diffn returns diff -> set -1 
     88                            report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(-1)+"\n") 
     89 
     90                    elif os.path.exists(config+"/"+checkfile): # if no ref file -> set 0 
    7891                        report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(0)+"\n") 
     92                    elif os.path.exists("reference/ref_"+config+"/"+checkfile): # if no output file -> set -2 
     93                        report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(-2)+"\n") 
     94 
    7995                    
    8096 
Note: See TracChangeset for help on using the changeset viewer.