| LIRC libraries LinuxInfraredRemoteControl

list-keys.py
1 '''
2
3 Get list of available remotes from lircd server. Run using
4 python3 list-remotes.py <remote> [socket_path]
5
6 '''
7
8 import sys
9
10 import lirc
11
12 if len(sys.argv) >= 3 or len(sys.argv) < 2:
13 sys.stderr.write("Usage: list-keys.py <remote> [socket path]")
14 sys.exit(1)
15 path = sys.argv[2] if len(sys.argv) == 3 else None
16 remote = sys.argv[1]
17
18 with lirc.CommandConnection(path) as conn:
19 reply = lirc.ListKeysCommand(conn, remote).run()
20 for key in reply.data:
21 print(key)
22
23 # conn.send(command.cmd_string)
24 # while not command.parser.is_completed():
25 # line = conn.readline(0.1)
26 # command.parser.feed(line)
27 # if not command.parser.result == lirc.client.Result.OK:
28 # print("Cannot get version string")
29 # else:
30 # print(command.parser.data[0])