Commit 7ac44e8c authored by Ad Schellevis's avatar Ad Schellevis

add end of stream marker to configd backend service (and commandline tool)

parent baa9f798
......@@ -38,9 +38,10 @@ import sys
__author__ = 'Ad Schellevis'
configd_socket_name = '/var/run/configd.socket'
configd_socket_name = 'testing/configd.socket'
# set a timeout to the socket
socket.setdefaulttimeout(120)
if len(sys.argv) <= 1:
print 'usage : %s <command>'%sys.argv[0]
......@@ -52,13 +53,21 @@ else:
sock.connect(configd_socket_name)
try:
sock.send(exec_command)
data = []
data = ""
while True:
line = sock.recv(4096)
if line:
data.append(line)
else:
data = data + line
if data.find("%c%c%c"%(chr(0),chr(0),chr(0))) > -1:
break
print (''.join(data))
print (data[:-3])
finally:
sock.close()
......@@ -103,7 +103,7 @@ class Handler(object):
# run single threaded
cmd_thread.run()
else:
# rnu threaded
# run threaded
cmd_thread.start()
except KeyboardInterrupt:
......@@ -171,6 +171,9 @@ class HandlerClient(threading.Thread):
# send response back to client( including trailing enter )
self.connection.sendall('%s\n'%result)
# send end of stream characters
self.connection.sendall("%c%c%c"%(chr(0),chr(0),chr(0)))
except:
print (traceback.format_exc())
syslog.syslog(syslog.LOG_ERR,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment