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:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user