Jpp  19.0.0
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 
82  git lfs pull --exclude= --include $INPUT_FILE
83 
84  if (( $? != 0 )); then
85  fatal "git lsf unavailable."
86  fi
87  fi
88  fi
89 
90  INPUT_FILE="$DIR/$INPUT_FILE"
91 fi
92 
93 popd
94 
95 if [[ ! -f $INPUT_FILE ]]; then
96  fatal "No corresponding file found in archive $DIR"
97 fi
98 
100 
101 if [[ -f $OUTPUT_FILE ]]; then
102  fatal "File $OUTPUT_FILE already exists."
103 fi
104 
105 cp -p $INPUT_FILE $OUTPUT_FILE
106 
107 if (( $? == 0 )); then
108  notice "Stored archive:$INPUT_FILE to $OUTPUT_FILE"
109 else
110  fatal "File $INPUT_FILE not retrieved from archive."
111 fi
112 
113 
&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:82
esac done BUFFER
Definition: JMakePDF.sh:83
is
Definition: JDAQCHSM.chsm:167
then
Definition: datalogs.sh:34
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
do grep(chi2\[.\]\|gradient\|string:\)" $INPUT_FILE > $WORKDIR/stage.txt awk 'BEGIN
&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 rm i $OUTPUT_FILE fi let RUN
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:89
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonStart.sh:47
then fatal The output file must have the wildcard in the e g root fi 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 JHobbit a $DETECTOR f
then cp
then eval ls $DIR $ID $TYPE _
Definition: getArchive.sh:108
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