From afac8af7dbcdaa2879d534e8ba528822a27d60e2 Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Fri, 30 Apr 2021 23:14:33 +0200 Subject: [PATCH] Delete command for uploading data twice (#3) * Delete command for uploading data twice * Retry 3 times * Sleep between tries * Fix method * Fix logical error --- analyse-bano.sh | 4 ++-- analyse-sirene.sh | 2 +- analyse_volta_lignes_RTE.sh | 4 +--- analyse_volta_postes.sh | 5 +---- analyzer-admin-express.sh | 2 +- analyzer-cadastre.sh | 2 +- analyzer-missing-road.sh | 2 +- analyzer-no-road-near-address.sh | 2 +- analyzer-no-road-near-building.sh | 2 +- analyzer-no-road-near-voirie.sh | 2 +- analyzer-qa-missing-buildings.sh | 2 +- analyzer-qa-missing-highways.sh | 4 ++-- analyzer-qa-missing-route500.sh | 2 +- analyzer-qa-route500-lanes.sh | 2 +- analyzer-road-name-ref.sh | 2 +- bdtopo/analyse_highway_bdtopo.sh | 5 +---- bdtopo/analyse_highway_decale.sh | 4 +--- bdtopo/analyse_highway_lanes_bdtopo.sh | 5 +---- bdtopo/analyse_waterway_bdtopo.sh | 6 +----- cadastre/analyse_voies_cadastre.sh | 2 +- config.sh | 21 +++++++++++++++++++++ 21 files changed, 43 insertions(+), 39 deletions(-) diff --git a/analyse-bano.sh b/analyse-bano.sh index 4408a8e..ab3c3ab 100755 --- a/analyse-bano.sh +++ b/analyse-bano.sh @@ -127,7 +127,7 @@ echo " 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 @@ -213,4 +213,4 @@ done echo " " | 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 diff --git a/analyse-sirene.sh b/analyse-sirene.sh index 96540fc..af0b6ae 100755 --- a/analyse-sirene.sh +++ b/analyse-sirene.sh @@ -24,5 +24,5 @@ select format(' " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyse_volta_lignes_RTE.sh b/analyse_volta_lignes_RTE.sh index 550f955..cb5b402 100755 --- a/analyse_volta_lignes_RTE.sh +++ b/analyse_volta_lignes_RTE.sh @@ -46,7 +46,5 @@ from ( echo " " | 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 diff --git a/analyse_volta_postes.sh b/analyse_volta_postes.sh index a49c1a0..696858c 100755 --- a/analyse_volta_postes.sh +++ b/analyse_volta_postes.sh @@ -81,7 +81,4 @@ done echo " " | 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 diff --git a/analyzer-admin-express.sh b/analyzer-admin-express.sh index d0ffff2..621121a 100755 --- a/analyzer-admin-express.sh +++ b/analyzer-admin-express.sh @@ -30,4 +30,4 @@ echo " " >> $OUT -curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-cadastre.sh b/analyzer-cadastre.sh index 249e0cd..097c3e9 100755 --- a/analyzer-cadastre.sh +++ b/analyzer-cadastre.sh @@ -51,4 +51,4 @@ echo " " >> $OUT -curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-missing-road.sh b/analyzer-missing-road.sh index 6d1b59a..740e560 100755 --- a/analyzer-missing-road.sh +++ b/analyzer-missing-road.sh @@ -33,4 +33,4 @@ echo " " >> $OUT -curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-no-road-near-address.sh b/analyzer-no-road-near-address.sh index c228ab7..cba02e9 100755 --- a/analyzer-no-road-near-address.sh +++ b/analyzer-no-road-near-address.sh @@ -38,4 +38,4 @@ echo " " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-no-road-near-building.sh b/analyzer-no-road-near-building.sh index 8288e87..895168d 100755 --- a/analyzer-no-road-near-building.sh +++ b/analyzer-no-road-near-building.sh @@ -39,4 +39,4 @@ echo " " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-no-road-near-voirie.sh b/analyzer-no-road-near-voirie.sh index 528e5cd..7f458d5 100755 --- a/analyzer-no-road-near-voirie.sh +++ b/analyzer-no-road-near-voirie.sh @@ -40,4 +40,4 @@ echo " " >> $OUT echo "Envoi" -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-qa-missing-buildings.sh b/analyzer-qa-missing-buildings.sh index b9fd0db..12eac7b 100755 --- a/analyzer-qa-missing-buildings.sh +++ b/analyzer-qa-missing-buildings.sh @@ -46,4 +46,4 @@ echo " " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-qa-missing-highways.sh b/analyzer-qa-missing-highways.sh index efd703f..69ac09e 100755 --- a/analyzer-qa-missing-highways.sh +++ b/analyzer-qa-missing-highways.sh @@ -28,7 +28,7 @@ echo " " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT echo " @@ -54,4 +54,4 @@ echo " " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-qa-missing-route500.sh b/analyzer-qa-missing-route500.sh index b25cdee..5ff5c62 100755 --- a/analyzer-qa-missing-route500.sh +++ b/analyzer-qa-missing-route500.sh @@ -35,4 +35,4 @@ echo " " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-qa-route500-lanes.sh b/analyzer-qa-route500-lanes.sh index c83aef2..e786d84 100755 --- a/analyzer-qa-route500-lanes.sh +++ b/analyzer-qa-route500-lanes.sh @@ -30,4 +30,4 @@ echo " " >> $OUT -curl -s --request POST --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/analyzer-road-name-ref.sh b/analyzer-road-name-ref.sh index 05dcf9e..d7225c5 100755 --- a/analyzer-road-name-ref.sh +++ b/analyzer-road-name-ref.sh @@ -31,4 +31,4 @@ echo " " >> $OUT -curl -s --request POST --compressed --form source='opendata_xref-france' --form code="$OSMOSEPASS" --form content=@$OUT "${URL_FRONTEND_UPDATE}" +send_frontend $OUT diff --git a/bdtopo/analyse_highway_bdtopo.sh b/bdtopo/analyse_highway_bdtopo.sh index d40912a..366a26a 100755 --- a/bdtopo/analyse_highway_bdtopo.sh +++ b/bdtopo/analyse_highway_bdtopo.sh @@ -56,7 +56,4 @@ done echo " " | 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 diff --git a/bdtopo/analyse_highway_decale.sh b/bdtopo/analyse_highway_decale.sh index a68211c..f105688 100755 --- a/bdtopo/analyse_highway_decale.sh +++ b/bdtopo/analyse_highway_decale.sh @@ -66,7 +66,5 @@ done echo " " | 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 diff --git a/bdtopo/analyse_highway_lanes_bdtopo.sh b/bdtopo/analyse_highway_lanes_bdtopo.sh index e0d8a90..78082ac 100755 --- a/bdtopo/analyse_highway_lanes_bdtopo.sh +++ b/bdtopo/analyse_highway_lanes_bdtopo.sh @@ -49,7 +49,4 @@ from ( echo " " | 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 diff --git a/bdtopo/analyse_waterway_bdtopo.sh b/bdtopo/analyse_waterway_bdtopo.sh index b187d62..4186757 100755 --- a/bdtopo/analyse_waterway_bdtopo.sh +++ b/bdtopo/analyse_waterway_bdtopo.sh @@ -46,8 +46,4 @@ from ( echo " " | 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 diff --git a/cadastre/analyse_voies_cadastre.sh b/cadastre/analyse_voies_cadastre.sh index 191092c..c0f4b8b 100755 --- a/cadastre/analyse_voies_cadastre.sh +++ b/cadastre/analyse_voies_cadastre.sh @@ -54,4 +54,4 @@ done echo " " | 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 diff --git a/config.sh b/config.sh index b37584f..437570d 100755 --- a/config.sh +++ b/config.sh @@ -11,3 +11,24 @@ else fi export URL_FRONTEND_UPDATE="http://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 +}