X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2Ftcptest.py;h=e5ff92eb5611776b2e29fc24e52cd3a9f747dcdb;hb=2c40c38256132139aec5155504226166eae34b1d;hp=f1512b671a47c9b60e58987bdc0c63819c669740;hpb=453cf4bdd0de8e45c807ab11139e3e044bb4a899;p=tests.git diff --git a/system/tcptest.py b/system/tcptest.py index f1512b6..e5ff92e 100755 --- a/system/tcptest.py +++ b/system/tcptest.py @@ -3,6 +3,9 @@ # Thierry Parmentelat # Copyright (C) 2010 INRIA # + +from __future__ import print_function + import sys import time import subprocess @@ -12,8 +15,8 @@ import threading from optparse import OptionParser def myprint(message, id='client'): - now=time.strftime("%H:%M:%S", time.localtime()) - print "*",now,'(%s)' % id, '--',message + now = time.strftime("%H:%M:%S", time.localtime()) + print("* {now} ({id}) -- {message}".format(**locals())) sys.stdout.flush() def show_network_status(id): @@ -64,7 +67,7 @@ class Server: else: server.serve_forever() except KeyboardInterrupt as e: - print 'Bailing out on keyboard interrupt' + print('Bailing out on keyboard interrupt') sys.exit(1) class Ready: @@ -90,7 +93,7 @@ class Ready: s.bind((options.address, options.port)) return True except Exception as e: - print e + print(e) return False def eth0_has_ipv4(): @@ -127,15 +130,15 @@ class Client: mout=i*'ping ' + '\n' min=mout.upper() if s.send(mout) != len(mout): - myprint("cannot send %s"%mout.strip()) + myprint("cannot send {}".format(mout.strip())) result=False break line=s.recv(len(min)) if line is not line: - myprint("unexpected reception\ngot:%s\nexpected: %s",line,min) - result=False + myprint("unexpected reception\ngot:{}\nexpected: {}".format(line, min)) + result = False else: - myprint("OK:%s"%mout.strip()) + myprint("OK:{}".format(mout.strip())) # leave the connection open, but the last one (so 1 iter returns fast) if i != options.loops: time.sleep(options.sleep) @@ -158,5 +161,5 @@ if __name__ == '__main__': elif arg.find("ready") >= 0: sys.argv.remove(arg) Ready().main() - print 'you must specify either --client or --server' + print('you must specify either --client or --server') sys.exit(1)