Vlad Efanov
02/14/2022, 9:52 PM[CONSTANTS]
script_path = ..\..\scripts\mp.py
exe_file_path = ..\..\scripts\mp.exe
new_videos_directory_path = ..\..\video_files\new
in_process_videos_directory_path = ..\..\video_files\in_process
finished_videos_directory_path = ..\..\video_files\finished
Config class
import os
from configparser import ConfigParser
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
class MsaConfig(metaclass=Singleton):
config_object = ConfigParser()
default_group_name = "CONSTANTS"
default_configuration_file_path = f'{os.path.dirname(__file__)}/MSA_orchestrator_config.ini'
print(f'Constructor config_object is: {config_object}')
def configuration_extractor(self, group_name=default_group_name,
configuration_file_path=default_configuration_file_path):
self.config_object.read(configuration_file_path)
if group_name not in self.config_object:
raise "Default group name is not provided"
return self.config_object[group_name]
Code in the sensor that implements the class:
msa_config_object = MsaConfig()
constants = msa_config_object.configuration_extractor()
owen
02/14/2022, 10:44 PMVlad Efanov
02/14/2022, 11:58 PMowen
02/15/2022, 12:24 AMAlex Service
02/15/2022, 2:18 PM