-
Notifications
You must be signed in to change notification settings - Fork 4
/
android.py
executable file
·43 lines (30 loc) · 1.22 KB
/
android.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
#!/usr/bin/env python3
import os
import signal
import sys
from core.system import System
from openadms import (exception_hook, get_args, main, setup_logging,
setup_thread_exception_hook, sighup_handler,
sigint_handler, start_mqtt_message_broker)
CONFIG_FILE_PATH = './config/examples/virtual.json'
if __name__ == '__main__':
# Change current directory.
os.chdir(os.path.dirname(__file__))
# Add OpenADMS directory to the Python system path.
sys.path.append(System.get_root_dir())
# Set the hook for unhandled exceptions.
setup_thread_exception_hook()
sys.excepthook = exception_hook
# Use signal handlers to quit gracefully on SIGINT and to restart on SIGHUP.
signal.signal(signal.SIGINT, sigint_handler)
signal.signal(signal.SIGHUP, sighup_handler)
# Get command-line arguments.
args = get_args()
args.config_file_path = CONFIG_FILE_PATH
args.is_debug = True
# Initialise the logger.
setup_logging(args.is_quiet, args.is_debug, args.verbosity, args.log_file)
# Use internal MQTT message broker (HBMQTT).
start_mqtt_message_broker(args.host, args.port)
# Start the monitoring.
main(args.config_file_path)