-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpylirc_test.py
executable file
·88 lines (73 loc) · 2.69 KB
/
pylirc_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python
#
# pyLirc, lirc (remote control) module for python
# Copyright (C) 2003 Linus McCabe <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
##
#
# This is a small and quite bad testprogram for the lirc module but
# it's getting better...
#
# $Id: pylirc_test.py,v 1.8 2003/02/22 22:51:01 mccabe Exp $
# $Log: pylirc_test.py,v $
# Revision 1.8 2003/02/22 22:51:01 mccabe
# Previous, accidental commit:
# Added Brian J. Murrell's code to fetch repeatcount
#
# This commit:
# Changed Brians code to return a dictionary instead of a list.
# Removed lirc_nextcode_ext() and merged it with lirc_nextcode() - new optional argument controls return type. Old programs should work as
# before and new programs can benefit the new behaviour by passing true as first argument.
#
# Revision 1.7 2003/02/22 22:12:40 mccabe
# Testprogram to test pylirc in multiple threads
#
# Revision 1.6 2002/12/21 20:30:26 mccabe
# Added id and log entries to most files
#
import pylirc, time
blocking = 0;
#
if(pylirc.init("pylirc", "./conf", blocking)):
code = {"config" : ""}
while(code["config"] != "quit"):
# Very intuitive indeed
if(not blocking):
print "."
# Delay...
time.sleep(1)
# Read next code
s = pylirc.nextcode(1)
# Loop as long as there are more on the queue
# (dont want to wait a second if the user pressed many buttons...)
while(s):
# Print all the configs...
for (code) in s:
print "Command: %s, Repeat: %d" % (code["config"], code["repeat"])
if(code["config"] == "blocking"):
blocking = 1
pylirc.blocking(1)
elif(code["config"] == "nonblocking"):
blocking = 0
pylirc.blocking(0)
# Read next code?
if(not blocking):
s = pylirc.nextcode(1)
else:
s = []
# Clean up lirc
pylirc.exit()