Skip to content

Commit

Permalink
feat(generic_gen): send script for generic_gen
Browse files Browse the repository at this point in the history
* added send script for generic_gen
* the send script expects destination type every time (this should always get passed by the engine anyway)
  • Loading branch information
xflord committed Oct 18, 2023
1 parent 15905e1 commit c6f5d25
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions send/generic_gen
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 8 additions & 1 deletion send/send_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down

0 comments on commit c6f5d25

Please sign in to comment.