-
Notifications
You must be signed in to change notification settings - Fork 0
/
Power.py
42 lines (40 loc) · 1.28 KB
/
Power.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
from Keypad import keypad
from Password import password
import lcddriver
import subprocess
import time
class power():
def menu(self):
display = lcddriver.lcd()
kp = keypad()
display.lcd_clear()
time.sleep(1)
while True :
display.lcd_display_string("A)Shutdown",1)
display.lcd_display_string("B)Reboot",2)
key = None
while key == None:
key = kp.getKey()
if(key == "A"):
display.lcd_clear()
time.sleep(1)
display.lcd_display_string("Shutdown...",1)
time.sleep(2)
display.lcd_clear()
print(subprocess.call("shutdown -h now", shell=True))
break
if(key == "B"):
display.lcd_clear()
time.sleep(1)
display.lcd_display_string("Reboot...",1)
print(subprocess.call("sudo reboot", shell=True))
break
if(key == "C"):
password.changepass()
break
if(key == "D"):
display.lcd_clear()
time.sleep(1)
display.lcd_display_string("Cancel...",1)
time.sleep(2)
break