/[CCFs]/bin/mlovccf
ViewVC logotype

Diff of /bin/mlovccf

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by ccflib, Wed Mar 23 15:36:37 2016 UTC revision 1.13 by ccflib, Fri Apr 1 12:22:28 2016 UTC
# Line 18  Line 18 
18  # This is obtained from the report of all observations that the XSA makes to CDS,  # This is obtained from the report of all observations that the XSA makes to CDS,
19  # xsaobslog.txt (http://nxsa.esac.esa.int/ftp_public/cfs_obslog/xsaobslog.txt).  # xsaobslog.txt (http://nxsa.esac.esa.int/ftp_public/cfs_obslog/xsaobslog.txt).
20  #  #
21  # $Id: mlovccf,v 1.11 2016/03/23 09:31:49 ccflib Exp $  # $Id: mlovccf,v 1.12 2016/03/23 15:36:37 ccflib Exp $
22    
23  # Next two lines allow to submit this script to the grid  # Next two lines allow to submit this script to the grid
24  # request Bourne shell as shell for job  # request Bourne shell as shell for job
25  #$ -S /bin/bash  #$ -S /bin/bash
26    
27    adminmail="eduardo.ojero@esa.int"
28    
29  VALID_CCF="$HOME/valid_ccf"  VALID_CCF="$HOME/valid_ccf"
30    
31    mailfile="${VALID_CCF}/mailfile"
32    
33  host=`hostname | cut -d. -f1`  host=`hostname | cut -d. -f1`
34    
35  now=`date +'%Y%m%d_%H%M'`  now=`date +'%Y%m%d_%H%M'`
36  now_table=`date +'%Y-%m-%dT%H:%M:%S'`  now_table=`date +'%Y-%m-%dT%H:%M:%S'`
37    
38    
39  # Function getxsaobslog  # +++ Function mailnotify
40    #
41    # This function is used to notify adminmail on any issue while runnning this procedure
42    #
43    # Needs a subject as $1 and body as local file to be send.
44    
45    mailnotify ()
46    {
47    
48    [ "$#" -ne "2" ] && return
49    
50    subject=$1
51    
52    bodyfile=$2
53    
54    [ ! -f "${bodyfile}" ] && return
55    
56    mailx -s "${subject}" "${adminuser}" < ${bodyfile}
57    
58    }
59    
60    
61    
62    # +++ Function getxsaobslog
63    #
64  # We need to get the list of all observed ODFs at the current date.  # We need to get the list of all observed ODFs at the current date.
65  # This is obtained from http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt.  # This is obtained from http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt.
66    
# Line 58  mv ${VALID_CCF}/xsaobslog.txt ${VALID_CC Line 85  mv ${VALID_CCF}/xsaobslog.txt ${VALID_CC
85  }  }
86    
87    
88  # Function find_latest_mif to get the latest XMM_CALINDEX from given directory  
89    # +++ Function find_latest_mif to get the latest XMM_CALINDEX from given directory
90    
91  find_latest_mif()  find_latest_mif()
92  {  {
# Line 79  MIF=${CCFPATH}/XMM_CALINDEX_${maxissue}. Line 107  MIF=${CCFPATH}/XMM_CALINDEX_${maxissue}.
107    
108  }  }
109    
110  # Function get_ccf_list to list on stdout the table of CCFs in a given CIF.  
111    
112    # +++Function get_ccf_list to list on stdout the table of CCFs in a given CIF.
113    #
114  # Requires that Heasoft is initialised. Otherwise exits with error.  # Requires that Heasoft is initialised. Otherwise exits with error.
115    
116  get_ccf_list()  get_ccf_list()
# Line 92  noversion=`which fversion | grep -c no` Line 123  noversion=`which fversion | grep -c no`
123    
124  if [ "${noversion}" != "0" ] ; then  if [ "${noversion}" != "0" ] ; then
125          echo "Error: Heasoft not initialised !"          echo "Error: Heasoft not initialised !"
126            [ -f "${mailfile}" ] && rm -rf ${mailfile}
127            echo "Running of fversion produced the following output:" >> $mailfile
128            echo "$noversion" >> $mailfile
129            mailnotify "mvloccf: Error: Heasoft not initialised!" $mailfile
130            rm ${mailfile}
131          exit          exit
132  fi  fi
133    
# Line 100  fdump ${cif_to_process} prhead=no showco Line 136  fdump ${cif_to_process} prhead=no showco
136                          rows=-  STDOUT                            rows=-  STDOUT  
137  }  }
138    
139  # Fill in the valid_constituents directory with the Valid CCF set  
140    
141    
142    # +++ Fill in the valid_constituents directory with the Valid CCF set
143    #
144    # The directory to be filled in is ${VALIDCONSTITUENTSDISR}.
145    # This directory is synchronized with the similar directory in the
146    # external ftp server.
147    #
148    # In addition to that, we also use this function to fill in the
149    # /ccf/valid directory available for users in the intranet.
150    
151  fillvalidccfdir()  fillvalidccfdir()
152  {  {
# Line 111  validccflist=$1 Line 157  validccflist=$1
157    
158  if [ ! -f "${VALID_CCF}/${validccflist}"  ] ; then  if [ ! -f "${VALID_CCF}/${validccflist}"  ] ; then
159          echo "Error: ${VALID_CCF}/${validccflist} not found - Abort!"          echo "Error: ${VALID_CCF}/${validccflist} not found - Abort!"
160            [ -f "${mailfile}" ] && rm -rf ${mailfile}
161            echo "The list of valid CCF ${VALID_CCF}/${validccflist} is not found" >> $mailfile
162            mailnotify "mvloccf: Error: ${VALID_CCF}/${validccflist} not found - Abort!" $mailfile
163            rm ${mailfile}
164          exit          exit
165  fi  fi
166    
167  VALIDCONSTITUENTSDIR="/home/ccflib/ftp-area/valid_constituents/"  VALIDCONSTITUENTSDIR="/home/ccflib/ftp-area/valid_constituents"
168  rm -rf ${VALIDCONSTITUENTSDIR}/*  rm -rf ${VALIDCONSTITUENTSDIR}/*
169    
170    VALIDCCFDIRINTRANET="/ccf/valid"
171    rm -rf ${VALIDCCFDIRINTRANET}/*
172    
173  CONSTITUENTSDIR="/home/ccflib/ftp-area/constituents"  CONSTITUENTSDIR="/home/ccflib/ftp-area/constituents"
174  n=0  n=0
175  while read ccf  while read ccf
# Line 124  do Line 177  do
177          n=$((n + 1))          n=$((n + 1))
178          echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/"          echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/"
179          cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/          cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/
180            echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCCFDIRINTRANET}/"
181            cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCCFDIRINTRANET}/
182  done < ${VALID_CCF}/${validccflist}  done < ${VALID_CCF}/${validccflist}
183    
184  }  }
185    
186    
187  # Get the list of all ODFs  #
188    #   M a i n    p r o g r a m
189    #
190    # 1. Get the list of all ODFs
191    
192    
193  xsaobslogsize="0"  xsaobslogsize="0"
194    
# Line 138  getxsaobslog Line 197  getxsaobslog
197  xsaobslogsize=`stat --format=%s ${VALID_CCF}/xsaobslog_${now}.txt`  xsaobslogsize=`stat --format=%s ${VALID_CCF}/xsaobslog_${now}.txt`
198    
199  if [ "$xsaobslogsize"  = "0" ] ; then  if [ "$xsaobslogsize"  = "0" ] ; then
200          echo "Error: Failure to download the XSA Obs. Log file - Abort"            echo "Error: Failure to download the XSA Obs. Log file - Abort"
201            [ -f "${mailfile}" ] && rm -rf ${mailfile}
202            echo "The XSA Obs. Log file has 0 size - Not downloaded?" >> $mailfile
203            echo "." >> $mailfile
204            mailnotify "mlovccf: Error: Failure to download the XSA Obs. Log file - Abort" "$mailfile"
205            rm ${mailfile}
206          exit          exit
207  fi  fi
208    
209  # Sets SAS_CCFPATH and initialises HEADAS and SAS depending on host  # 2. Sets SAS_CCFPATH and initialises HEADAS and SAS depending on host
210    
211  case "$host" in  case "$host" in
212          xvsoc01|xmm)          xvsoc01|xmm)
# Line 184  case "$host" in Line 248  case "$host" in
248          *) echo "Error: Do not know how to do it in host $host" ; exit ;;          *) echo "Error: Do not know how to do it in host $host" ; exit ;;
249  esac  esac
250    
251  # Finds the latest MIF issue  # 3. Finds the latest MIF issue
252    
253  find_latest_mif "${SAS_CCFPATH}"  find_latest_mif "${SAS_CCFPATH}"
254    
255    
256  # Now scans the list of OBDS ID registered in the previous list to get the start time  # 4. Scans the list of OBDS ID registered in the previous list to get the start time
257  # and then runs cifbuild to get the respective CIF  #    Then runs cifbuild to get the respective CIF.
258    #    all_ccfs_${now}.txt is filled recursively on each iteration. Therefore we start
259    #    with an empty file.
260    
261    #    Output file :          ${VALID_CCF}/all_ccfs_${now}.txt
262    
 # Output file  
263  touch ${VALID_CCF}/all_ccfs_${now}.txt  touch ${VALID_CCF}/all_ccfs_${now}.txt
264    
265  n=0  n=0
# Line 243  do Line 310  do
310    
311  done < ${VALID_CCF}/xsaobslog_${now}.txt  done < ${VALID_CCF}/xsaobslog_${now}.txt
312    
313  # Make a table of classes and issues type "Pipeline Release Notes"  # 5. Make a table of classes and issues with the style "Pipeline Release Notes"
314    #    To get a classification, we need first to obtain all available classes.
315    #
316    
317    
318  # Lists all CCF classes  # Lists all CCF classes
319    
# Line 258  done < ${VALID_CCF}/all_ccfs_${now}.txt Line 328  done < ${VALID_CCF}/all_ccfs_${now}.txt
328  cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt  cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt
329  mv ${VALID_CCF}/kk.txt ${ccf_classes}  mv ${VALID_CCF}/kk.txt ${ccf_classes}
330    
331    
332    
333  # Output final file is named all_ccfs_${now}_table.txt  # Output final file is named all_ccfs_${now}_table.txt
334    
335  total_number_of_ccfs=0  total_number_of_ccfs=0
# Line 326  echo "Total number of valid CCFs require Line 398  echo "Total number of valid CCFs require
398  rm ${VALID_CCF}/ccf_classes.txt  rm ${VALID_CCF}/ccf_classes.txt
399  rm ${VALID_CCF}/ccf_issues_for*.txt  rm ${VALID_CCF}/ccf_issues_for*.txt
400    
401  # Fill in the Valid CCF Set dir with the proper CCFs  
402    
403    # 6. Fill in the Valid CCF Set dir with the proper CCFs
404    
405  fillvalidccfdir "all_ccfs_${now}.txt"  fillvalidccfdir "all_ccfs_${now}.txt"
406    
407    [ -f "${mailfile}" ] && rm -rf ${mailfile}
408    echo "Valid CCF Set successfully copied to ${VALIDCONSTITUENTSDIR}" >> $mailfile
409    echo "Valid CCF Set successfully copied to ${VALIDCCFDIRINTRANET}"  >> $mailfile
410    mailnotify "mvloccf: Valid CCF Set created successfully" $mailfile
411    rm ${mailfile}

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.27