Skip to content

Commit

Permalink
Check if target group is found
Browse files Browse the repository at this point in the history
  • Loading branch information
edeno committed Sep 29, 2023
1 parent 7497a86 commit 891abf8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions config/add_dj_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import tempfile

target_group = "kachery-users"
TARGET_GROUP = "kachery-users"


def add_module(module_name):
Expand All @@ -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(
Expand Down

0 comments on commit 891abf8

Please sign in to comment.