Showing 1 changed files with 7 additions and 7 deletions
+7 -7
analyse-votes-AN
... ...
@@ -136,16 +136,17 @@ function update_database () {
136 136
                 done
137 137
             done
138 138
 
139
-            if test $(( ($scrutin - $first) * 100 / ( $last - $first ) )) -ne $progress; then
140
-                progress=$(( ($scrutin - $first) * 100 / ( $last - $first ) ))
139
+            if test $(( ($scrutin - ${first:-0}) * 100 / ( $last - ${first:-0} ) )) -ne ${progress:-0}; then
140
+                progress=$(( ($scrutin - ${first:-0}) * 100 / ( $last - ${first:-0} ) ))
141 141
                 if test $(($progress % ${update_progress:-1})) -eq 0; then
142 142
                     now=$(date +%s)
143 143
                     delta=$(( $now - $begin ))
144
-#                   scrutin = first+1 à la première itération
145
-                    echo $progress%, ETA: $(date +%H:%M:%S -d "$(($delta * ($last - $scrutin) / ($scrutin - $first) )) seconds")
144
+#                   scrutin = {first:-0}+1 à la première itération
145
+                    printf "\r%d%%, ETA %s" $progress $(date +%H:%M:%S -d "$(($delta * ($last - $scrutin) / ($scrutin - ${first:-0}) )) seconds")
146 146
                 fi
147 147
             fi
148 148
         done
149
+        echo -e "\r\033[KTerminé: $(($scrutin - ${first:-0} - 1)) scrutins ajoutés"
149 150
         rm -f "$url_database" "$tempfile"
150 151
     fi
151 152
     first=$first_
... ...
@@ -350,14 +351,13 @@ EOcontent
350 351
             if test $(( $progress % ${generation_progress:-5} )) -eq 0; then
351 352
                 now=$(date +%s)
352 353
                 delta=$(( $now - $begin ))
353
-                echo $progress%, ETA: $(date +%H:%M:%S -d "$(( $delta * (${qty:-$last} - $line) / $line )) seconds")
354
+                printf "\r%d%%, ETA %s" $progress $(date +%H:%M:%S -d "$(( $delta * (${qty:-$last} - $line) / $line )) seconds")
354 355
             fi
355 356
         fi
356 357
 
357 358
         let line++
358 359
 
359 360
     done
360
-    echo
361 361
 
362 362
     cat >> "$content" << EOcontent
363 363
     </table:table>
... ...
@@ -374,7 +374,7 @@ EOcontent
374 374
 
375 375
     mv -f "/dev/shm/$result.zip" "$result.ods"
376 376
 
377
-    echo "$result.ods"
377
+    echo -e "\r\033[KTerminé : $result.ods"
378 378
 }
379 379
 
380 380
 function save_database () {