forked from asmbly-makerspace/NeonIntegrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenPathUpdateSingle.py
More file actions
40 lines (34 loc) · 1.71 KB
/
openPathUpdateSingle.py
File metadata and controls
40 lines (34 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
###############################################################################
#Fetch all member records from Neon and update OpenPath as necessary for all
#* Run me at least once a day to catch subscription expirations
import neonUtil
import openPathUtil
import logging
import sys
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
def openPathUpdateSingle(neonID):
account = neonUtil.getMemberById(neonID)
if account.get("OpenPathID"):
openPathUtil.updateGroups(account)
#note that this isn't necessarily 100% accurate, because we have Neon users with provisioned OpenPath IDs and no access groups
#assuming that typical users who gained and lost openPath access have a signed waiver
elif neonUtil.accountHasFacilityAccess(account):
account = openPathUtil.createUser(account)
openPathUtil.updateGroups(account, openPathGroups=[]) #pass empty groups list to skip the http get
openPathUtil.createMobileCredential(account)
elif account.get("validMembership"):
if not account.get("WaiverDate"):
logging.info(f'''{account.get("fullName")} ({account.get("Email 1")} is missing the Waiver''')
if not account.get("FacilityTourDate"):
logging.info(f'''{account.get("fullName")} ({account.get("Email 1")} is missing the Facility Tour''')
#begin standalone script functionality -- update single account provided on command line
def main():
if len(sys.argv) != 2 or not str(sys.argv[1]).isnumeric():
print(f'''Usage: {sys.argv[0]} <integer NeonID>''')
else:
openPathUpdateSingle(str(sys.argv[1]))
if __name__ == "__main__":
main()