Fix: Run both sonar and clm scans in parallel
[ccsdk/cds.git] / ms / py-executor / blueprints_grpc / script_executor_configuration.py
1 #!/usr/bin/python
2 #
3 #  Copyright © 2018-2019 AT&T Intellectual Property.
4 #
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
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 import os
18 import logging
19 import configparser
20 from pathlib import Path, PurePath
21
22
23 class ScriptExecutorConfiguration:
24
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')
30
31     def get_section(self, section_name: str):
32         return self.config[section_name]
33
34     def get_property(self, section_name: str, property_name: str):
35         return self.config.get(section_name, property_name)
36
37     def script_executor_property(self, property_name: str):
38         return self.config.get('scriptExecutor', property_name)
39
40     def blueprints_processor(self, property_name: str):
41         return self.config.get('blueprintsprocessor', property_name)
42
43
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)