added code to initialize db with models and recodres

This commit is contained in:
Tobias Kurze
2019-11-20 12:41:05 +01:00
parent bc1347fe99
commit 60ff5bdeaf
20 changed files with 1658 additions and 136 deletions

View File

@@ -14,10 +14,7 @@ from sqlalchemy import and_
from backend import db
from backend.models.recorder_model import RecorderModel, RecorderCommand
from backend.recorder_adapters import get_defined_recorder_adapters
def calculate_md5_checksum(string_to_md5_sum: str):
return hashlib.md5(string_to_md5_sum.encode('utf-8')).hexdigest()
from backend.tools.helpers import calculate_md5_checksum
def create_recorder_commands_for_recorder_adapter(command_definitions: dict, recorder_model: RecorderModel):
@@ -61,9 +58,9 @@ def update_recorder_models_database():
else:
if not model_checksum == r_m.checksum:
r_m.model_name = r_a["name"]
r_m.model_name = r_a["name"]
r_m.last_time_modified = datetime.utcnow()
r_m.checksum = model_checksum
create_recorder_commands_for_recorder_adapter(r_a["commands"], r_m)
create_recorder_commands_for_recorder_adapter(r_a["commands"], r_m)
db.session.commit()