diff --git a/send/generic_gen b/send/generic_gen new file mode 100644 index 00000000..39d0d56a --- /dev/null +++ b/send/generic_gen @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +import sys + +import generic_sender +import send_lib + +send_lib.check_input_fields(sys.argv, generic_script=True) + +facility = sys.argv[1] +destination = sys.argv[2] +destination_type = sys.argv[3] +service_name = sys.argv[4] + +generic_sender.send(service_name, facility, destination, destination_type) diff --git a/send/send_lib.py b/send/send_lib.py index 4a75bc39..e14cd039 100644 --- a/send/send_lib.py +++ b/send/send_lib.py @@ -65,13 +65,20 @@ def __exit__(self, exc_type, exc_val, exc_tb): os.close(self.dir_fd) -def check_input_fields(args: list[str], destination_type_required: bool = False) -> None: +def check_input_fields(args: list[str], destination_type_required: bool = False, generic_script: bool = False) -> None: """ Checks input script parameters are present (facility name, destination, (optional) destination type). Dies if parameters mismatch. + :param generic_script: True if calling script is generic (and includes the service name argument) :param destination_type_required: True if destination type is required, default is False :param args: parameters passed to script (sys.argv) """ + + if generic_script: + if len(args) != 5: + # Destination type gets passed by the engine every time so this shouldn't be an issue + die_with_error("Error: Expected number of arguments is 4 (FACILITY_NAME, DESTINATION, DESTINATION_TYPE and SERVICE_NAME)") + if len(args) != 4: if destination_type_required: die_with_error("Error: Expected number of arguments is 3 (FACILITY_NAME, DESTINATION and DESTINATION_TYPE)")