2 from __future__
import absolute_import
, division
, print_function
5 from time
import strftime
10 print("completion_logger_server.py <listen address> <listen port> <log file>")
14 port
= int(sys
.argv
[2])
18 # Create socket and bind to address
19 UDPSock
= socket(AF_INET
,SOCK_DGRAM
)
22 print("Listing on {0}:{1} and logging to '{2}'".format(host
, port
, sys
.argv
[3]))
24 # Open the logging file.
25 f
= open(sys
.argv
[3], "a")
29 data
,addr
= UDPSock
.recvfrom(buf
)
34 f
.write("\"time\": \"{0}\"".format(datetime
.datetime
.utcnow().strftime('%Y-%m-%d %H:%M:%S')))
35 f
.write(", \"sender\": \"{0}\" ".format(addr
[0]))
36 f
.write(", \"data\": ")
44 if __name__
== '__main__':