Ejemplo n.º 1
0
def proxy_to_coordinator(socket_path, header=None, stdin=None, stdout=None):
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    sock.connect(socket_path)
    try:
        stdin_fd = get_fd(stdin, sys.stdin)
        stdout_fd = get_fd(stdout, sys.stdout)
        with no_echo(stdin_fd):
            while True:
                ready, _, _ = select.select([stdin_fd, sock], [], [])
                if stdin_fd in ready:
                    c = os.read(stdin_fd, 1)
                    if c:
                        sock.send(c)
                if sock in ready:
                    c = sock.recv(1024)
                    if not c:
                        break
                    os.write(stdout_fd, c)
    finally:
        sock.close()
Ejemplo n.º 2
0
def proxy_to_coordinator(socket_path, header=None, stdin=None, stdout=None):
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    sock.connect(socket_path)
    try:
        stdin_fd = get_fd(stdin, sys.stdin)
        stdout_fd = get_fd(stdout, sys.stdout)
        with no_echo(stdin_fd):
            while True:
                ready, _, _ = select.select([stdin_fd, sock], [], [])
                if stdin_fd in ready:
                    c = os.read(stdin_fd, 1)
                    if c:
                        sock.send(c)
                if sock in ready:
                    try:
                        c = sock.recv(1024)
                    except socket.error as e:
                        break
                    if not c:
                        break
                    os.write(stdout_fd, c)
    finally:
        sock.close()
Ejemplo n.º 3
0
def join_player(sock_path, **kwds):
    stdout_fd = get_fd(kwds.get("stdout"), sys.stdout)
    os.write(stdout_fd, "\x1b[2J\x1b[H")
    return proxy_to_coordinator(sock_path, **kwds)
Ejemplo n.º 4
0
def join_player(sock_path, **kwds):
    stdout_fd = get_fd(kwds.get("stdout"), sys.stdout)
    os.write(stdout_fd, "\x1b[2J\x1b[H")
    return proxy_to_coordinator(sock_path, **kwds)