mirror of https://github.com/ecmwf/eccodes.git
Set timeout to 15s. Also improve messages
This commit is contained in:
parent
cfef150e19
commit
4c3a0dcd5f
|
@ -3,9 +3,10 @@
|
||||||
usage ()
|
usage ()
|
||||||
{
|
{
|
||||||
prog=`basename $0`
|
prog=`basename $0`
|
||||||
echo "Usage: $prog [-v] data_dir"
|
echo "Usage: $prog [-v] [-c] data_dir"
|
||||||
echo
|
echo
|
||||||
echo "-v verbose"
|
echo "-v verbose"
|
||||||
|
echo "-c clean downloaded files"
|
||||||
echo "-h prints this help message"
|
echo "-h prints this help message"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
@ -62,21 +63,23 @@ fi
|
||||||
|
|
||||||
[ -d "${DATA_DIR}/tigge" ] || mkdir "${DATA_DIR}/tigge"
|
[ -d "${DATA_DIR}/tigge" ] || mkdir "${DATA_DIR}/tigge"
|
||||||
|
|
||||||
|
TIMEOUT_SECS=15
|
||||||
|
|
||||||
# Decide what tool to use to download data
|
# Decide what tool to use to download data
|
||||||
DNLD_PROG=""
|
DNLD_PROG=""
|
||||||
if command -v wget >/dev/null 2>&1; then
|
if command -v wget >/dev/null 2>&1; then
|
||||||
PROG=wget
|
PROG=wget
|
||||||
OPTIONS="--tries=1 --timeout=3 -nv -q -O"
|
OPTIONS="--tries=1 --timeout=$TIMEOUT_SECS -nv -q -O"
|
||||||
if [ $VERBOSE -eq 1 ]; then
|
if [ $VERBOSE -eq 1 ]; then
|
||||||
OPTIONS="--tries=1 --timeout=3 -nv -O"
|
OPTIONS="--tries=1 --timeout=$TIMEOUT_SECS -nv -O"
|
||||||
fi
|
fi
|
||||||
DNLD_PROG="$PROG $OPTIONS"
|
DNLD_PROG="$PROG $OPTIONS"
|
||||||
fi
|
fi
|
||||||
if command -v curl >/dev/null 2>&1; then
|
if command -v curl >/dev/null 2>&1; then
|
||||||
PROG=curl
|
PROG=curl
|
||||||
OPTIONS="--silent --show-error --fail --output"
|
OPTIONS="--connect-timeout $TIMEOUT_SECS --silent --show-error --fail --output"
|
||||||
if [ $VERBOSE -eq 1 ]; then
|
if [ $VERBOSE -eq 1 ]; then
|
||||||
OPTIONS="--show-error --fail --output"
|
OPTIONS="--connect-timeout $TIMEOUT_SECS --show-error --fail --output"
|
||||||
fi
|
fi
|
||||||
DNLD_PROG="$PROG $OPTIONS"
|
DNLD_PROG="$PROG $OPTIONS"
|
||||||
fi
|
fi
|
||||||
|
@ -87,13 +90,18 @@ fi
|
||||||
|
|
||||||
download_URL="http://download.ecmwf.org"
|
download_URL="http://download.ecmwf.org"
|
||||||
cd ${DATA_DIR}
|
cd ${DATA_DIR}
|
||||||
echo "Downloading data files for testing..."
|
echo "Checking data files for testing..."
|
||||||
|
downloading=0
|
||||||
for f in $files; do
|
for f in $files; do
|
||||||
# If we haven't already got the file, download it
|
# If we haven't already got the file, download it
|
||||||
if [ ! -f "$f" ]; then
|
if [ ! -f "$f" ]; then
|
||||||
if [ $VERBOSE -eq 1 ]; then
|
if [ $VERBOSE -eq 1 ]; then
|
||||||
echo "$DNLD_PROG $f ${download_URL}/test-data/grib_api/data/$f"
|
echo "$DNLD_PROG $f ${download_URL}/test-data/grib_api/data/$f"
|
||||||
fi
|
fi
|
||||||
|
if [ $downloading = 0 ]; then
|
||||||
|
echo "Downloading..."
|
||||||
|
downloading=1
|
||||||
|
fi
|
||||||
$DNLD_PROG $f ${download_URL}/test-data/grib_api/data/$f
|
$DNLD_PROG $f ${download_URL}/test-data/grib_api/data/$f
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo
|
echo
|
||||||
|
@ -110,4 +118,4 @@ done
|
||||||
|
|
||||||
# Add a file to indicate we've done the download
|
# Add a file to indicate we've done the download
|
||||||
touch .downloaded
|
touch .downloaded
|
||||||
echo "Downloads completed."
|
echo "Completed."
|
||||||
|
|
Loading…
Reference in New Issue