Jpp  18.5.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getFile.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 source ${0%${script}}ulib.sh
8 
9 set_variable: DEBUG ARCHIVE_DEBUG 2
11 
12 if do_usage $*; then
13  usage "$script <path> <detector identifier> <run> <type> [version] <output file>"\
14  "\nUtility script to retrieve file from archive."\
15  "\nNote that extension from name of file in archive is taken."
16 fi
17 
18 case $# in
20  5) set_variable DIR $argv[1];
21  let ID=" $argv[2]";
22  let RUN=" $argv[3]";
25  *) fatal "Wrong number of arguments."
26 esac
27 
28 if [[ ! -d $DIR ]]; then
29  fatal "Invalid path $argv[1]"
30 fi
31 
32 if (( $ID == 0 )); then
33  fatal "Invalid detector identifier $argv[2]"
34 fi
35 
36 if (( $RUN == 0 )); then
37  fatal "Invalid run $argv[3]"
38 fi
39 
40 setopt extendedglob
41 
42 typeset -Z8 ID
43 
44 let COUNTER="0"
45 INPUT_FILE=""
46 
47 if [[ ! -d $DIR ]]; then
48  fatal "No archive $DIR"
49 fi
50 
51 typeset -T BUFFER ARRAY /
52 
53 pushd $DIR
54 
55 eval ls -1 $ID/$TYPE/_${VERSION}/\*/\*/\* 2> /dev/null | while read BUFFER; do
56 
57  set_variable A_ID ${ARRAY[-6]}
58  set_variable A_TYPE ${ARRAY[-5]}
59  set_variable A_VERSION ${ARRAY[-4]#_}
60  let A_MINRUN=" ${ARRAY[-3]}"
61  let A_MAXRUN=" ${ARRAY[-2]}"
62  set_variable A_FILENAME ${ARRAY[-1]}
63 
64  let A_COUNTER="${A_FILENAME:r}"
65 
66  if (( $RUN >= $A_MINRUN && $RUN <= $A_MAXRUN )); then
67  if (( $A_COUNTER > $COUNTER )); then
68  let COUNTER="$A_COUNTER"
69  INPUT_FILE=$BUFFER
70  fi
71  fi
72 done
73 
74 if [[ -n $INPUT_FILE ]]; then
75 
76  if [[ $(git rev-parse --is-inside-work-tree) == "true" ]]; then
77 
78  git check-attr --all -- $INPUT_FILE | grep "filter: *lfs" >& /dev/null
79 
80  if (( $? == 0 )); then
81  git lfs pull --exclude= --include $INPUT_FILE
82  fi
83  fi
84 
85  INPUT_FILE="$DIR/$INPUT_FILE"
86 fi
87 
88 popd
89 
90 if [[ ! -f $INPUT_FILE ]]; then
91  fatal "No corresponding file found in archive $DIR"
92 fi
93 
94 OUTPUT_FILE+=.${INPUT_FILE:e}
95 
96 if [[ -f $OUTPUT_FILE ]]; then
97  fatal "File $OUTPUT_FILE already exists."
98 fi
99 
100 cp -p $INPUT_FILE $OUTPUT_FILE
101 
102 if (( $? == 0 )); then
103  notice "Stored archive:$INPUT_FILE to $OUTPUT_FILE"
104 else
105  fatal "File $INPUT_FILE not retrieved from archive."
106 fi
107 
108 
&set_variable TYPE
Definition: getLs.sh:22
then usage $script< detector identifier >< startdate\"YYYY-MM-DDHH:MM:SS\"><finaldate\"YYYY-MM-DDHH:MM:SS\"><QA/QCfile> fi case set_variable QAQC_TXT $argv[4]
Definition: JDataMonitor.sh:24
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
then git lfs pull exclude
Definition: getFile.sh:81
esac done BUFFER
Definition: JMakePDF.sh:83
o $QUALITY_ROOT d $DEBUG!CHECK_EXIT_CODE JPlot1D f
Definition: JDataQuality.sh:76
then fatal Wrong number of arguments fi set_variable ARCHIVE $argv[1] set_variable ID $argv[2] set_variable VERSION $argv[3] source JAcousticsToolkit sh RUN
is
Definition: JDAQCHSM.chsm:167
then
Definition: datalogs.sh:31
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DETECTOR_ID set_array RUNS if do_usage *then usage $script< source directory > nThe source directory corresponds to a pre calibrated D0ARCA009 detector fi case set_variable DIR
do set_variable A_ID
Definition: getFile.sh:57
boost::property_tree::ptree parse(std::string str)
Definition: configure.hh:24
const int n
Definition: JPolint.hh:786
&set_variable VERSION
Definition: getLs.sh:21
do set_variable OUTPUT_DIRECTORY $WORKDIR T
then fatal Invalid run $argv[3] fi setopt extendedglob typeset Z8 ID let COUNTER
Definition: getFile.sh:44
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
* usage
then JFileTuna f $INPUT_FILE
Definition: file-Tuna.sh:66
&set_variable OUTPUT_FILE
set_variable INPUT_FILE
then ls $DIR $ID
Definition: getArchive.sh:85
do grep(chi2\[.\]\|gradient\)" $INPUT_FILE > $WORKDIR/stage.txt awk 'BEGIN
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
then cp
then eval ls $DIR $ID $TYPE _
Definition: getArchive.sh:104
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
esac done
Definition: JAddHDE.sh:21
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62