safesight-control/scripts/deploy/register-face-gallery.py
tian 24b9400767 feat: 离线部署包一体化,启动自动导入种子数据,人脸库构建流程修复
- package.sh: 打包包含 configs 种子数据、tools 构建工具、deps 离线依赖、scripts 辅助脚本
- ImportSeedAssets: 首次启动检测空库自动导入 templates/profiles/overlays
- face_gallery.html: 添加构建人脸库按钮
- device.html: 无标准配置时显示设备实际模型/资源,无人脸库配置时隐藏按钮
- register-face-gallery.py: 手动注册已构建人脸库到 standard_resources
- deployment.md: 更新部署流程反映新包结构
- .gitignore: 排除 *.tar.gz 构建产物
2026-07-23 17:57:47 +08:00

18 lines
694 B
Python

#!/usr/bin/env python3
import sqlite3, hashlib, os
db = '/opt/safesightd/data/app.db'
fg = '/opt/safesightd/resources/standard_resources/face_gallery/face_gallery.db'
sha = hashlib.sha256(open(fg, 'rb').read()).hexdigest()
size = os.path.getsize(fg)
conn = sqlite3.connect(db)
conn.execute(
"INSERT OR REPLACE INTO standard_resources(name,resource_type,version,sha256,size_bytes,description,file_path,created_at,updated_at) VALUES(?,?,?,?,?,?,?,datetime('now'),datetime('now'))",
('face_gallery', 'face_gallery', 'v1', sha, size, '人脸库', 'resources/standard_resources/face_gallery/face_gallery.db'),
)
conn.commit()
conn.close()
print('OK sha256=' + sha + ' size=' + str(size))