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 .data import Message
|
||||||
from . import gui
|
from . import gui
|
||||||
from .data import log
|
from .data import log
|
||||||
|
from io import TextIOWrapper
|
||||||
|
|
||||||
|
|
||||||
def read_log(logfile: str, app: gui.Gui) -> None:
|
def read_log(logfile: str, app: gui.Gui) -> None:
|
||||||
try:
|
try:
|
||||||
logfile = open(logfile, 'r', encoding='utf8')
|
with open(logfile, 'r', encoding='utf8') as file:
|
||||||
loglines = follow(logfile)
|
loglines = follow(file)
|
||||||
for line in loglines:
|
for line in loglines:
|
||||||
message = Message.from_text(line)
|
message = Message.from_text(line)
|
||||||
log.debug(message)
|
log.debug(message)
|
||||||
if message and message.trade and message.to_from == 'From':
|
if message and message.trade and message.to_from == 'From':
|
||||||
log.debug(message.trade)
|
log.debug(message.trade)
|
||||||
app.add_tab(30, message)
|
app.add_tab(30, message)
|
||||||
except IOError:
|
except IOError:
|
||||||
log.error(f'Error opening log file {logfile}.')
|
log.error(f'Error opening log file {logfile}.')
|
||||||
|
|
||||||
|
|
||||||
def follow(thefile: str):
|
def follow(thefile: TextIOWrapper):
|
||||||
thefile.seek(0, 2)
|
thefile.seek(0, 2)
|
||||||
while True:
|
while True:
|
||||||
line = thefile.readline()
|
line = thefile.readline()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user