diff options
Diffstat (limited to '815.patch')
-rw-r--r-- | 815.patch | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/815.patch b/815.patch deleted file mode 100644 index 1566c6581b2c..000000000000 --- a/815.patch +++ /dev/null @@ -1,69 +0,0 @@ -From a73e7766952759e7eebb656e553008f07b16a209 Mon Sep 17 00:00:00 2001 -From: Matthieu Coudron <mattator@gmail.com> -Date: Tue, 10 Jul 2018 17:47:49 +0900 -Subject: [PATCH] fix "which" calls always returning true - -The redirection of stderr towards stdout means calls to "which program" -always return something even when "program" is not installed. - -This patch checks for the return value instead before returning the -value. - -See #814. ---- - mininet/node.py | 10 +++++----- - mininet/util.py | 5 +++++ - 2 files changed, 10 insertions(+), 5 deletions(-) - -diff --git a/mininet/node.py b/mininet/node.py -index 7429b0b6f..4423cce7c 100644 ---- a/mininet/node.py -+++ b/mininet/node.py -@@ -63,7 +63,7 @@ - from mininet.log import info, error, warn, debug - from mininet.util import ( quietRun, errRun, errFail, moveIntf, isShellBuiltin, - numCores, retry, mountCgroups, BaseString, decode, -- encode, Python3 ) -+ encode, Python3, which ) - from mininet.moduledeps import moduleDeps, pathCheck, TUN - from mininet.link import Link, Intf, TCIntf, OVSIntf - from re import findall -@@ -1447,7 +1447,7 @@ def __repr__( self ): - @classmethod - def isAvailable( cls ): - "Is controller available?" -- return quietRun( 'which controller' ) -+ return which( 'controller' ) - - - class OVSController( Controller ): -@@ -1459,9 +1459,9 @@ def __init__( self, name, **kwargs ): - - @classmethod - def isAvailable( cls ): -- return ( quietRun( 'which ovs-controller' ) or -- quietRun( 'which test-controller' ) or -- quietRun( 'which ovs-testcontroller' ) ).strip() -+ return (which( 'ovs-controller' ) or -+ which( 'test-controller' ) or -+ which( 'ovs-testcontroller' )) - - class NOX( Controller ): - "Controller to run a NOX application." -diff --git a/mininet/util.py b/mininet/util.py -index 18813188f..9ce61db1e 100644 ---- a/mininet/util.py -+++ b/mininet/util.py -@@ -171,6 +171,11 @@ def quietRun( cmd, **kwargs ): - "Run a command and return merged stdout and stderr" - return errRun( cmd, stderr=STDOUT, **kwargs )[ 0 ] - -+def which(cmd, **kwargs ): -+ "Run a command and return merged stdout and stderr" -+ out, _, ret = errRun( ["which", cmd], stderr=STDOUT, **kwargs ) -+ return out.rstrip() if ret == 0 else None -+ - # pylint: enable=maybe-no-member - - def isShellBuiltin( cmd ): - |