diff --git a/config/add_dj_module.py b/config/add_dj_module.py index d5e24e793..78213f8ee 100644 --- a/config/add_dj_module.py +++ b/config/add_dj_module.py @@ -4,7 +4,7 @@ import sys import tempfile -target_group = "kachery-users" +TARGET_GROUP = "kachery-users" def add_module(module_name): @@ -15,10 +15,16 @@ def add_module(module_name): # find the kachery-users group groups = grp.getgrall() + group_found = False # initialize the flag as False for group in groups: - if group.gr_name == target_group: + if group.gr_name == TARGET_GROUP: + group_found = True # set the flag to True when the group is found break + # Check if the group was found + if not group_found: + sys.exit(f"Error: The target group {TARGET_GROUP} was not found.") + # get a list of usernames for user in group.gr_mem: file.write(