Comment 1 for bug 865370

Revision history for this message
Hanno Schlichting (hannosch) wrote :

I use those in two ways, either simple command line:

$ echo stat | nc 127.0.0.1 2181

or via as very simple helper:

from socket import create_connection

def send_command(host=u'127.0.0.1', port=2181, command=b'ruok'):
    sock = create_connection((host, port))
    sock.sendall(command)
    result = sock.recv(8192)
    sock.close()
    return [l.strip() for l in result.split('\n') if l]

>>> send_command(command=b'stat')