|
7 | 7 | using redis.
|
8 | 8 | """
|
9 | 9 |
|
10 |
| -import RPi.GPIO as GPIO |
11 |
| -import threading |
12 | 10 | import datetime
|
| 11 | +import json |
13 | 12 | import socket
|
14 |
| -import redis |
| 13 | +# import RPi.GPIO as GPIO |
| 14 | +import threading |
15 | 15 | import time
|
16 |
| -import json |
17 |
| -import sys |
18 | 16 |
|
19 |
| -# TODO: This might not be needed and could be deleted |
20 |
| -sys.path.append('..') |
| 17 | +import redis |
| 18 | + |
| 19 | +import constants |
21 | 20 | from action import Action
|
22 |
| -from config_load import load_config_json |
23 | 21 | from server.mudpi_server import MudpiServer
|
24 |
| -from workers.linux.lcd_worker import LcdWorker |
| 22 | +from utils import load_config_json |
| 23 | +from workers.linux.camera_worker import CameraWorker |
| 24 | +from workers.linux.control_worker import PiControlWorker |
25 | 25 | from workers.linux.i2c_worker import PiI2CWorker
|
| 26 | +from workers.linux.lcd_worker import LcdWorker |
26 | 27 | from workers.linux.relay_worker import RelayWorker
|
27 |
| -from workers.linux.camera_worker import CameraWorker |
28 | 28 | from workers.linux.sensor_worker import PiSensorWorker
|
29 |
| -from workers.linux.control_worker import PiControlWorker |
30 |
| -from workers.trigger_worker import TriggerWorker |
31 | 29 | from workers.sequence_worker import SequenceWorker
|
| 30 | +from workers.trigger_worker import TriggerWorker |
| 31 | + |
32 | 32 | try:
|
33 | 33 | from workers.arduino.arduino_worker import ArduinoWorker
|
| 34 | + |
34 | 35 | NANPY_ENABLED = True
|
35 | 36 | except ImportError:
|
36 | 37 | NANPY_ENABLED = False
|
| 38 | + |
37 | 39 | try:
|
38 | 40 | from workers.adc_worker import ADCMCP3008Worker
|
| 41 | + |
39 | 42 | MCP_ENABLED = True
|
40 |
| -except ImportError: |
| 43 | +except (ImportError, AttributeError): |
41 | 44 | MCP_ENABLED = False
|
42 | 45 |
|
43 | 46 | from logger.Logger import Logger, LOG_LEVEL
|
44 |
| -import variables |
45 | 47 |
|
46 |
| -CONFIGS = {} |
| 48 | + |
47 | 49 | PROGRAM_RUNNING = True
|
48 | 50 | threads = []
|
49 | 51 | actions = {}
|
|
58 | 60 |
|
59 | 61 | print(chr(27) + "[2J")
|
60 | 62 | print('Loading MudPi Configs...\r', end="", flush=True)
|
61 |
| -CONFIGS = load_config_json() |
| 63 | + |
| 64 | +try: |
| 65 | + CONFIGS = load_config_json() |
| 66 | +except FileNotFoundError: |
| 67 | + print( |
| 68 | + f'{constants.RED_BACK}There is no configuration file present on the ' |
| 69 | + f'filesystem{constants.RESET}\n\r' |
| 70 | + ) |
| 71 | + exit(1) |
| 72 | + |
62 | 73 | # Singleton redis to prevent connection conflicts
|
63 | 74 | try:
|
64 | 75 | r = redis.Redis(host=CONFIGS['redis'].get('host', '127.0.0.1'),
|
|
112 | 123 |
|
113 | 124 | try:
|
114 | 125 | print('Initializing Garden Control \r', end="", flush=True)
|
115 |
| - GPIO.setwarnings(False) |
116 |
| - GPIO.setmode(GPIO.BCM) |
117 |
| - GPIO.cleanup() |
118 |
| - # Pause for GPIO to finish |
119 | 126 | time.sleep(0.1)
|
120 | 127 | Logger.log(
|
121 | 128 | LOG_LEVEL["info"],
|
|
278 | 285 | Logger.log(
|
279 | 286 | LOG_LEVEL["info"],
|
280 | 287 | '{0} Actions...\t\t\t\t\033[1;32m Initializing\033[0;0m'.format(
|
281 |
| - len(CONFIGS['actions']))) |
| 288 | + len(CONFIGS['actions'])) |
| 289 | + ) |
282 | 290 | except KeyError:
|
283 |
| - Logger.log(LOG_LEVEL["info"], |
284 |
| - 'Actions...\t\t\t\t\033[1;31m Disabled\033[0;0m') |
| 291 | + Logger.log( |
| 292 | + LOG_LEVEL["info"], |
| 293 | + 'Actions...\t\t\t\t\033[1;31m Disabled\033[0;0m' |
| 294 | + ) |
285 | 295 |
|
286 | 296 | # Worker for Sequences
|
287 | 297 | try:
|
|
0 commit comments