Exemplo n.º 1
0
async def _get_nvim_client(nvim_pid):
    nvim_sock = get_nvim_unix_socket_by_pid(nvim_pid)
    if nvim_sock:
        nvim = aio_msgpack_rpc.Client(
            *await asyncio.open_unix_connection(nvim_sock))
        await nvim.call(b'nvim_set_option', 'pumheight', 1)
        return nvim
    return None
Exemplo n.º 2
0
 async def connect(port):
     client = aio_msgpack_rpc.Client(
         *await asyncio.open_connection("127.0.0.1", port))
     status, msg = await client.call("connect")
     if status:
         self.logger.error(f"Connecting to power strip: Error: {msg}")
     else:
         self.logger.debug(f"Connecting to power strip: {msg}")
         self.output_setup = True
Exemplo n.º 3
0
                    async def get_status(port):
                        client = aio_msgpack_rpc.Client(
                            *await asyncio.open_connection("127.0.0.1", port))

                        status, msg = await client.call("get_status")
                        if status:
                            self.logger.error(f"Status: Error: {msg}")
                        else:
                            self.logger.debug(f"Status: {msg}")
                            if msg:
                                for channel, state in enumerate(msg):
                                    self.output_states[channel] = state
Exemplo n.º 4
0
        async def outlet_change(port, channel_, state_):
            client = aio_msgpack_rpc.Client(
                *await asyncio.open_connection("127.0.0.1", port))

            if state_:
                status, msg = await client.call("outlet_on", channel_)
            else:
                status, msg = await client.call("outlet_off", channel_)

            if status:
                self.logger.error(
                    f"Switching CH{channel_} {'ON' if state_ else 'OFF'}: Error: {msg}"
                )
            else:
                self.output_states[channel] = state
                self.logger.debug(
                    f"Switching CH{channel_} {'ON' if state_ else 'OFF'}: {msg}"
                )