Merge pull request #1922 from mhils/read-from-stdin

mitmdump: fix reading from stdin
This commit is contained in:
Maximilian Hils 2017-01-10 10:58:18 +01:00 committed by GitHub
commit 48e399a285

View File

@ -170,8 +170,11 @@ class Master:
path = os.path.expanduser(path) path = os.path.expanduser(path)
try: try:
if path == "-": if path == "-":
# This is incompatible with Python 3 - maybe we can use click? try:
freader = io.FlowReader(sys.stdin) sys.stdin.buffer.read(0)
except Exception as e:
raise IOError("Cannot read from stdin: {}".format(e))
freader = io.FlowReader(sys.stdin.buffer)
return self.load_flows(freader) return self.load_flows(freader)
else: else:
with open(path, "rb") as f: with open(path, "rb") as f: