-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_last_line.py
executable file
·40 lines (32 loc) · 1.01 KB
/
display_last_line.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import sys
from csv import reader
from os.path import isdir
from src.affichage import affichage, affichage_brut_cartesien_une_image, init_affichage_brut_cartesien
if not isdir("./Logs/"):
print("No measure to read")
sys.exit(0)
n_last_lines = 10
last_lines = []
with open("Logs/RawData.logs", "r") as f:
data_reader = reader(f, delimiter=" ")
for line in data_reader:
last_lines.append(line)
if len(last_lines) >= n_last_lines:
last_lines.pop(0)
if not last_lines:
print("The log file is void")
sys.exit(0)
ax = None
fig = None
# Initialisation de l'affichage
if affichage:
print("Affichage init")
ax, fig = init_affichage_brut_cartesien()
measures = [measure for line in last_lines for measure in line[1:] if ":" in measure]
dico = {float(m.split(":")[0]): float(m.split(":")[0]) for measure in measures for m in measure.split(":")}
# Affichage des points
if affichage:
affichage_brut_cartesien_une_image(ax, dico, fig)
else:
print(dico)