-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloudProcess.py
More file actions
71 lines (62 loc) · 2.41 KB
/
cloudProcess.py
File metadata and controls
71 lines (62 loc) · 2.41 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /etc/bin/python
import os, time, subprocess, re
def indProc():
arr=[]
p=subprocess.Popen(['ps -aux | grep CloudCam.py'],shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
q=p.stdout.readlines()
run_cam=False
for x,f in enumerate(q):
u=f.split()
if re.search('/home/cloudcam/CloudCamera/CloudCam.py', u[11]):
run_cam=True
p=subprocess.Popen(['ps -aux | grep wiggleCloud.py'],shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
q=p.stdout.readlines()
run_gif=False
for x,f in enumerate(q):
u=f.split()
if re.search('/home/cloudcam/CloudCamera/wiggleCloud.py', u[11]):
run_gif=True
p=subprocess.Popen(['ps -aux | grep clouduino_interface.py'],shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
q=p.stdout.readlines()
run_rain=False
for x,f in enumerate(q):
u=f.split()
if re.search('/home/cloudcam/CloudCamera/clouduino_interface.py', u[11]):
run_rain=True
return [run_cam,run_gif,run_rain]
def startProc(camStart = False, gifStart = False, rainStart = False):
if camStart:
print 'starting cloud cam'
os.system('nohup python /home/cloudcam/CloudCamera/CloudCam.py &')
if gifStart:
print 'starting gif'
os.system('nohup python /home/cloudcam/CloudCamera/wiggleCloud.py &')
if rainStart:
print 'starting Rain Sensors'
os.system('nohup python /home/cloudcam/CloudCamera/clouduino_interface.py &')
return
if __name__ == "__main__":
x=0
y=0
while True:
arrProc=indProc()
if x==5 and not arrProc[1]:
print 'starting wiggle'
startProc(False, True, False)
x=0
if y==5:
print 'running rsync'
p1 = subprocess.Popen(['rsync -azrh --progress --remove-source-files /home/cloudcam/CloudCamera/images/ analysis:/raid/CloudCamera/fits/'], stdout=subprocess.PIPE, shell=True)
#print p1.stdout.read()
p2 = subprocess.Popen(['rsync -azrh --progress --remove-source-files /home/cloudcam/CloudCamera/analyzed/ analysis:/raid/CloudCamera/'], stdout=subprocess.PIPE, shell=True)
#print p2.stdout.read()
y=0
if not arrProc[0]:
print 'start cloudcam'
startProc(True, False)
if not arrProc[2]:
print 'starting clouduino_interface.py'
startProc(False, False, True)
x = x + 1
y = y + 1
time.sleep(60)