safesight-control/scripts/fix-use-date-prefix.py

18 lines
610 B
Python

import sqlite3, json
c = sqlite3.connect('/opt/safesightd/data/app.db')
row = c.execute("SELECT body_json FROM templates WHERE name='workshop_face_recognition_shoe_alarm'").fetchone()
body = json.loads(row[0])
for n in body['template']['nodes']:
if n.get('type') == 'alarm':
for key in ['snapshot', 'clip']:
if key in n.get('actions', {}):
n['actions'][key]['use_date_prefix'] = False
c.execute("UPDATE templates SET body_json=? WHERE name=?",
(json.dumps(body, ensure_ascii=False), 'workshop_face_recognition_shoe_alarm'))
c.commit()
c.close()
print('OK')