-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoRunner.py
More file actions
41 lines (27 loc) · 1.2 KB
/
autoRunner.py
File metadata and controls
41 lines (27 loc) · 1.2 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
41
from imleaguesAPI import *
from datetime import datetime as dt
import datetime
from jsonManager import JsonManager
def autoRunner():
jsonManager = JsonManager()
config = jsonManager.readConfig()
for i in range(len(config['users'])):
print(f"Registering events for user: {config['users'][i]['email']}")
studentId = config['users'][i]['studentId']
todayEventIds = []
for j in range(len(config['users'][i]['eventIds'])):
startDate = datetime.date.fromisoformat(config['users'][i]['eventIds'][j]['registrationDay'])
if startDate == dt.today().date():
todayEventId = config['users'][i]['eventIds'].pop(j)
todayEventIds.append(todayEventId['eventId'])
jsonManager.writeConfig(config)
if todayEventIds:
imLeaguesAPI = ImLeaguesAPI(config['users'][i]['email'], config['users'][i]['password'], config['users'][i]['schoolId'])
for eventId in todayEventIds:
try:
print(imLeaguesAPI.registerEvent(studentId, eventId))
except EventRegistrationError as e:
print(f"Error: Event Id: {eventId} Message: {e}")
else:
print(f"No events today for user: {config['users'][i]['email']}")
autoRunner()