mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
open flow files using with as max suggested
This commit is contained in:
parent
c4aeca2764
commit
4f578866fa
@ -501,8 +501,8 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
flows = []
|
flows = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
f = file(path, "rb")
|
with file(path, "rb") as f:
|
||||||
flows.extend(list(flow.FlowReader(f).stream()))
|
flows.extend(list(flow.FlowReader(f).stream()))
|
||||||
except (IOError, flow.FlowReadError), v:
|
except (IOError, flow.FlowReadError), v:
|
||||||
return True, v.strerror
|
return True, v.strerror
|
||||||
return False, flows
|
return False, flows
|
||||||
|
@ -148,8 +148,8 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
flows = []
|
flows = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
f = file(path, "rb")
|
with file(path, "rb") as f:
|
||||||
flows.extend(list(flow.FlowReader(f).stream()))
|
flows.extend(list(flow.FlowReader(f).stream()))
|
||||||
except (IOError, flow.FlowReadError), v:
|
except (IOError, flow.FlowReadError), v:
|
||||||
raise DumpError(v.strerror)
|
raise DumpError(v.strerror)
|
||||||
return flows
|
return flows
|
||||||
|
Loading…
Reference in New Issue
Block a user