Add error checking to ViewProtobuf

There are protobufs that protoc can't parse.  When protoc --decode_raw
fails, it returns nothing to stdin, and writes "Failed to parse input."
to stderr. Before this commit, if protoc --decode_raw couldn't parse
the protobuf, the blank stdout output would get returned to the view;
with this commit stderr gets caught and returned to the view.
This commit is contained in:
Jason A. Novak 2013-04-21 12:46:37 -05:00
parent 61c794e08f
commit f78dada550

View File

@ -389,8 +389,11 @@ class ViewProtobuf:
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, _ = p.communicate(input=content)
out, err = p.communicate(input=content)
if out:
return out
else:
return err
def __call__(self, hdrs, content, limit):
decoded = self.decode_protobuf(content)