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)
|
||||
# convert from its default timezone in GMT to the timezone of the requester
|
||||
localtime = time_of_hit.replace(tzinfo=timezone.utc).astimezone(timezone)
|
||||
# convert this time back to a string for logging purposes
|
||||
localtime_str = localtime.strftime(log_date_format)
|
||||
# convert this time back to a string for logging purposes, without timezone
|
||||
localtime_str = ' '.join(localtime.strftime(log_date_format).split(' ')[:2])
|
||||
|
||||
distance = latlon_distance(self_latlon, latlon)
|
||||
date, time = timethings.split(' ')[:2]
|
||||
result += (
|
||||
f'{server.name},{ip},{distance},{date},{time},'
|
||||
+ f'{localtime_str},{method},{file}\n'
|
||||
f'{server.name},{ip},{distance:.5f},{date},{time},'
|
||||
+ f'{localtime_str},{method},"{file}"\n'
|
||||
)
|
||||
|
||||
return result
|
||||
|
@ -135,7 +135,7 @@ def main(args: list) -> int:
|
|||
outfile = 'analysis.csv'
|
||||
start_dir = Path('.').resolve()
|
||||
|
||||
f = open(outfile, 'a')
|
||||
f = open(outfile, 'w')
|
||||
for logdir in args[1:]:
|
||||
chdir(logdir)
|
||||
serverdir = Path('.')
|
||||
|
|
Loading…
Reference in New Issue