forked from JimJamUrCode/lirc_node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearnDevice.py
More file actions
31 lines (28 loc) · 827 Bytes
/
learnDevice.py
File metadata and controls
31 lines (28 loc) · 827 Bytes
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
#sudo irrecord -f -d /dev/lirc0 /home/pi/lirc_web/node_modules/lirc_node/irrecord/lircdlearn1.conf
import pexpect
import os
import sys
from time import sleep
try:
os.remove('/home/pi/lirc_web/node_modules/lirc_node/irrecord/lircdlearn.conf')
except OSError:
pass
try:
os.system("sudo /etc/init.d/lirc stop")
except OSError:
pass
sleep(4)
child = pexpect.spawn ('sudo irrecord -f -d /dev/lirc0 /home/pi/lirc_web/node_modules/lirc_node/irrecord/lircdlearn.conf')
child.logfile = sys.stdout
child.expect ('Press RETURN to continue.')
child.sendline ('')
child.expect ('Press RETURN now to start recording.')
print "\nStart Pressing!"
child.sendline ('')
child.expect ('Now enter the names for the buttons.')
child.sendline ('')
sleep(2)
try:
os.system("sudo /etc/init.d/lirc start")
except OSError:
pass