Rev Author Line No. Line
4686 kaklik 1 #!/usr/bin/python
2 import wiringpi2 as gpio
3 import time
4 import subprocess
5  
6 gpio.wiringPiSetupGpio()
7 gpio.pinMode(88, 0)
8 gpio.pullUpDnControl(88, 0)
9  
10  
11 oldstav = gpio.digitalRead(88)
12  
13 while True:
14 stav = gpio.digitalRead(88)
15  
4687 kaklik 16 if oldstav == 0 and stav == 0:
4686 kaklik 17 subprocess.call("shutdown -P 1", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
4688 kaklik 18 else:
19 print "power is OK."
20  
21 oldstav = stav
4686 kaklik 22  
4687 kaklik 23 time.sleep(2)
4686 kaklik 24  
25