diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-02-05 14:44:45 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-02-05 14:44:45 +0100 |
commit | 0ac3227b7bb27a76b6f49aa1605f1b1887a01a10 (patch) | |
tree | ab68843e42e06335f71d842eb71f70d89167c0fb /libmproxy/flow.py | |
parent | 19555bb39ab09f5e5b5dd663136e0105d2b3a625 (diff) | |
download | mitmproxy-0ac3227b7bb27a76b6f49aa1605f1b1887a01a10.tar.gz mitmproxy-0ac3227b7bb27a76b6f49aa1605f1b1887a01a10.tar.bz2 mitmproxy-0ac3227b7bb27a76b6f49aa1605f1b1887a01a10.zip |
clean up flow reading
Diffstat (limited to 'libmproxy/flow.py')
-rw-r--r-- | libmproxy/flow.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 97ebc572..f9e2b94d 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -945,6 +945,25 @@ class FlowMaster(controller.Master): self.stream = None +def read_flows_from_paths(paths): + """ + Given a list of filepaths, read all flows and return a list of them. + From a performance perspective, streaming would be advisable - + however, if there's an error with one of the files, we want it to be raised immediately. + + If an error occurs, a FlowReadError will be raised. + """ + try: + flows = [] + for path in paths: + path = os.path.expanduser(path) + with file(path, "rb") as f: + flows.extend(FlowReader(f).stream()) + except IOError as e: + raise FlowReadError(e.strerror) + return flows + + class FlowWriter: def __init__(self, fo): self.fo = fo |