4 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
6 set_variable WORKDIR ${TMPDIR:-/tmp}/
7 set_variable: DEBUG ARCHIVE_DEBUG 2
8 set_variable URL https://wiki.km3net.de/index.php/Calibration/Detectors
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."
17 3) set_variable VERSION $argv[3];
18 set_variable ARCHIVE $argv[2];&
19 1) set_variable DETID $argv[1];;
20 *) fatal "Wrong number of arguments."
23 set_variable WIKI_HTML $WORKDIR/wiki.html
24 set_variable WIKI_TXT $WORKDIR/wiki.txt
26 set_variable DETID `getDetector -D $DETID -O string`
29 # extract html page from wiki
31 if [[ ! -f $WIKI_HTML ]]; then
34 --no-check-certificate \
44 xmllint --html $WIKI_HTML |\
45 awk 'BEGIN { RS = "</tr>"; FS = "</td>" } \
47 if ($1 ~ "https://km3netdbweb.in2p3.fr/detx/") {
49 URL = gensub(".*href *= *\"([^\"]+)\".*", "\\1", "", $1)
50 DETECTOR = gensub(".*(KM3NeT_.*\\.detx|TBD).*", "\\1", "", $1)
51 RUNS = gensub("(<td>|,|<br>|\n)", " ", "g", $2)
53 print gensub("\\&", "\\&", "g", URL), DETECTOR, RUNS
60 while read __line__; do
63 echo $__line__ | read URL DETECTOR RUNS
67 notice "Processing $DETECTOR..."
69 if [[ "$DETECTOR" =~ "$DETID" ]]; then
71 if [[ ! -f $DETECTOR ]]; then
74 --no-check-certificate \
75 --load-cookies=$HOME/.km3netdb_cookie \
76 --secure-protocol=TLSv1_2 \
81 for RANGE in $RUNS[*]; do
86 if [[ "$RUN1" =~ "\.\." ]]; then; RUN1=1; fi
87 if [[ "$RUN2" =~ "\.\." ]]; then; RUN2=99999999; fi
90 debug "[${RUN1},${RUN2}]"
92 if [[ "$DETECTOR" =~ "\.detx$" || "$DETECTOR" =~ "\.datx$" ]]; then
94 if [[ "$ARCHIVE" != "" ]]; then
96 archive-put-Detector.sh \
114 rm -f $WIKI_HTML $WIKI_TXT