def printout(self, stream, context): obj = Container() if self.show_stream: obj.stream_position = stream.tell() follows = stream.read(self.stream_lookahead) if not follows: obj.following_stream_data = "EOF reached" else: stream.seek(-len(follows), 1) obj.following_stream_data = HexString(follows) print("") if self.show_context: obj.context = context if self.show_stack: obj.stack = ListContainer() frames = [s[0] for s in inspect.stack()][1:-1] frames.reverse() for f in frames: a = Container() a.__update__(f.f_locals) obj.stack.append(a) print("=" * 80) print("Probe %s" % (self.printname, )) print(obj) print("=" * 80)
def _parse(self, stream, context): obj = ListContainer() c = 0 count = self.countfunc(context) try: if self.subcon.conflags & self.FLAG_COPY_CONTEXT: while c < count: obj.append(self.subcon._parse(stream, context.__copy__())) c += 1 else: while c < count: obj.append(self.subcon._parse(stream, context)) c += 1 except ConstructError: raise ArrayError("expected %d, found %d" % (count, c), sys.exc_info()[1]) return obj
def _parse(self, stream, context): if "<obj>" in context: obj = context["<obj>"] del context["<obj>"] else: obj = ListContainer() if self.nested: context = Container(_ = context) for sc in self.subcons: if sc.conflags & self.FLAG_EMBED: context["<obj>"] = obj sc._parse(stream, context) else: subobj = sc._parse(stream, context) if sc.name is not None: obj.append(subobj) context[sc.name] = subobj return obj
def _parse(self, stream, context): obj = ListContainer() c = 0 try: if self.subcon.conflags & self.FLAG_COPY_CONTEXT: while c < self.maxcout: pos = stream.tell() obj.append(self.subcon._parse(stream, context.__copy__())) c += 1 else: while c < self.maxcout: pos = stream.tell() obj.append(self.subcon._parse(stream, context)) c += 1 except ConstructError: if c < self.mincount: raise RangeError("expected %d to %d, found %d" % (self.mincount, self.maxcout, c), sys.exc_info()[1]) stream.seek(pos) return obj
def drop_terminate_messages(messages): ''' Terminate() messages happen eventually, Citus doesn't feel any need to send them immediately, so tests which embed them aren't reproducible and fail to timing issues. Here we simply drop those messages. ''' def isTerminate(msg, from_client): kind = structs.message_type(msg, from_client) return kind == 'Terminate' for message in messages: if not message.parsed: yield message continue message.parsed = ListContainer([ msg for msg in message.parsed if not isTerminate(msg, message.from_client) ]) message.parsed.from_frontend = message.from_client if len(message.parsed) == 0: continue yield message