Merge pull request #619 from akhepcat/v4.2-dev

Update wgd.sh - install pypi mirror can auto select by rtt after delay
This commit is contained in:
Donald Zou 2025-02-18 02:46:19 +08:00 committed by GitHub
commit 8e5cf14ebc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,8 @@ heavy_checkmark=$(printf "\xE2\x9C\x85")
heavy_crossmark=$(printf "\xE2\x9D\x8C") heavy_crossmark=$(printf "\xE2\x9D\x8C")
install=$(printf "\xF0\x9F\x92\xBF") install=$(printf "\xF0\x9F\x92\xBF")
msleep=15
PID_FILE=./gunicorn.pid PID_FILE=./gunicorn.pid
environment=$(if [[ $ENVIRONMENT ]]; then echo $ENVIRONMENT; else echo 'develop'; fi) environment=$(if [[ $ENVIRONMENT ]]; then echo $ENVIRONMENT; else echo 'develop'; fi)
if [[ $CONFIGURATION_PATH ]]; then if [[ $CONFIGURATION_PATH ]]; then
@ -275,16 +277,30 @@ _determinePypiMirror(){
rtt="9999" rtt="9999"
printf " [%i] [FAILED] %s\n" "$index" "$url" printf " [%i] [FAILED] %s\n" "$index" "$url"
else else
rtt=${rtt//.*/}
printf " [%i] %sms %s\n" "$index" "$rtt" "$url" printf " [%i] %sms %s\n" "$index" "$rtt" "$url"
fi fi
rtthost[$index]=$rtt
index=$((index+1)) index=$((index+1))
done done
printf "\n" for i in "${!rtthost[@]}"; do
printf " Which mirror you would like to use (Hit enter to use default): " [[ -z ${rtthost[i]} ]] && continue # Skip unset or empty values
read -r choice if [[ -z $min_val || ${rtthost[i]} -lt $min_val ]]; then
min_val=${rtthost[i]}
min_idx=$i
fi
done
min_idx=$((min_idx - 1))
printf "\n"
printf " Which mirror you would like to use (Hit enter or wait ${msleep} seconds to use default: ${urls[$min_idx]}): "
read -t ${msleep} -r choice
printf "\n"
if [[ -z "$choice" ]]; then
choice=${min_dix}
fi
if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#urls[@]} )); then if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#urls[@]} )); then
selected_url="${urls[choice-1]}" selected_url="${urls[choice-1]}"