truncate decimal places, opens in the correct mode
parent
3687854e42
commit
19e02d7d94
10
analyze.py
10
analyze.py
|
@ -99,14 +99,14 @@ def analyze_server(server: Path, serverip: str) -> None:
|
||||||
time_of_hit = datetime.strptime(timethings, log_date_format)
|
time_of_hit = datetime.strptime(timethings, log_date_format)
|
||||||
# convert from its default timezone in GMT to the timezone of the requester
|
# convert from its default timezone in GMT to the timezone of the requester
|
||||||
localtime = time_of_hit.replace(tzinfo=timezone.utc).astimezone(timezone)
|
localtime = time_of_hit.replace(tzinfo=timezone.utc).astimezone(timezone)
|
||||||
# convert this time back to a string for logging purposes
|
# convert this time back to a string for logging purposes, without timezone
|
||||||
localtime_str = localtime.strftime(log_date_format)
|
localtime_str = ' '.join(localtime.strftime(log_date_format).split(' ')[:2])
|
||||||
|
|
||||||
distance = latlon_distance(self_latlon, latlon)
|
distance = latlon_distance(self_latlon, latlon)
|
||||||
date, time = timethings.split(' ')[:2]
|
date, time = timethings.split(' ')[:2]
|
||||||
result += (
|
result += (
|
||||||
f'{server.name},{ip},{distance},{date},{time},'
|
f'{server.name},{ip},{distance:.5f},{date},{time},'
|
||||||
+ f'{localtime_str},{method},{file}\n'
|
+ f'{localtime_str},{method},"{file}"\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -135,7 +135,7 @@ def main(args: list) -> int:
|
||||||
outfile = 'analysis.csv'
|
outfile = 'analysis.csv'
|
||||||
start_dir = Path('.').resolve()
|
start_dir = Path('.').resolve()
|
||||||
|
|
||||||
f = open(outfile, 'a')
|
f = open(outfile, 'w')
|
||||||
for logdir in args[1:]:
|
for logdir in args[1:]:
|
||||||
chdir(logdir)
|
chdir(logdir)
|
||||||
serverdir = Path('.')
|
serverdir = Path('.')
|
||||||
|
|
Loading…
Reference in New Issue