USB-AIO für automatische Geräteprüfung
Some checks failed
Tests / test (push) Has been cancelled

This commit is contained in:
2026-10-14 20:14:36 +02:00
commit 81f06cf6b4
40 changed files with 9956 additions and 0 deletions

17
scripts/db-import.py Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env python3
import argparse, datetime, json, pathlib, sqlite3
parser=argparse.ArgumentParser()
parser.add_argument('database', type=pathlib.Path)
parser.add_argument('report', type=pathlib.Path)
args=parser.parse_args()
report=json.loads(args.report.read_text(encoding='utf-8'))
asset=report['asset_id']
if not isinstance(asset,str) or not asset or len(asset)>64: raise ValueError('Invalid asset ID')
args.database.parent.mkdir(parents=True,exist_ok=True)
with sqlite3.connect(args.database,timeout=30) as db:
db.execute('PRAGMA journal_mode=DELETE')
db.execute('PRAGMA synchronous=FULL')
db.execute('CREATE TABLE IF NOT EXISTS scans (scan_id INTEGER PRIMARY KEY, asset_id TEXT NOT NULL, scanned_at_unix INTEGER, imported_at_utc TEXT NOT NULL, tool_version TEXT, model TEXT, cpu TEXT, health_gate TEXT, json TEXT NOT NULL)')
db.execute('CREATE INDEX IF NOT EXISTS scans_asset ON scans(asset_id,scan_id DESC)')
db.execute('INSERT INTO scans(asset_id,scanned_at_unix,imported_at_utc,tool_version,model,cpu,health_gate,json) VALUES(?,?,?,?,?,?,?,?)', (asset,report.get('timestamp_unix'),datetime.datetime.now(datetime.timezone.utc).isoformat(),report.get('tool_version'),report.get('model'),report.get('cpu'),report.get('health_gate'),json.dumps(report,separators=(',',':'))))
print('Recorded',asset,'in',args.database)