From 47e10e88bdea9e74b5c34e01a9deda8a731bc6cb Mon Sep 17 00:00:00 2001 From: Fabian Klemm Date: Thu, 16 Nov 2023 17:56:49 +0100 Subject: [PATCH] adjust device model database init Signed-off-by: Fabian Klemm --- .../libocpp_configuration_helper.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/everest-testing/src/everest/testing/core_utils/configuration/libocpp_configuration_helper.py b/everest-testing/src/everest/testing/core_utils/configuration/libocpp_configuration_helper.py index 83cc5049..f0f4d138 100644 --- a/everest-testing/src/everest/testing/core_utils/configuration/libocpp_configuration_helper.py +++ b/everest-testing/src/everest/testing/core_utils/configuration/libocpp_configuration_helper.py @@ -1,5 +1,6 @@ import json import subprocess +import sys from abc import ABC, abstractmethod from copy import deepcopy from pathlib import Path @@ -85,7 +86,8 @@ def adjust_ocpp_configuration(self, config: dict): for network_connection_profile in network_connection_profiles: security_profile = network_connection_profile["connectionData"]["securityProfile"] protocol = "ws" if security_profile == 1 else "wss" - network_connection_profile["connectionData"]["ocppCsmsUrl"] = f"{protocol}://{self._central_system_host}:{self._central_system_port}" + network_connection_profile["connectionData"][ + "ocppCsmsUrl"] = f"{protocol}://{self._central_system_host}:{self._central_system_port}" self._set_value_in_v201_config(config, "InternalCtrlr", "NetworkConnectionProfiles", "Actual", json.dumps(network_connection_profiles)) return config @@ -118,16 +120,14 @@ def create_temporary_ocpp_configuration_db(libocpp_path: Path, device_model_schemas_path: Path, ocpp_configuration_file: Path, target_directory: Path): - wd = libocpp_path / "config/v201" - subprocess.run( - f"python3 {libocpp_path / 'config/v201/init_device_model_db.py'} --out {target_directory / 'device_model_storage.db'} --schemas {device_model_schemas_path}", - cwd=wd, - check=True, - shell=True - ) - subprocess.run( - f"python3 {libocpp_path / 'config/v201/insert_device_model_config.py'} --config {ocpp_configuration_file} --db {target_directory / 'device_model_storage.db'}", - cwd=wd, - check=True, - shell=True - ) + import_path = libocpp_path / "config/v201" + sys.path.append(str(import_path)) + from init_device_model_db import DeviceModelDatabaseInitializer + + database_file = target_directory / 'device_model_storage.db' + database_initializer = DeviceModelDatabaseInitializer(database_file) + + database_initializer.initialize_database(schemas_path=device_model_schemas_path) + database_initializer.insert_config_and_default_values( + config_file=ocpp_configuration_file, + schemas_path=device_model_schemas_path)