eive-obsw/generators/gen.py
Robin Mueller 417969fcec
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
always generate host files now as well
2023-02-09 15:58:41 +01:00

73 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
import logging
import sys
import colorlog
from colorlog import ColoredFormatter
from definitions import BspType
from objects.objects import parse_objects
from events.event_parser import parse_events
from returnvalues.returnvalues_parser import parse_returnvalues
from fsfwgen.core import (
return_generic_args_parser,
init_printout,
)
_LOGGER = logging.getLogger()
def main():
set_up_logger()
init_printout(project_string="EIVE")
parser = return_generic_args_parser()
args = parser.parse_args()
parse_handling_for_bsp(args.type, BspType.BSP_HOSTED)
parse_handling_for_bsp(args.type, BspType.BSP_Q7S)
def set_up_logger():
handler = colorlog.StreamHandler(stream=sys.stdout)
formatter = ColoredFormatter(
"%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s",
datefmt=None,
reset=True,
log_colors={
"DEBUG": "cyan",
"INFO": "green",
"WARNING": "yellow",
"ERROR": "red",
"CRITICAL": "red,bg_white",
},
secondary_log_colors={},
style="%",
)
handler.setFormatter(formatter)
_LOGGER.addHandler(handler)
_LOGGER.setLevel(logging.INFO)
def parse_handling_for_bsp(type_arg: str, bsp_select: BspType):
if bsp_select == BspType.BSP_Q7S:
copy_to_eive_tmtc = True
else:
copy_to_eive_tmtc = False
if type_arg == "objects":
_LOGGER.info(f"Generating objects data")
parse_objects(bsp_select, copy_to_eive_tmtc)
elif type_arg == "events":
_LOGGER.info(f"Generating event data")
parse_events(bsp_select, True, True, copy_to_eive_tmtc)
elif type_arg == "returnvalues":
_LOGGER.info("Generating returnvalue data")
parse_returnvalues(bsp_select, copy_to_eive_tmtc)
elif type_arg == "all":
_LOGGER.info("Generating all data")
parse_objects(bsp_select, copy_to_eive_tmtc)
parse_events(bsp_select, True, True, copy_to_eive_tmtc)
parse_returnvalues(bsp_select, copy_to_eive_tmtc)
if __name__ == "__main__":
main()