fixed some warnings in trade.py
This commit is contained in:
parent
e48abb9820
commit
0c4054d94f
@ -2,23 +2,24 @@ import time
|
||||
from .data import Message
|
||||
from . import gui
|
||||
from .data import log
|
||||
from io import TextIOWrapper
|
||||
|
||||
|
||||
def read_log(logfile: str, app: gui.Gui) -> None:
|
||||
try:
|
||||
logfile = open(logfile, 'r', encoding='utf8')
|
||||
loglines = follow(logfile)
|
||||
for line in loglines:
|
||||
message = Message.from_text(line)
|
||||
log.debug(message)
|
||||
if message and message.trade and message.to_from == 'From':
|
||||
log.debug(message.trade)
|
||||
app.add_tab(30, message)
|
||||
with open(logfile, 'r', encoding='utf8') as file:
|
||||
loglines = follow(file)
|
||||
for line in loglines:
|
||||
message = Message.from_text(line)
|
||||
log.debug(message)
|
||||
if message and message.trade and message.to_from == 'From':
|
||||
log.debug(message.trade)
|
||||
app.add_tab(30, message)
|
||||
except IOError:
|
||||
log.error(f'Error opening log file {logfile}.')
|
||||
|
||||
|
||||
def follow(thefile: str):
|
||||
def follow(thefile: TextIOWrapper):
|
||||
thefile.seek(0, 2)
|
||||
while True:
|
||||
line = thefile.readline()
|
||||
|
Loading…
x
Reference in New Issue
Block a user