refactor: Externalize host configuration to hosts.json
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"http": [
|
||||||
|
"tanner.vc",
|
||||||
|
"forum.protospace.ca",
|
||||||
|
"protospace.ca",
|
||||||
|
"my.protospace.ca"
|
||||||
|
],
|
||||||
|
"mqtt": [
|
||||||
|
"webhost.protospace.ca"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
18
main.py
18
main.py
@@ -8,20 +8,16 @@ import asyncio
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import aiomqtt
|
import aiomqtt
|
||||||
import ssl
|
import ssl
|
||||||
|
import json
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
|
||||||
HOSTS = {
|
try:
|
||||||
'http': [
|
with open('hosts.json', 'r') as f:
|
||||||
'tanner.vc',
|
HOSTS = json.load(f)
|
||||||
'forum.protospace.ca',
|
except FileNotFoundError:
|
||||||
'protospace.ca',
|
logging.error("hosts.json not found. Please copy hosts.json.example to hosts.json and configure it.")
|
||||||
'my.protospace.ca',
|
exit(1)
|
||||||
],
|
|
||||||
'mqtt': [
|
|
||||||
'webhost.protospace.ca',
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def alert_tanner(msg):
|
def alert_tanner(msg):
|
||||||
|
|||||||
Reference in New Issue
Block a user