StreamReader.py 693 Bytes
Newer Older
1
2
import labcomm

3
4
5
6
7
8
9
class StreamReader:

    def __init__(self, stream):
        self.stream = stream
        pass

    def start(self, decoder, version):
10
11
12
13
14
15
16
        self.version = version;
        if labcomm.LabComm.sendVersionString(version):
          other_version = decoder.decode_string()
          if version != other_version:
              raise Exception("LabComm version mismatch %s != %s" %
                              (version, other_version))
          pass
17
18
19
20
21
22
23
24
25
26
27
28
        pass

    def read(self, count):
        result = self.stream.read(count)
        if len(result) == 0:
            raise EOFError()
        return result

    def mark(self, value, decl):
        pass
        
    pass