progress bar updated
This commit is contained in:
parent
a5444a864a
commit
9bba32a197
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
temp/**
|
temp/**
|
||||||
.idea
|
.idea
|
||||||
.idea/**
|
.idea/**
|
||||||
|
poetry.lock
|
||||||
|
@ -7,6 +7,7 @@ readme = "README.md"
|
|||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.12"
|
python = "^3.12"
|
||||||
|
tqdm = "^4.66.5"
|
||||||
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
13
src/app.py
13
src/app.py
@ -2,6 +2,8 @@ import argparse
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
import os
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog='java-logs-analyzer')
|
parser = argparse.ArgumentParser(prog='java-logs-analyzer')
|
||||||
parser.add_argument('-l', '--logs', help='Logs file')
|
parser.add_argument('-l', '--logs', help='Logs file')
|
||||||
@ -54,17 +56,10 @@ def _parse(line: str) -> (bool, str, str, str, str, str, str):
|
|||||||
|
|
||||||
|
|
||||||
with open(args.logs, 'r') as file:
|
with open(args.logs, 'r') as file:
|
||||||
read_len = 0
|
progress = tqdm(total=file_len, unit='b', unit_scale=2)
|
||||||
last_percent = -1
|
|
||||||
percent = 0
|
|
||||||
for line in file:
|
for line in file:
|
||||||
l = line.strip()
|
l = line.strip()
|
||||||
read_len += len(line)
|
progress.update(len(line))
|
||||||
percent = round(read_len / file_len * 100, 2)
|
|
||||||
cur_percent = round(percent / 10, 0)
|
|
||||||
if last_percent != cur_percent:
|
|
||||||
print(f"{percent}%", end='\r')
|
|
||||||
last_percent = cur_percent
|
|
||||||
(is_parsed, year, month, day, hour, minute, second) = _parse(l)
|
(is_parsed, year, month, day, hour, minute, second) = _parse(l)
|
||||||
if is_parsed:
|
if is_parsed:
|
||||||
if first_line is None:
|
if first_line is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user