update with new save to csv
This commit is contained in:
parent
90731dab5d
commit
8d63cf52e4
|
|
@ -25,6 +25,16 @@
|
||||||
// }
|
// }
|
||||||
// "cwd": "${workspaceFolder}",
|
// "cwd": "${workspaceFolder}",
|
||||||
"justMyCode": false
|
"justMyCode": false
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Python: list",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/speedtest.py",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"args": ["--list"],
|
||||||
|
"justMyCode": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
1
setup.py
1
setup.py
|
|
@ -95,5 +95,6 @@ setup(
|
||||||
'Programming Language :: Python :: 3.8',
|
'Programming Language :: Python :: 3.8',
|
||||||
'Programming Language :: Python :: 3.9',
|
'Programming Language :: Python :: 3.9',
|
||||||
'Programming Language :: Python :: 3.10',
|
'Programming Language :: Python :: 3.10',
|
||||||
|
'Programming Language :: Python :: 3.11',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
58
speedtest.py
58
speedtest.py
|
|
@ -1943,40 +1943,36 @@ def shell():
|
||||||
speedtest.get_best_server(speedtest.set_mini_server(args.mini))
|
speedtest.get_best_server(speedtest.set_mini_server(args.mini))
|
||||||
|
|
||||||
results = speedtest.results
|
results = speedtest.results
|
||||||
# print(dict(str(results)))
|
|
||||||
# os.makedirs('tmp', exist_ok=True)
|
|
||||||
# utilities.convert_and_save_to_xlsx(str(results), "tmp/output.xlsx")
|
|
||||||
# utilities.convert_and_save_to_csv(str(results), "tmp/data.csv")
|
|
||||||
|
|
||||||
printer('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
|
# printer('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
|
||||||
'%(latency)s ms' % results.server, quiet)
|
# '%(latency)s ms' % results.server, quiet)
|
||||||
|
|
||||||
if args.download:
|
if args.download:
|
||||||
printer('Testing download speed', quiet,
|
# printer('Testing download speed', quiet,
|
||||||
end=('', '\n')[bool(debug)])
|
# end=('', '\n')[bool(debug)])
|
||||||
speedtest.download(
|
speedtest.download(
|
||||||
callback=callback,
|
callback=callback,
|
||||||
threads=(None, 1)[args.single]
|
threads=(None, 1)[args.single]
|
||||||
)
|
)
|
||||||
printer('Download: %0.2f M%s/s' %
|
# printer('Download: %0.2f M%s/s' %
|
||||||
((results.download / 1000.0 / 1000.0) / args.units[1],
|
# ((results.download / 1000.0 / 1000.0) / args.units[1],
|
||||||
args.units[0]),
|
# args.units[0]),
|
||||||
quiet)
|
# quiet)
|
||||||
else:
|
else:
|
||||||
printer('Skipping download test', quiet)
|
printer('Skipping download test', quiet)
|
||||||
|
|
||||||
if args.upload:
|
if args.upload:
|
||||||
printer('Testing upload speed', quiet,
|
# printer('Testing upload speed', quiet,
|
||||||
end=('', '\n')[bool(debug)])
|
# end=('', '\n')[bool(debug)])
|
||||||
speedtest.upload(
|
speedtest.upload(
|
||||||
callback=callback,
|
callback=callback,
|
||||||
pre_allocate=args.pre_allocate,
|
pre_allocate=args.pre_allocate,
|
||||||
threads=(None, 1)[args.single]
|
threads=(None, 1)[args.single]
|
||||||
)
|
)
|
||||||
printer('Upload: %0.2f M%s/s' %
|
# printer('Upload: %0.2f M%s/s' %
|
||||||
((results.upload / 1000.0 / 1000.0) / args.units[1],
|
# ((results.upload / 1000.0 / 1000.0) / args.units[1],
|
||||||
args.units[0]),
|
# args.units[0]),
|
||||||
quiet)
|
# quiet)
|
||||||
else:
|
else:
|
||||||
printer('Skipping upload test', quiet)
|
printer('Skipping upload test', quiet)
|
||||||
|
|
||||||
|
|
@ -2004,18 +2000,20 @@ def shell():
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
for i in range(0,3):
|
||||||
shell()
|
try:
|
||||||
except KeyboardInterrupt:
|
shell()
|
||||||
printer('\nCancelling...', error=True)
|
except KeyboardInterrupt:
|
||||||
except (SpeedtestException, SystemExit):
|
printer('\nCancelling...', error=True)
|
||||||
e = get_exception()
|
except (SpeedtestException, SystemExit):
|
||||||
# Ignore a successful exit, or argparse exit
|
e = get_exception()
|
||||||
if getattr(e, 'code', 1) not in (0, 2):
|
# Ignore a successful exit, or argparse exit
|
||||||
msg = '%s' % e
|
if getattr(e, 'code', 1) not in (0, 2):
|
||||||
if not msg:
|
msg = '%s' % e
|
||||||
msg = '%r' % e
|
if not msg:
|
||||||
raise SystemExit('ERROR: %s' % msg)
|
msg = '%r' % e
|
||||||
|
raise SystemExit('ERROR: %s' % msg)
|
||||||
|
i+=1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
12
utilities.py
12
utilities.py
|
|
@ -65,15 +65,3 @@ def flatten_dict(d, parent_key='', sep='_'):
|
||||||
else:
|
else:
|
||||||
items.append((new_key, v))
|
items.append((new_key, v))
|
||||||
return dict(items)
|
return dict(items)
|
||||||
|
|
||||||
# Sample input string
|
|
||||||
sample_input = "{'download': 0, 'upload': 0, 'ping': 9.319, 'server': {'url': 'http://speedtest.nextgentel.no:8080/speedtest/upload.php', 'lat': '59.9494', 'lon': '10.7564', 'name': 'Oslo', 'country': 'Norway', 'cc': 'NO', 'sponsor': 'NextGenTel AS', 'id': '8018', 'host': 'speedtest.nextgentel.no:8080', 'd': 5.7463776547060155, 'latency': 9.319}, 'timestamp': '2024-01-01T20:06:56.839888Z', 'bytes_sent': 0, 'bytes_received': 0, 'share': None, 'client': {'ip': '84.215.59.36', 'lat': '59.955', 'lon': '10.859', 'isp': 'Telia Norge AS', 'isprating': '3.7', 'rating': '0', 'ispdlavg': '0', 'ispulavg': '0', 'loggedin': '0', 'country': 'NO'}}"
|
|
||||||
|
|
||||||
# Specify the file name
|
|
||||||
file_name = "output.xlsx"
|
|
||||||
|
|
||||||
# Call the function with the sample input and file name
|
|
||||||
convert_and_save_to_xlsx(sample_input, file_name)
|
|
||||||
|
|
||||||
|
|
||||||
# py .\speedtest.py --csv
|
|
||||||
Loading…
Reference in New Issue