Files
eink-push/main.py
2026-06-29 09:43:20 +08:00

38 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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()