3 # Copyright © 2018-2019 AT&T Intellectual Property.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 from pathlib import Path, PurePath
23 class ScriptExecutorConfiguration:
25 def __init__(self, file_path: str):
26 self.logger = logging.getLogger(self.__class__.__name__)
27 self.logger.info('loading configuration file : {}'.format(file_path))
28 self.config = configparser.ConfigParser(os.environ)
29 self.config.read(file_path, encoding='utf-8')
31 def get_section(self, section_name: str):
32 return self.config[section_name]
34 def get_property(self, section_name: str, property_name: str):
35 return self.config.get(section_name, property_name)
37 def script_executor_property(self, property_name: str):
38 return self.config.get('scriptExecutor', property_name)
40 def blueprints_processor(self, property_name: str):
41 return self.config.get('blueprintsprocessor', property_name)
44 if __name__ == '__main__':
45 default_configuration_file = str(PurePath(Path().absolute(), "../../configuration.ini"))
46 supplied_configuration_file = os.environ.get('CONFIGURATION')
47 config_file = str(os.path.expanduser(Path(supplied_configuration_file or default_configuration_file)))
48 scriptExecutorConfiguration = ScriptExecutorConfiguration(config_file)
49 blueprintDeployPath = scriptExecutorConfiguration.get_property('blueprintsprocessor', 'blueprintDeployPath')
50 print(blueprintDeployPath)