-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlauncher_curiosityRover.py
47 lines (35 loc) · 1.48 KB
/
launcher_curiosityRover.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
43
44
45
46
import subprocess
import threading
import time
from datetime import datetime, timedelta
# Weilong & Pradosh main contribution
# This is for Curiosity rover
def run_script(script_path):
try:
print(f"Running {script_path}")
process = subprocess.Popen(["/usr/bin/python3", script_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode != 0:
print(f"Error running {script_path}: {stderr.decode('utf-8')}")
else:
print(f"Output from {script_path}: {stdout.decode('utf-8')}")
except Exception as e:
print(f"Exception occurred: {e}")
def calculate_seconds_until_midnight():
now = datetime.now()
midnight = datetime(now.year, now.month, now.day, 0, 0, 0)
if now > midnight:
midnight = midnight + timedelta(days=1)
return (midnight - now).total_seconds()
# List of scripts to launch
scripts = ["colour.py", "gps.py", "oxygen.py", "radiation.py", "temperature.py", "cpu_temperature.py", "humidity.py", "light_intensity.py", "sound.py"]
print("Launching scripts...")
# Start each script in a separate thread
for script in scripts:
thread = threading.Thread(target=run_script, args=("/users/pgrad/zhangj20/group24/" + script,))
thread.start()
# Join threads to prevent the program from exiting immediately
for thread in threading.enumerate():
if thread != threading.current_thread():
thread.join()
print("All scripts have completed.")