Skip to content

Commit

Permalink
Refactor send_frontend (#3)
Browse files Browse the repository at this point in the history
* Delete command for uploading data twice

* Retry 3 times

* Sleep between tries

* Fix method

* Fix logical error
  • Loading branch information
Nicolas Cornu authored and Marc-marc-marc committed Apr 30, 2021
1 parent ec9d626 commit 837a4c7
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 41 deletions.
4 changes: 2 additions & 2 deletions analyse-bano.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ echo " </analyser>
echo ""

echo "sending to osmose frontend"
curl -v --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}" && echo -e "\n\rcurl ok" || echo -e "\n\rcurl ko"
send_frontend $OUT

done

Expand Down Expand Up @@ -213,4 +213,4 @@ done
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyse-sirene.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ select format('<error class=\"99\" subclass=\"1\"><location lat=\"%s\" lon=\"%s\
echo " </analyser>
</analysers>" >> $OUT

curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT

4 changes: 1 addition & 3 deletions analyse_volta_lignes_RTE.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,5 @@ from (
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
sleep 30
curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
send_frontend $OUT

5 changes: 1 addition & 4 deletions analyse_volta_postes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,4 @@ done
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
sleep 30
curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"

send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-admin-express.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-cadastre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-missing-road.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-no-road-near-address.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ echo "
</analysers>" >> $OUT


curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-no-road-near-building.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ echo "
</analysers>" >> $OUT


curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-no-road-near-voirie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ echo "
</analysers>" >> $OUT

echo "Envoi"
curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-qa-missing-buildings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
4 changes: 2 additions & 2 deletions analyzer-qa-missing-highways.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ echo "
</analysers>" >> $OUT


curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT


echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
Expand All @@ -54,4 +54,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-qa-missing-route500.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-qa-route500-lanes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
2 changes: 1 addition & 1 deletion analyzer-road-name-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ echo "
</analyser>
</analysers>" >> $OUT

curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
7 changes: 1 addition & 6 deletions bdtopo/analyse_highway_bdtopo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,4 @@ done
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

#exit

curl --form source="opendata_xref-france" --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
sleep 30
curl --form source="opendata_xref-france" --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"

send_frontend $OUT
4 changes: 1 addition & 3 deletions bdtopo/analyse_highway_decale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,5 @@ done
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
sleep 30
curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
send_frontend $OUT

5 changes: 1 addition & 4 deletions bdtopo/analyse_highway_lanes_bdtopo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,4 @@ from (
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
sleep 30
curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"

send_frontend $OUT
6 changes: 1 addition & 5 deletions bdtopo/analyse_waterway_bdtopo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,4 @@ from (
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
sleep 300
curl --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"


send_frontend $OUT
2 changes: 1 addition & 1 deletion cadastre/analyse_voies_cadastre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ done
echo " </analyser>
</analysers>" | gzip -9 >> $OUT

curl -v --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}"
send_frontend $OUT
21 changes: 21 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,24 @@ else
fi

export URL_FRONTEND_UPDATE="https://osmose.openstreetmap.fr/control/send-update"

send_frontend() {
$OUT = $1
tries = 0

echo "Sending result"

until [ "$tries" -ge 3 ]; do
tries=$(( $tries + 1 ))
echo "Try: '$tries'"
curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT -H 'Host: osmose.openstreetmap.fr' "${URL_FRONTEND_UPDATE}" && break
sleep 300
done

if [ "$tries" -eq 4 ]; do
echo "Impossible to send results"
exit 1
done

return
}

0 comments on commit 837a4c7

Please sign in to comment.