-
Notifications
You must be signed in to change notification settings - Fork 5
/
platform-input-support.py
executable file
·55 lines (44 loc) · 1.67 KB
/
platform-input-support.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Custom modules
import logging.config
import sys
# Custom modules
from modules import cfg
from manifest import get_manifest_service
from modules.common.YAMLReader import YAMLReader
from modules.RetrieveResource import RetrieveResource
logger = logging.getLogger(__name__)
class PISRunnerException(Exception):
"""Platform input support exception"""
def print_list_steps(keys_list):
""" Lists of the steps available defined inside the config yaml file. """
keys_list.remove("config")
list_steps = '\n\t'.join(keys_list)
list_steps = 'List of steps available:\n\t' + list_steps
print(list_steps)
# This procedure reads the config file and the args and runs the plugins requested.
def main():
logger.debug("Setting up configuration parser")
cfg.setup_parser()
logger.debug("Get command line arguments")
args = cfg.get_args()
logger.debug("Prepare YAML reader for configuration file")
try:
yaml = YAMLReader(args.config)
logger.debug("Read configuration file")
yaml_dict = yaml.read_yaml()
print_list_steps(yaml.get_list_keys())
except YAMLReaderException as err:
message = f"When trying to read the YAML config, the following error occurred '{err}'"
logger.error(message)
raise PISRunnerException(message) from err
cfg.set_up_logging(args)
# Resources retriever
resources = RetrieveResource(args, yaml_dict)
# Session's Manifest
manifest_config = yaml_dict
manifest_config.update({"output_dir": resources.output_dir_prod})
# Initialize the manifest service
_ = get_manifest_service(args, manifest_config)
resources.run()
if __name__ == '__main__':
main()