eive-obsw/generators/gen.py

73 lines
2.1 KiB
Python
Raw Normal View History

2021-08-02 11:43:49 +02:00
#!/usr/bin/env python3
2023-02-09 15:14:21 +01:00
import logging
2023-02-09 15:51:36 +01:00
import sys
import colorlog
from colorlog import ColoredFormatter
2021-08-02 11:43:49 +02:00
2023-02-09 15:14:21 +01:00
from definitions import BspType
2021-08-02 11:43:49 +02:00
from objects.objects import parse_objects
from events.event_parser import parse_events
from returnvalues.returnvalues_parser import parse_returnvalues
2022-03-01 18:03:50 +01:00
from fsfwgen.core import (
return_generic_args_parser,
init_printout,
)
2022-06-21 01:02:00 +02:00
2023-02-09 15:51:36 +01:00
_LOGGER = logging.getLogger()
2021-08-02 11:43:49 +02:00
def main():
2023-02-09 15:51:36 +01:00
set_up_logger()
2022-03-01 18:03:50 +01:00
init_printout(project_string="EIVE")
2021-08-02 11:43:49 +02:00
parser = return_generic_args_parser()
args = parser.parse_args()
2023-02-09 15:58:41 +01:00
parse_handling_for_bsp(args.type, BspType.BSP_HOSTED)
2023-02-09 15:51:36 +01:00
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={
2023-02-09 15:58:41 +01:00
"DEBUG": "cyan",
"INFO": "green",
"WARNING": "yellow",
"ERROR": "red",
"CRITICAL": "red,bg_white",
2023-02-09 15:51:36 +01:00
},
secondary_log_colors={},
2023-02-09 15:58:41 +01:00
style="%",
2023-02-09 15:51:36 +01:00
)
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":
2023-02-09 15:14:21 +01:00
_LOGGER.info(f"Generating objects data")
2023-02-09 15:51:36 +01:00
parse_objects(bsp_select, copy_to_eive_tmtc)
elif type_arg == "events":
2023-02-09 15:14:21 +01:00
_LOGGER.info(f"Generating event data")
2023-02-09 15:51:36 +01:00
parse_events(bsp_select, True, True, copy_to_eive_tmtc)
elif type_arg == "returnvalues":
2023-02-09 15:14:21 +01:00
_LOGGER.info("Generating returnvalue data")
2023-02-09 15:58:41 +01:00
parse_returnvalues(bsp_select, copy_to_eive_tmtc)
2023-02-09 15:51:36 +01:00
elif type_arg == "all":
2023-02-09 15:14:21 +01:00
_LOGGER.info("Generating all data")
2023-02-09 15:51:36 +01:00
parse_objects(bsp_select, copy_to_eive_tmtc)
parse_events(bsp_select, True, True, copy_to_eive_tmtc)
2023-02-09 15:58:41 +01:00
parse_returnvalues(bsp_select, copy_to_eive_tmtc)
2021-08-02 11:43:49 +02:00
if __name__ == "__main__":
main()