Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
archive-put-wiki-detectors.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
5 
7 set_variable: DEBUG ARCHIVE_DEBUG 2
8 set_variable URL https://wiki.km3net.de/index.php/Calibration/Detectors
9 
10 if do_usage $*; then
11  usage "$script <detector identifier> [<archive> <version>]"\
12  "\nAuxiliary script to download official detectors from wiki."\
13  "\nOptionally, the corresponding JSON files are stored in the archive with given version."
14 fi
15 
16 case $# in
18  set_variable ARCHIVE $argv[2];&
20  *) fatal "Wrong number of arguments."
21 esac
22 
23 set_variable WIKI_HTML $WORKDIR/wiki.html
24 set_variable WIKI_TXT $WORKDIR/wiki.txt
25 
26 set_variable DETID `getDetector -D $DETID -O string`
27 typeset -Z 8 DETID
28 
29 # extract html page from wiki
30 
31 if [[ ! -f $WIKI_HTML ]]; then
32 
33  wget \
34  --no-check-certificate \
35  --user=km3net \
36  --ask-password \
37  -q \
38  -O $WIKI_HTML \
39  "$URL"
40 fi
41 
42 # parse html table
43 
44 xmllint --html $WIKI_HTML |\
45  awk 'BEGIN { RS = "</tr>"; FS = "</td>" } \
46  { \
47  if ($1 ~ "https://km3netdbweb.in2p3.fr/detx/") {
48 
49  URL = gensub(".*href *= *\"([^\"]+)\".*", "\\1", "", $1)
50  DETECTOR = gensub(".*(KM3NeT_.*\\.detx|TBD).*", "\\1", "", $1)
51  RUNS = gensub("(<td>|,|<br>|\n)", " ", "g", $2)
52 
53  print gensub("\\&amp;", "\\&", "g", URL), DETECTOR, RUNS
54  }
55  }' > $WIKI_TXT
56 
57 
58 # process data
59 
60 while read __line__; do
61 
62  debug $__line__
63  echo $__line__ | read URL DETECTOR RUNS
64 
66 
67  notice "Processing $DETECTOR..."
68 
69  if [[ "$DETECTOR" =~ "$DETID" ]]; then
70 
71  if [[ ! -f $DETECTOR ]]; then
72 
73  wget \
74  --no-check-certificate \
75  --load-cookies=$HOME/.km3netdb_cookie \
76  --secure-protocol=TLSv1_2 \
77  -O $DETECTOR \
78  "$URL"
79  fi
80 
81  for RANGE in $RUNS[*]; do
82 
83  RUN1=${RANGE%%-*}
84  RUN2=${RANGE##*-}
85 
86  if [[ "$RUN1" =~ "\.\." ]]; then; RUN1=1; fi
87  if [[ "$RUN2" =~ "\.\." ]]; then; RUN2=99999999; fi
88 
89  debug "$URL"
90  debug "[${RUN1},${RUN2}]"
91 
92  if [[ "$DETECTOR" =~ "\.detx$" || "$DETECTOR" =~ "\.datx$" ]]; then
93 
94  if [[ "$ARCHIVE" != "" ]]; then
95 
96  archive-put-Detector.sh \ $ARCHIVE \ $VERSION \ $DETECTOR \
97  ${RUN1} ${RUN2}
98  else
99 
100  JDestructDetector \
101  -a $DETECTOR \
102  -o $WORKDIR/%.txt
103  fi
104 
105  CHECK_EXIT_CODE
106  fi
107  done
108  fi
109 done < $WIKI_TXT
110 
111 rm -f $WIKI_HTML $WIKI_TXT
112 
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
set_array RUNS
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
then wget no check certificate user
o $QUALITY_ROOT d $DEBUG!CHECK_EXIT_CODE JPlot1D f
Definition: JDataQuality.sh:76
usr share Modules init zsh export TMPDIR
then fatal Wrong number of arguments fi JConvertDetectorFormat a o
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
boost::property_tree::ptree parse(std::string str)
Definition: configure.hh:24
then fatal Invalid path $argv[1] fi setopt extendedglob typeset Z8 ID function archive()
Definition: getArchive.sh:42
then set_variable DETID
Definition: JEditTuneHV.sh:63
then rm
Definition: sftpput.zsh:30
then fatal Detector file should be binary format fi eval JPrintDetector a $DETECTOR O IDENTIFIER typeset a INPUT_FILES for RANGE in $RUNS[*]
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
Definition: JAcoustics.sh:21
do set_variable STRING_TXT awk
then JCalibrateToT a
Definition: JTuneHV.sh:116
#define VERSION
Definition: elog-version.h:27
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DEBUG set_variable WORKDIR
Definition: JLegolas.sh:20
* usage
then fatal Timeout at user input fi set_variable SERVER JServerDB wget no check certificate q https
Definition: JCookie.sh:58
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
then set_variable MODULE getModule a $DETECTOR L $STRING $FLOOR JEditDetector a $DETECTOR M $MODULE add $X o $DETECTOR else echo No update of detector $DETECTOR
then display $WORKDIR
Definition: plot-Domino.sh:128
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
set_variable DETECTOR
then echo
Definition: JQAQC.sh:90
static JNullStream null
Null I/O stream.
Definition: JNullStream.hh:51
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:46
script
Definition: JAcoustics.sh:2
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
then wget no check certificate load cookies
int debug
debug level
then fatal Invalid detector identifier $DETECTOR_ID fi set_variable RUNSETUPID typeset a RANGE RANGE[1]
then echo Monitoring data echo Detector
Definition: JSlewingK40.sh:97
esac done
Definition: JAddHDE.sh:21
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62