-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoinicio.py
More file actions
executable file
·52 lines (42 loc) · 1.19 KB
/
autoinicio.py
File metadata and controls
executable file
·52 lines (42 loc) · 1.19 KB
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
'''
Created on jul 7, 2017
@author: chamizo
'''
import os,sys
import subprocess
try:
import time
import os
import RPi.GPIO as GPIO
except RuntimeError:
print("RPi.GPIO Library has not been loaded!" +\
"Try using superuser privilage (sudo) on loading " +\
"the script...")
POWER_BUTTOM_DISABLED = 29
DATA_ENABLE = 32
POWER_BUTTOM_ENABLED = 16
HIGH = 1
LOW = 0
GPIO.setwarnings(False)
#Set GPIO to BCM numbering
GPIO.setmode(GPIO.BOARD)
GPIO.setup(POWER_BUTTOM_DISABLED, GPIO.OUT)
GPIO.setup(DATA_ENABLE, GPIO.OUT)
GPIO.setup(POWER_BUTTOM_ENABLED, GPIO.OUT)
GPIO.output(POWER_BUTTOM_DISABLED, GPIO.HIGH)
GPIO.output(DATA_ENABLE, GPIO.HIGH)
time.sleep(1)
GPIO.output(POWER_BUTTOM_DISABLED, GPIO.LOW)
GPIO.output(DATA_ENABLE, GPIO.HIGH)
GPIO.output(POWER_BUTTOM_ENABLED, GPIO.HIGH)
comando = "ps -ef | grep VentiApp"
estado = str(subprocess.getoutput(comando)).split('\n')
est = 0
for i in range(0,len(estado)):
if not "grep" in estado[i]:
est = 1
#print est
if est == 0:
comando1 = "sudo nice -n-20 ./VentiApp"
subprocess.getoutput(comando1)
# os.system("sudo python /home/pi/VentiApp/scripts/shutdownbuttons.py &")