Beispiel #1
0
 def request(self, body):
     body = erlang.serialize(body)
     data = struct.pack("!I", len(body)) + body
     self.conn.sendall(data)
     buf = ""
     while len(buf) < 4:
         buf += self.conn.recv(4 - len(buf))
     size = struct.unpack("!I", buf)[0]
     ret = []
     while size > 0:
         ret.append(self.conn.recv(size))
         size -= len(ret[-1])
     ret = erlang.parse("".join(ret))
     if ret == a.timeout:
         raise RuntimeError("Timeout executing request")
     assert ret[0] == a.resp
     return ret[1]
Beispiel #2
0
def check_parser(vm, script, exp):
    resp = vm.run(script)
    if exp is not None:
        t.eq(resp, exp)
    t.eq(resp, erlang.parse(erlang.serialize(resp)))