Updated Home (markdown)

Matt Martz 2018-01-03 09:13:52 -06:00
parent 460789997c
commit bd5bf8654c

45
Home.md

@ -14,7 +14,7 @@ s.get_servers(servers)
s.get_best_server()
s.download()
s.upload()
s.share()
s.results.share()
results_dict = s.results.dict()
```
@ -33,6 +33,18 @@ s.download()
```
### Bind source
#### v2.x
```
source = "192.168.1.100"
s = speedtest.Speedtest(source_address=source)
s.get_best_server()
s.download()
s.upload()
```
#### v1.x
```
source = "192.168.1.100"
speedtest.SOURCE = source
@ -41,33 +53,4 @@ s = speedtest.Speedtest()
s.get_best_server()
s.download()
s.upload()
```
### A zenity-powered bash script to display test results graphically
```
#!/bin/bash
notify_send_messages()
{
notify-send "www.SpeedTest.net:" "Retrieving speedtest.net configuration and server list..." -i network-modem -t 30
notify-send "www.SpeedTest.net:" "Selecting best server & calculating speeds..." -i network-modem -t 40
}
TMPFILE=`mktemp -t speedtest.XXXXXX`
notify_send_messages &
speedtest-cli 2>&1 > $TMPFILE
# Check if temp file is empty: if true there's something wrong with network
if [ -z "$TMPFILE" ]
then
zenity --class=Err --error --title="www.SpeedTest.net" --text="Network Error!"
else
# Determine ISP source server, best target server, ping, dowload and upload speeds
SOURCE=$(cat "$TMPFILE" | grep "Testing from " | sed -e "s/Testing from //g" -e "s/\.\.\.//g")
TARGET=$(cat "$TMPFILE" | grep "Hosted by " | sed -e "s/Hosted by //g" -e "s/: .\+$//g")
PING=$(cat "$TMPFILE" | grep "Hosted by " | awk -F ": " '{print $2}')
DOWNLD=$(cat "$TMPFILE" | grep "Download: " | sed -e "s/Download: //g")
UPLOAD=$(cat "$TMPFILE" | grep "Upload: " | sed -e "s/Upload: //g")
# Display information
zenity --class=SpeedTest --info --height 200 --title="www.SpeedTest.net" --text="\nSource: <b>$SOURCE</b>\n\nTarget: <b>$TARGET</b>\n\nPing: <b>$PING</b>\n\nDownload: <b>$DOWNLD</b>\n\nUpload: <b>$UPLOAD</b>"
# Remove temp file
rm -f $TMPFILE
fi
```
```