-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
34 lines (32 loc) · 1.31 KB
/
logger.py
File metadata and controls
34 lines (32 loc) · 1.31 KB
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
import tkinter
class Logger(object):
def __init__(self, terminal):
#self.printer = sys.stdout
self.terminal = terminal
self.train_progress = None
#self.log = open("logfile.log", "a")
def write(self, message):
#self.printer.write(message)
self.terminal.insert(tkinter.END, message)
self.terminal.see(tkinter.END)
if self.train_progress is not None:
if "Lancement de l'entrainement ..." in message:
self.train_progress["value"] = 5
try:
if "Epoch " in message:
avancement = message[6:]
#print(avancement)
actuel, final = avancement.split("/")
#print("actuel : " + actuel + " / final : " + final)
final_amount = int(actuel) * 100 / int(final)
#print(int(final_amount))
self.train_progress["value"] = final_amount
except ValueError:
pass
def set_training_bar(self, training_bar):
self.train_progress = training_bar
def flush(self):
#this flush method is needed for python 3 compatibility.
#this handles the flush command by doing nothing.
#you might want to specify some extra behavior here.
pass