2024-05-19 22:38:21 +08:00
|
|
|
import os
|
|
|
|
|
import time
|
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
|
|
from controller.client import FanController
|
|
|
|
|
from controller.logger import logger
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
host = os.getenv('HOST')
|
|
|
|
|
username = os.getenv('USERNAME')
|
|
|
|
|
password = os.getenv('PASSWORD')
|
|
|
|
|
|
|
|
|
|
if host is None:
|
2025-06-08 12:50:52 +08:00
|
|
|
raise RuntimeError('HOST 环境变量未设置')
|
2024-05-19 22:38:21 +08:00
|
|
|
|
|
|
|
|
if username is None:
|
2025-06-08 12:50:52 +08:00
|
|
|
raise RuntimeError('USERNAME 环境变量未设置')
|
2024-05-19 22:38:21 +08:00
|
|
|
|
|
|
|
|
if password is None:
|
2025-06-08 12:50:52 +08:00
|
|
|
raise RuntimeError('PASSWORD 环境变量未设置')
|
2024-05-19 22:38:21 +08:00
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
client = FanController(host=host, username=username, password=password)
|
|
|
|
|
client.run()
|
|
|
|
|
time.sleep(60)
|
|
|
|
|
except Exception as err:
|
|
|
|
|
logger.error(
|
2025-06-08 12:50:52 +08:00
|
|
|
f'运行控制器失败 {err}. {traceback.format_exc()}'
|
2024-05-19 22:38:21 +08:00
|
|
|
)
|