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,8 +501,8 @@ class ConsoleMaster(flow.FlowMaster):
flows = []
for path in paths:
path = os.path.expanduser(path)
f = file(path, "rb")
flows.extend(list(flow.FlowReader(f).stream()))
with file(path, "rb") as f:
flows.extend(list(flow.FlowReader(f).stream()))
except (IOError, flow.FlowReadError), v:
return True, v.strerror
return False, flows

View File

@ -148,8 +148,8 @@ class DumpMaster(flow.FlowMaster):
flows = []
for path in paths:
path = os.path.expanduser(path)
f = file(path, "rb")
flows.extend(list(flow.FlowReader(f).stream()))
with file(path, "rb") as f:
flows.extend(list(flow.FlowReader(f).stream()))
except (IOError, flow.FlowReadError), v:
raise DumpError(v.strerror)
return flows