def testParser3(): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s', datefmt='%d%b%Y %H:%M:%S') p = Parser() portionlist = ["ncwa in.nc temp.nc", "ncwa temp.nc temp.nc", "ncwa temp.nc out.nc"] portion = "\n".join(portionlist) cf = CommandFactory(Config.dummyConfig()) p.parseScript(portion, cf)
def testParser2(): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s', datefmt='%d%b%Y %H:%M:%S') wholelist = open("full_resamp.swamp").readlines() test = [ "".join(wholelist[:10]), "".join(wholelist[:400]), "".join(wholelist), testScript4] p = Parser() cf = CommandFactory(Config.dummyConfig()) p.parseScript(test[1], cf)
def testParser(): test1 = """#!/usr/local/bin/bash # Analysis script for CAM/CLM output. #export CASEID1=camsomBC_1998d11 ncwa in.nc out.nc CASEID1=$1 DATA=nothing export ANLDIR=${DATA}/anl_${CASEID1} export STB_YR=00 export FRST_YR=0000 export LAST_YR=0014 export MDL=clm2 let Y1=$FRST_YR+1 let Y9=1 let Y9=1+1 mkdir -p ${ANLDIR} #inline comment mkdir -p ${DATA}/${CASEID1}/tmp # Move /tmp files into original directories (strictly precautionary): mv ${DATA}/${CASEID1}/tmp/* ${DATA}/${CASEID1}/ # Move data from year 0 out of the way mv ${DATA}/${CASEID1}/${CASEID1}.${MDL}.h0.${FRST_YR}-??.nc ${DATA}/${CASEID1}/tmp/ # STEP 1: Create ensemble annual and seasonal means # Bring in December of year 0 for seasonal mean mv ${DATA}/${CASEID1}/tmp/${CASEID1}.${MDL}.h0.${FRST_YR}-12.nc ${DATA}/${CASEID1}/ for yr in `seq $Y1 $LAST_YR`; do YY=`printf "%04d" ${yr}` let yrm=yr-1 YM=`printf "%04d" ${yrm}` ncrcat -O ${DATA}/${CASEID1}/${CASEID1}.${MDL}.h0.${YM}-12.nc ${DATA}/${CASEID1}/${CASEID1}.${MDL}.h0.${YY}-??.nc ${ANLDIR}/foo2.nc """ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s', datefmt='%d%b%Y %H:%M:%S') # filename='/tmp/myapp.log', # filemode='w') p = Parser() p.parseScript(test1, None)