Hallo Morone,
OK, dann warte ich einfach mal ab
Weis jemand ob die XML files schon beim dowload kaputt sind ?
Ich habe mir einfach gedacht das man das ja vermeiden könnte wenn
A. auf konsitenz überprüft wird nach dem download
B oder man sie zwei mal runterlädt und dann vergleicht - falls sie sich unterschieden dann noch mal das ganze. Darüber hinaus ist es sicherlich sinnvoll zu checken ob es überhaupt eine XML datei ist Wenn die site offline ist dann bekommt man doch bestimmt eine HTML siete o.ä. zurück.
Habe auf die schnelel kein XML prüfung gefunden, habe also erstmal lösung B realisiert. Wenn der download nicht erfolgreich ist (5 vesuche pro datei) dann bleibt die vorherige datei da.
Bitte die drei letzten wget's :
wget -t 4 -T 20 "http://xoap.weather.com/weather/local/$ID1?cc=*&unit=m&dayf=10&
prod=xoap&par=1004124588&key=$KEY" -O "$SETUPDIR/plugins/weatherng/data1.xml"
wget -t 4 -T 20 "http://xoap.weather.com/weather/local/$ID2?cc=*&unit=m&dayf=10&
prod=xoap&par=1004124588&key=$KEY" -O "$SETUPDIR/plugins/weatherng/data2.xml"
wget -t 4 -T 20 "http://xoap.weather.com/weather/local/$ID3?cc=*&unit=m&dayf=10&
prod=xoap&par=1004124588&key=$KEY" -O "$SETUPDIR/plugins/weatherng/data3.xml"
ersetzen duch dies :
function DownloadWeaterXML() {
# Param 1 : StationID
# 2 : Filename
wget -t 4 -T 20 "http://xoap.weather.com/weather/local/${1}?cc=*&unit=m&dayf=10&prod=xoap&par=1004124588&key=$KEY" -O "${2}"
}
function DownloadAndCheckXML() {
# Param 1 : StationID
# 2 : Filename
XMLOK=false
let LoopCnt=0
while [ $XMLOK = false -a $LoopCnt -lt 5 ]; do
DownloadWeaterXML $1 "${2}-a"
DownloadWeaterXML $1 "${2}-b"
diff "${2}-a" "${2}-b" >/dev/null 2>&1
STATUS=$?
grep -q "^<?xml" "${2}-a"
if [ $? -eq 0 -a $STATUS -eq 0 ]; then
# XML file should be OK
mv -vf "${2}-a" "${2}"
printf "\nDownload $1 to ${2##*/} OK.\n"
XMLOK=true
else
printf "\nERROR: $1 ${LoopCnt}. try - The two XML files differ, retrying download.\n"
fi
let LoopCnt++
done
# Cleanup
[ -e "${2}-a" ] && rm -f "${2}-a"
[ -e "${2}-b" ] && rm -f "${2}-b"
[ $XMLOK = true ] && return 0 || return 1
}
DownloadAndCheckXML $ID1 "$SETUPDIR/plugins/weatherng/data1.xml"
STATUS1=$?
DownloadAndCheckXML $ID2 "$SETUPDIR/plugins/weatherng/data2.xml"
STATUS2=$?
DownloadAndCheckXML $ID3 "$SETUPDIR/plugins/weatherng/data3.xml"
STATUS3=$?
[ $STATUS1 -ne 0 -o $STATUS2 -ne 0 -o $STATUS3 -ne 0 ] && MESG=$MESGERR
echo $MESG
Alles anzeigen
Wie ist das eigentlich mit dem $MESG - wird die vom Plugin ausgegeben ? Habe es bewusst bisher nicht wahrgenommen !?
Wenn ja dann oben im CASE eine MESGERR hinzufügen :
So wie dies :
1) MESG='Download abgeschlossen und Radarmaps aktualisiert'
MESGERR='Download der Radarmaps nicht erfolgreich'
Gruß
Viking