Cleaned up and minmized Chubb's CISA script to share with the client so they can run it on their own

This commit is contained in:
Norm Rasmussen
2025-09-26 14:49:46 -04:00
parent 29d3db5c20
commit 06553b93c3
2 changed files with 178 additions and 6 deletions

View File

@ -24,11 +24,12 @@ def bulk_invite_and_group():
This function looks for the group in the CSV as well.
"""
df = pd.DataFrame()
data = pd.read_csv(IMPORTFILE)
groups = data["Group"].unique()
groups = list(groups)
print("Here are all groups within the CSV:")
print(groups)
print(" ")
for group in groups:
payload = ""
print(group)
@ -89,12 +90,11 @@ def add_props_from_func(people, data, group):
]
}
propresponse = requests.post(prop_url, json=payload, headers=HEADERS)
print(propresponse.status_code)
if propresponse.status_code != 200:
error_tupe = (learner_uuid, learner_email, agname)
errorlist.append(error_tupe)
else:
print(f"Looks like {learner_email} and {agname} was successful.")
print(f"Looks like {learner_email} and {agname} was successful. Received status code: {propresponse.status_code}.")
except (TypeError, IndexError) as e:
error_tupe = (0, learner_email, agency_name)
errorlist.append(error_tupe)
@ -106,18 +106,15 @@ def add_props_from_func(people, data, group):
def add_props_from_csv():
errorlist = []
df = pd.DataFrame()
data = pd.read_csv(IMPORTFILE)
for dat in data.iterrows():
agency_name = dat[1][3]
# agency_name = "EMPLOYEE"
learner_email = dat[1][2]
# print(learner_email)
ppl_search = f"{BASEURL}people?filter[email][eq]={learner_email}"
ppl_response = requests.get(ppl_search, headers=HEADERS)
try:
ppl_data = ppl_response.json()
nextlink = ppl_data["links"]
learner_uuid = ppl_data["data"][0]["id"]
# Now update the props