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 ...@@ -38,9 +38,10 @@ import sys
__author__ = 'Ad Schellevis' __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: if len(sys.argv) <= 1:
print 'usage : %s <command>'%sys.argv[0] print 'usage : %s <command>'%sys.argv[0]
...@@ -52,13 +53,21 @@ else: ...@@ -52,13 +53,21 @@ else:
sock.connect(configd_socket_name) sock.connect(configd_socket_name)
try: try:
sock.send(exec_command) sock.send(exec_command)
data = [] data = ""
while True: while True:
line = sock.recv(4096) line = sock.recv(4096)
if line: if line:
data.append(line) data = data + line
else:
if data.find("%c%c%c"%(chr(0),chr(0),chr(0))) > -1:
break break
print (''.join(data))
print (data[:-3])
finally: finally:
sock.close() sock.close()
...@@ -103,7 +103,7 @@ class Handler(object): ...@@ -103,7 +103,7 @@ class Handler(object):
# run single threaded # run single threaded
cmd_thread.run() cmd_thread.run()
else: else:
# rnu threaded # run threaded
cmd_thread.start() cmd_thread.start()
except KeyboardInterrupt: except KeyboardInterrupt:
...@@ -171,6 +171,9 @@ class HandlerClient(threading.Thread): ...@@ -171,6 +171,9 @@ class HandlerClient(threading.Thread):
# send response back to client( including trailing enter ) # send response back to client( including trailing enter )
self.connection.sendall('%s\n'%result) self.connection.sendall('%s\n'%result)
# send end of stream characters
self.connection.sendall("%c%c%c"%(chr(0),chr(0),chr(0)))
except: except:
print (traceback.format_exc()) print (traceback.format_exc())
syslog.syslog(syslog.LOG_ERR, 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