2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

ovs-dpctl-top: Fix ovs-dpctl-top via pipe.

Currently it's not possible to use ovs-dpctl-top via pipe (eg:
ovs-dpctl dump-flows | ovs-dpctl-top --script --verbose) since Python3
doesn't allow to open a file (stdin in our case) in binary mode without
buffering enabled.

This commit changes the behaviour in order to directly pass stdin to
flows_read instead of re-opening it without buffering.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Timothy Redaelli 2021-05-12 19:44:33 +02:00 committed by Ilya Maximets
parent 59e8cb8a05
commit cd475f9765

View File

@ -1236,11 +1236,7 @@ def flows_script(args):
if (args.flowFiles is None):
logging.info("reading flows from stdin")
ihdl = os.fdopen(sys.stdin.fileno(), 'r', 0)
try:
flow_db = flows_read(ihdl, flow_db)
finally:
ihdl.close()
flow_db = flows_read(sys.stdin, flow_db)
else:
for flowFile in args.flowFiles:
logging.info("reading flows from %s", flowFile)