2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

python: Fix print function compatibility.

The print statement from Python 2 is a function in Python 3.  Enable
print function support for Python 2 and convert print statements to
function calls.

Enable the H233 flake8 warning.  If the hacking plugin is installed,
this will generate warnings for print statement usage not compatible
with Python 3.

  H233 Python 3.x incompatible use of print operator

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Russell Bryant
2015-12-14 10:21:53 -05:00
parent f3068bff92
commit 8ea171aba0
9 changed files with 74 additions and 57 deletions

View File

@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import errno
import sys
@@ -74,11 +76,11 @@ def do_run(arg):
if action is None:
pass
elif action == ovs.reconnect.CONNECT:
print " should connect"
print(" should connect")
elif action == ovs.reconnect.DISCONNECT:
print " should disconnect"
print(" should disconnect")
elif action == ovs.reconnect.PROBE:
print " should send probe"
print(" should send probe")
else:
assert False
@@ -92,10 +94,10 @@ def do_timeout(_):
global now
timeout = r.timeout(now)
if timeout >= 0:
print " advance %d ms" % timeout
print(" advance %d ms" % timeout)
now += timeout
else:
print " no timeout"
print(" no timeout")
def do_set_max_tries(arg):
@@ -183,7 +185,7 @@ def main():
r = ovs.reconnect.Reconnect(now)
r.set_name("remote")
prev = r.get_stats(now)
print "### t=%d ###" % now
print("### t=%d ###" % now)
old_time = now
old_max_tries = r.get_max_tries()
while True:
@@ -191,7 +193,7 @@ def main():
if line == "":
break
print line[:-1]
print(line[:-1])
if line[0] == "#":
continue
@@ -207,15 +209,15 @@ def main():
commands[command](op)
if old_time != now:
print
print "### t=%d ###" % now
print()
print("### t=%d ###" % now)
cur = r.get_stats(now)
diff_stats(prev, cur, now - old_time)
prev = cur
if r.get_max_tries() != old_max_tries:
old_max_tries = r.get_max_tries()
print " %d tries left" % old_max_tries
print(" %d tries left" % old_max_tries)
old_time = now