Skip to content

Instantly share code, notes, and snippets.

@hrsano645
Created January 27, 2018 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrsano645/ec343d149a024e480c6585653179d959 to your computer and use it in GitHub Desktop.
Save hrsano645/ec343d149a024e480c6585653179d959 to your computer and use it in GitHub Desktop.
import subprocess
import datetime
from pprint import pprint
ROUTER = ""
NW = ""
RUN_COUNT = 2
speedtest_command = "speedtest-cli --server 15047".split(" ")
def main():
filetimestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
stdouts = list()
for i in range(1, RUN_COUNT+1):
stdouts.append("=====[{}/{} {}]=====\n".format(i, RUN_COUNT, filetimestamp))
# output = subprocess.check_output(speedtest_command, shell=False)
# stdouts.append(output)
output = subprocess.run(speedtest_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
stdouts.append(output.stdout.decode("utf-8"))
print("stdout =")
pprint(stdouts)
with open("nwtestresult_{}_{}.txt".format(ROUTER, NW), "w") as result_file:
result_file.writelines(stdouts)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment