Solved Python 2.4 build compatibilty and flake8 warnings
This commit is contained in:
parent
bd4bced399
commit
cdf2724bd8
|
@ -739,14 +739,15 @@ def speedtest():
|
|||
if args.csv:
|
||||
filename = args.csv
|
||||
file_exists = os.path.isfile(filename)
|
||||
|
||||
try:
|
||||
with open(filename, 'ab+') as csvfile:
|
||||
csvfile = open(filename, 'ab+')
|
||||
try:
|
||||
|
||||
headers = ['Test server', 'Date/Time', 'Latency (ms)',
|
||||
'Dowload Speed (Kb/s)', 'Upload Speed (Kb/s)']
|
||||
csvwriter = csv.DictWriter(csvfile, delimiter=';',
|
||||
lineterminator='\n',fieldnames=headers)
|
||||
lineterminator='\n',
|
||||
fieldnames=headers)
|
||||
|
||||
server = '%(sponsor)s (%(name)s) [%(d)0.2f km]' % best
|
||||
current_time = datetime.datetime.now().isoformat()
|
||||
|
@ -754,7 +755,6 @@ def speedtest():
|
|||
ping = float(round(best['latency'], 2))
|
||||
ulspeedk = int(round((ulspeed / 1000) * 8, 0))
|
||||
|
||||
|
||||
if not file_exists:
|
||||
csvwriter.writeheader()
|
||||
|
||||
|
@ -762,8 +762,8 @@ def speedtest():
|
|||
'Date/Time': current_time,
|
||||
'Latency (ms)': ping,
|
||||
'Dowload Speed (Kb/s)': dlspeedk,
|
||||
'Upload Speed (Kb/s)': ulspeedk
|
||||
})
|
||||
'Upload Speed (Kb/s)': ulspeedk})
|
||||
finally:
|
||||
csvfile.close()
|
||||
except IOError:
|
||||
print_("Unable to write CSV file")
|
||||
|
|
Loading…
Reference in New Issue