open flow files using with as max suggested

This commit is contained in:
Marcelo Glezer 2015-01-12 14:31:18 -03:00
parent c4aeca2764
commit 4f578866fa
2 changed files with 4 additions and 4 deletions

View File

@ -501,7 +501,7 @@ 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

View File

@ -148,7 +148,7 @@ 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)