Previously we looked for 'eth0', but linux has renamed interfaces.
Instead of looking by name, we now look for an interface which
is the appropriate gateway to a remote server address.
fixes#831
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.
pmonitor() is hard to get right, but this seems like
a reasonable improvement:
1. non-blocking I/O so we can drain buffer with impunity
2. drain buffer after poll
3. unregister fd on POLLHUP
Note we may have a unicode splitting problem since we're
decoding chunks of bytes, but that is a problem for another
day I think.
Changes for compatibility with Python 3.
The approach is to make as few changes as possible to maintain compatibility with both Python 2 and Python 3.
We use whatever python is installed, and also support a PYTHON environment variable for installing another version.
For simplicity, we provide mininet.util.pexpect which works out of the box with Python 3 utf-8 strings.
Thanks to @cuihantao for looking at this as well and also for changes to MiniEdit.
Closes#794
items() vs. iteritems() and decode() bytes in monitorFiles
Probably not strictly correct if bytes are split - we still
need to deal with this properly.
Unfortunately pexpect isn't compatible with Python 3 strings
unless you specify unicode encoding, which isn't the default.
With this helper code, you can import pexpect from mininet.util
and get default pexpect.spawn() behavior that works with Python 3
strings.
I'm not a fan of this, but Python 3's subprocess module
complains otherwise.
For now we're only doing this on Python 3. We should probably
quantify the slowdown however.