Commit 27dc184c authored by Tommy Olofsson's avatar Tommy Olofsson
Browse files

Do not let the readers reopen the file.

parent 2f9091de
...@@ -6,8 +6,8 @@ import labcomm ...@@ -6,8 +6,8 @@ import labcomm
class Reader(object): class Reader(object):
def __init__(self, _file): def __init__(self, file_):
self._file = open(_file) self._file = file_
def read(self, count): def read(self, count):
data = self._file.read(count) data = self._file.read(count)
...@@ -106,11 +106,11 @@ def main(): ...@@ -106,11 +106,11 @@ def main():
"Requires -f.") "Requires -f.")
args = parser.parse_args() args = parser.parse_args()
d = labcomm.Decoder(Reader(args.elc))
seen = {} seen = {}
current = {} current = {}
_type = {} _type = {}
file_ = open(args.elc)
d = labcomm.Decoder(Reader(file_))
# Do one pass through the file to find all registrations. # Do one pass through the file to find all registrations.
while True: while True:
try: try:
...@@ -126,10 +126,11 @@ def main(): ...@@ -126,10 +126,11 @@ def main():
# Do another pass to extract the data. # Do another pass to extract the data.
current = {} current = {}
file_.seek(0)
if args.follow: if args.follow:
reader = FollowingReader(args.elc, args.interval, args.timeout) reader = FollowingReader(file_, args.interval, args.timeout)
else: else:
reader = Reader(args.elc) reader = Reader(file_)
d = labcomm.Decoder(reader) d = labcomm.Decoder(reader)
while True: while True:
try: try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment