nando client p3

This commit is contained in:
Q
2020-05-08 22:47:18 +03:00
parent fe600f8546
commit ff71a588cc

12
nando
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
import socket,sys,time,os,configobj import socket,sys,time,os,configobj
@@ -90,7 +90,7 @@ def read_desc(opts):
return "" return ""
DESC=open(opts.MSGFILE,"rb").read(1024) DESC=open(opts.MSGFILE,"rb").read(1024)
DESC=''.join([ c for c in DESC if c not in ['\n','\r','|'] ]) DESC=''.join([ str(c) for c in DESC.decode('utf-8') if c not in ['\n','\r','|'] ])
return DESC return DESC
opts=setup_options() opts=setup_options()
@@ -115,14 +115,14 @@ while True:
else: else:
MSG=opts.command MSG=opts.command
sock.sendto(MSG, (opts.HOST, opts.PORT)) sock.sendto(MSG.encode('utf8'), (opts.HOST, opts.PORT))
received = sock.recv(BLOCK_SIZE) received = sock.recv(BLOCK_SIZE)
if opts.command!="": if opts.command!="":
print_table(received) print_table(received.decode('utf8'))
if opts.INTERVAL==0 and opts.command=="": if opts.INTERVAL==0 and opts.command=="":
sock.sendto("list", (opts.HOST, opts.PORT)) sock.sendto("list".encode('utf8'), (opts.HOST, opts.PORT))
received = sock.recv(BLOCK_SIZE) received = sock.recv(BLOCK_SIZE)
print_table(received) print_table(received.decode('utf8'))
errors=0 errors=0
except socket.error: except socket.error:
print("Didn't get reply from {0}:{1}".format(opts.HOST,opts.PORT)) print("Didn't get reply from {0}:{1}".format(opts.HOST,opts.PORT))