converting to python3

This commit is contained in:
tonton Th 2020-04-14 11:08:52 +02:00
parent cff083a21d
commit a3aa74b3b9

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
import socket, sys, getopt import socket, sys, getopt
@ -19,11 +19,11 @@ arguments = sys.argv[1:]
opts, args = getopt.getopt(arguments, options) opts, args = getopt.getopt(arguments, options)
for o, a in opts: for o, a in opts:
print ' ', o, ' --> ', a print (' ', o, ' --> ', a)
if "-v" == o: verbose += 1 if "-v" == o: verbose += 1
elif "-p" == o: rx_port = int(a) elif "-p" == o: rx_port = int(a)
print "listening port : ", rx_port print ("listening port : ", rx_port)
# --- # ---
@ -34,7 +34,7 @@ for ligne in open("destinations.liste"):
if p: cibles.append((a, int(p))) if p: cibles.append((a, int(p)))
for cible in cibles: for cible in cibles:
print " -> ", cible print (" -> ", cible)
# point d'entree, d'ecoute # point d'entree, d'ecoute
@ -49,7 +49,7 @@ sock_tx = socket.socket(socket.AF_INET, # Internet
while True: while True:
data, addr = sock_rx.recvfrom(1024) # buffer size is 1024 bytes data, addr = sock_rx.recvfrom(1024) # buffer size is 1024 bytes
if verbose: if verbose:
print "got:", addr, " ", len(data) print ("got:", addr, " ", len(data))
for cible in cibles: for cible in cibles:
# print cible # print cible
sock_tx.sendto(data, cible) sock_tx.sendto(data, cible)