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
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.
Looking at trying to minimize code changes for Python 3.
For now we are keeping byte str() in py2 and unicode str()
in py3. It's a pain to rewrite all string code to usee
u'' for py2 compatibility. However we may need to revisit
this for pexpect().
Created compatibility wrappers in util.py:
BaseString (replacement for basestring)
decode() (optionally decode utf-8 for py3)
encode() (optionally encode utf-8 for py3)
Also we've switched from the .iter*() flavors to their
static alternatives for py2 (note they are iterators in py3!)
Changed util.errRun and clean.sh to call decode()