From 5d88d4e51651e96ae96b6a4a84722710bcd8c6d3 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 20 Dec 2022 13:37:17 +0100 Subject: [PATCH] remove script --- scripts/create_new_hid.py | 54 --------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 scripts/create_new_hid.py diff --git a/scripts/create_new_hid.py b/scripts/create_new_hid.py deleted file mode 100644 index 3e9ff4ff..00000000 --- a/scripts/create_new_hid.py +++ /dev/null @@ -1,54 +0,0 @@ -import json -import sys - -from ereuse_devicehub.db import db -from ereuse_devicehub.devicehub import Devicehub -from ereuse_devicehub.resources.action.models import Snapshot - - -def open_snapshot(): - path = sys.argv[2] - f = open(path) - txt = f.read() - return json.loads(txt) - - -def get_family(snapshot): - debug = snapshot.get('debug', {}) - lshw = debug.get('lshw', {}) - return lshw.get('configuration', {}).get('family', '') - - -def get_device(uuid): - snapshot = Snapshot.query.filter_by(uuid=uuid).first() - if snapshot: - return snapshot.device - - -def main(): - schema = sys.argv[1] - app = Devicehub(inventory=schema) - app.app_context().push() - snapshot = open_snapshot() - uuid = snapshot.get('uuid') - if not uuid: - return - family = get_family(snapshot) - device = get_device(uuid) - if not device: - return - device.family = family - device.set_hid() - for c in device.components: - c.set_hid() - - if device.binding: - device.binding.device.family = family - device.binding.device.set_hid() - for c in device.binding.device.components: - c.set_hid() - db.session.commit() - - -if __name__ == '__main__': - main()