diff mbox series

[ovs-dev] ovs-dpctl-top: fix ovs-dpctl-top via pipe

Message ID ccbe8452bee9696528daba75a2ab148ee64dd8fa.1620841473.git.tredaelli@redhat.com
State New
Headers show
Series [ovs-dev] ovs-dpctl-top: fix ovs-dpctl-top via pipe | expand

Commit Message

Timothy Redaelli May 12, 2021, 5:44 p.m. UTC
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>
---
 utilities/ovs-dpctl-top.in | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/utilities/ovs-dpctl-top.in b/utilities/ovs-dpctl-top.in
index fbe6e4f56..2c1766eff 100755
--- a/utilities/ovs-dpctl-top.in
+++ b/utilities/ovs-dpctl-top.in
@@ -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)