Update README.rst

This commit is contained in:
Gamerhythm 2017-02-25 17:57:06 +00:00 committed by GitHub
parent 068d71597b
commit 1f8583c426
1 changed files with 12 additions and 0 deletions

View File

@ -71,6 +71,18 @@ or
Usage
-----
You can use in another script via the following:
::
DownloadParsed = re.compile(r"Download: ([\d.]+) .bit")
UploadParsed = re.compile(r"Upload: ([\d.]+) .bit")
PingParsed = re.compile(r"([\d.]+) ms")
speedtest_result = str(subprocess.check_output(['speedtest-cli'], stderr=subprocess.STDOUT))
download = DownloadParsed.search(speedtest_result).group(1)
upload = UploadParsed.search(speedtest_result).group(1)
ping = PingParsed.search(speedtest_result).group(1)
print("Download Speed: " + download + " mbps\n" + "Upload Speed: " + upload + " mbps\n" + "Ping: " + ping + " ms")
::
$ speedtest-cli -h