Created
March 8, 2017 16:54
-
-
Save zokis/710c3c015e0832b1dc44e807baee54c6 to your computer and use it in GitHub Desktop.
Runs an internet speed test every 1 hour; Throws the result into a csv file named speedtest_result.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# pip install speedtest-cli | |
import subprocess | |
import time | |
def main(): | |
c = 0 | |
with open('speedtest_result.csv', 'w') as file: | |
process = subprocess.Popen(['speedtest', '--csv-header'], stdout=subprocess.PIPE) | |
out, err = process.communicate() | |
file.writelines([out]) | |
print 'Writing header' | |
try: | |
while True: | |
c += 1 | |
print 'Writing speed test %s' % c | |
process = subprocess.Popen(['speedtest', '--csv'], stdout=subprocess.PIPE) | |
out, err = process.communicate() | |
file.writelines([out]) | |
print 'Sleeping 1hr' | |
time.sleep(3600) | |
except KeyboardInterrupt: | |
exit(0) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment