mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 01:24:38 +00:00
add end of stream marker to configd backend service (and commandline tool)
This commit is contained in:
parent
baa9f79874
commit
7ac44e8c7b
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user