Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
archive-put-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> <variant>]"\
12  "\nAuxiliary script to download official detectors from wiki and"\
13  "\noptionally store corresponding JSON files in given archive with given variant."
14 fi
15 
16 case $# in
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 if ! [[ "$DETID" =~ "^[0-9]*[0-9]$" ]]; then
27  set_variable DETID `getDetector -D $DETID`
28 fi
29 
30 typeset -Z 8 DETID
31 
32 # extract html page from wiki
33 
34 if [[ ! -f $WIKI_HTML ]]; then
35 
36  wget \
37  --no-check-certificate \
39  --ask-password \
40  -q \
41  -O $WIKI_HTML \
42  "$URL"
43 fi
44 
45 # parse html table
46 
47 xmllint --html $WIKI_HTML |\
48  awk 'BEGIN { RS = "</tr>"; FS = "</td>" } \
49  { \
50  if ($1 ~ "https://km3netdbweb.in2p3.fr/detx/") {
51 
52  URL = gensub(".*href *= *\"([^\"]+)\".*", "\\1", "", $1)
53  DETECTOR = gensub(".*(KM3NeT_.*\\.detx|TBD).*", "\\1", "", $1)
54  RUNS = gensub("(<td>|,|<br>|\n)", " ", "g", $2)
55 
56  print gensub("\\&amp;", "\\&", "g", URL), DETECTOR, RUNS
57  }
58  }' > $WIKI_TXT
59 
60 
61 # process data
62 
63 while read __line__; do
64 
65  debug $__line__
66  echo $__line__ | read URL DETECTOR RUNS
67 
69 
70  notice "Processing $DETECTOR..."
71 
72  if [[ "$DETECTOR" =~ "$DETID" ]]; then
73 
74  if [[ ! -f $DETECTOR ]]; then
75 
76  wget \
77  --no-check-certificate \
78  --load-cookies=$HOME/.km3netdb_cookie \
79  --secure-protocol=TLSv1_2 \
80  -O $DETECTOR \
81  "$URL"
82  fi
83 
84  for RANGE in $RUNS[*]; do
85 
86  RUN1=${RANGE%%-*}
87  RUN2=${RANGE##*-}
88 
89  if [[ "$RUN1" =~ "\.\." ]]; then; RUN1=1; fi
90  if [[ "$RUN2" =~ "\.\." ]]; then; RUN2=99999999; fi
91 
92  debug "$URL"
93  debug "[${RUN1},${RUN2}]"
94 
95  if [[ "$DETECTOR" =~ "\.detx$" || "$DETECTOR" =~ "\.datx$" ]]; then
96 
97  if [[ "$ARCHIVE" != "" ]]; then
98 
99  archive-put-Detector.sh \ $ARCHIVE \ $VARIANT \ $DETECTOR \
100  ${RUN1} ${RUN2}
101  else
102 
103  JDestructDetector \
104  -a $DETECTOR \
105  -o $WORKDIR/%.txt
106  fi
107 
108  CHECK_EXIT_CODE
109  fi
110  done
111  fi
112 done < $WIKI_TXT
113 
114 rm -f $WIKI_HTML $WIKI_TXT
115 
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.
rm f XXX txt echo nlist all archive files that do have specific variants getArchive sh $ARCHIVE test km3net(mjg_2|mjg_1)" getFile.sh $ARCHIVE/test 100 101 km3net "(mjg_2|mjg_1)" XXX
o $QUALITY_ROOT d $DEBUG!JPlot1D f
Definition: JDataQuality.sh:66
then wget no check certificate user
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
then echo
boost::property_tree::ptree parse(std::string str)
Definition: configure.hh:24
then set_variable DETID
Definition: JEditTuneHV.sh:63
then wget no check certificate load cookies
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
do debug $__line__ echo $__line__ read URL DETECTOR RUNS RUNS
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
source $JPP_DIR setenv sh $JPP_DIR ARCHIVE
Definition: archive.sh:5
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
then JCalibrateToT a
Definition: JTuneHV.sh:116
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 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
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
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
&set_variable VARIANT
Definition: JDetector.sh:30