init: init proj
This commit is contained in:
37
main.py
Normal file
37
main.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
入口 —— 取数据 → 渲染 → 推送到设备。
|
||||
|
||||
用法:
|
||||
python3 main.py # 渲染并推送(默认取设备列表第一个)
|
||||
python3 main.py --render-only # 只渲染生成图片,不推送(output/dashboard.png)
|
||||
|
||||
可用环境变量覆盖配置:ZECTRIX_API_KEY、ZECTRIX_DEVICE_ID
|
||||
"""
|
||||
import argparse
|
||||
|
||||
import config
|
||||
from data import get_dashboard_data
|
||||
from renderer import DashboardRenderer
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="墨水屏仪表盘:渲染并推送")
|
||||
parser.add_argument("--render-only", action="store_true", help="只渲染,不推送")
|
||||
args = parser.parse_args()
|
||||
|
||||
data = get_dashboard_data()
|
||||
path = DashboardRenderer().render_to_file(data, config.OUTPUT_PATH)
|
||||
print(f"[渲染] 已生成 {path}")
|
||||
|
||||
if args.render_only:
|
||||
return
|
||||
|
||||
from pusher import push_image
|
||||
device_id, resp = push_image(path)
|
||||
print(f"[推送] 设备 {device_id} 成功:{resp.get('data')}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user