forked from malvern-code-club/auqa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.py
53 lines (40 loc) · 1.45 KB
/
start.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
47
48
49
50
51
52
53
# import the colorama library
import os
from sys import path as syspath
syspath.append(os.path.join(os.path.dirname(__file__), "./lib/colorama"))
from colorama import init, Fore, Back, Style # to change console colours
init() # init colorama
os.environ["TEST"] = "n" # Run Normall
try:
from sense_hat import SenseHat
except ModuleNotFoundError:
print(Fore.RED + Style.BRIGHT + " [!] The Sense Hat module is not installed. Starting in testing mode...")
os.environ["TEST"] = "y" # Run in Test Mode
import signal
import time
import threading # to run each module simultaneously
# show plant system ascii art text
print(Fore.GREEN + Style.BRIGHT + " _ ")
print(Fore.GREEN + Style.BRIGHT + " /_\ _ _ __ _ __ _ ")
print(Fore.GREEN + Style.BRIGHT + " / _ \ || / _` / _` | ")
print(Fore.GREEN + Style.BRIGHT + " /_/ \_\_,_\__, \__,_| ")
print(Fore.GREEN + Style.BRIGHT + " |_| ")
# reset colours
print(Style.RESET_ALL)
# import dashboard and sense modules
import dashboard
import sense
# make the dashboard and sense threads
sensethread = threading.Thread(target=sense.go)
dashboardthread = threading.Thread(target=dashboard.app.run)
# start the sense thread
print(Fore.CYAN + Style.BRIGHT + " [+] Starting Sense...")
sensethread.start()
# start the dashboard thread
# wait before starting
time.sleep(5)
print(Fore.CYAN + Style.BRIGHT + " [+] Starting Web Server...")
dashboardthread.start()
# run forever
while True:
pass