mirror of
				https://github.com/AquaMorph/dotfiles.git
				synced 2025-11-03 17:03:18 +00:00 
			
		
		
		
	Creates basic photo checklist
This commit is contained in:
		@@ -3,6 +3,7 @@
 | 
				
			|||||||
# Program to create a photo checklist of a given frc event.
 | 
					# Program to create a photo checklist of a given frc event.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import configparser
 | 
					import configparser
 | 
				
			||||||
 | 
					import datetime as dt
 | 
				
			||||||
import operator
 | 
					import operator
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import tbapy
 | 
					import tbapy
 | 
				
			||||||
@@ -16,6 +17,19 @@ def getProjectID(api, name):
 | 
				
			|||||||
    print('Error: No project with the name {} found'.format(name))
 | 
					    print('Error: No project with the name {} found'.format(name))
 | 
				
			||||||
    exit(1)
 | 
					    exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# createChecklistItem() creates a checklist item of the highest priority.
 | 
				
			||||||
 | 
					def createChecklistItem(name, api, projectID, item, date):
 | 
				
			||||||
 | 
					    return api.items.add(name,
 | 
				
			||||||
 | 
					                         project_id=projectID,
 | 
				
			||||||
 | 
					                         parent_id=item['id'],
 | 
				
			||||||
 | 
					                         date_string=date,
 | 
				
			||||||
 | 
					                         priority=4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# createPhotoChecklistItem() creates a checklist item that requires a photo.
 | 
				
			||||||
 | 
					def createPhotoChecklistItem(name, api, projectID, item, date):
 | 
				
			||||||
 | 
					    return createChecklistItem('Take photo of **{}**'.format(name),
 | 
				
			||||||
 | 
					                               api, projectID, item, date)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# createPitList() creates a checklist for taking photos of a teams pit.
 | 
					# createPitList() creates a checklist for taking photos of a teams pit.
 | 
				
			||||||
def createPitList(api, teams, projectID, checklist, date):
 | 
					def createPitList(api, teams, projectID, checklist, date):
 | 
				
			||||||
    item = api.items.add('**Take** Pit Photos',
 | 
					    item = api.items.add('**Take** Pit Photos',
 | 
				
			||||||
@@ -24,12 +38,43 @@ def createPitList(api, teams, projectID, checklist, date):
 | 
				
			|||||||
                         date_string=date,
 | 
					                         date_string=date,
 | 
				
			||||||
                         priority=3)
 | 
					                         priority=3)
 | 
				
			||||||
    for team in teams:
 | 
					    for team in teams:
 | 
				
			||||||
        api.items.add('Pit photo of **{}** {}'.format(team['team_number'], team['nickname']),
 | 
					        createChecklistItem('Pit photo of **{}** {}'.format(team['team_number'], team['nickname']),
 | 
				
			||||||
 | 
					                            api, projectID, item, date)
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					# createGroupsList() creates a checklist of the different groups of volenteers.
 | 
				
			||||||
 | 
					def createGroupsList(api, projectID, checklist, date):
 | 
				
			||||||
 | 
					    item = api.items.add('Groups',
 | 
				
			||||||
                         project_id=projectID,
 | 
					                         project_id=projectID,
 | 
				
			||||||
                      parent_id=item['id'],
 | 
					                         parent_id=checklist['id'],
 | 
				
			||||||
                         date_string=date,
 | 
					                         date_string=date,
 | 
				
			||||||
                      priority=4)
 | 
					                         priority=3)
 | 
				
			||||||
    api.commit()
 | 
					    groups = ['Judges', 'Robot Inspectors', 'Referees', 'Safety Inspectors',
 | 
				
			||||||
 | 
					              'Field Reset', 'Queuers', 'CSAs', 'VC and Pit Admin']
 | 
				
			||||||
 | 
					    for group in groups:
 | 
				
			||||||
 | 
					        createPhotoChecklistItem(group, api, projectID, item, date)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# createWinnersList() creates a checklist of the winners of an event.
 | 
				
			||||||
 | 
					def createWinnersList(api, projectID, checklist, date):
 | 
				
			||||||
 | 
					    item = api.items.add('Winners',
 | 
				
			||||||
 | 
					                         project_id=projectID,
 | 
				
			||||||
 | 
					                         parent_id=checklist['id'],
 | 
				
			||||||
 | 
					                         date_string=date,
 | 
				
			||||||
 | 
					                         priority=3)
 | 
				
			||||||
 | 
					    groups = ['Chairman\'s award', 'Engineering Inspiration', 'Rookie All-Star', 'Winning Alliance',
 | 
				
			||||||
 | 
					              'Winning Team 1', 'Winning Team 2', 'Winning Team 3']
 | 
				
			||||||
 | 
					    for group in groups:
 | 
				
			||||||
 | 
					        createPhotoChecklistItem(group, api, projectID, item, date)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# createRobotList() creates a checklist for taking photos of a team's robot.
 | 
				
			||||||
 | 
					def createRobotList(api, teams, projectID, checklist, date):
 | 
				
			||||||
 | 
					    item = api.items.add('**Take** Robot Photos',
 | 
				
			||||||
 | 
					                         project_id=projectID,
 | 
				
			||||||
 | 
					                         parent_id=checklist['id'],
 | 
				
			||||||
 | 
					                         date_string=date,
 | 
				
			||||||
 | 
					                         priority=3)
 | 
				
			||||||
 | 
					    for team in teams:
 | 
				
			||||||
 | 
					        createChecklistItem('Robot photo of **{}** {}'.format(team['team_number'], team['nickname']),
 | 
				
			||||||
 | 
					                            api, projectID, item, date)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
# Parse settings config
 | 
					# Parse settings config
 | 
				
			||||||
configString = '[Settings]\n' + open('../settings.conf').read()
 | 
					configString = '[Settings]\n' + open('../settings.conf').read()
 | 
				
			||||||
@@ -49,14 +94,31 @@ projectID = getProjectID(api, 'Test')
 | 
				
			|||||||
tba = tbapy.TBA(tbaKey)
 | 
					tba = tbapy.TBA(tbaKey)
 | 
				
			||||||
eventKey = '2020ncpem'
 | 
					eventKey = '2020ncpem'
 | 
				
			||||||
event = tba.event(eventKey)
 | 
					event = tba.event(eventKey)
 | 
				
			||||||
 | 
					setupDay = event['start_date']
 | 
				
			||||||
 | 
					day1 = (dt.datetime.strptime(setupDay, '%Y-%m-%d') + dt.timedelta(days=1)).strftime('%Y-%m-%d')
 | 
				
			||||||
 | 
					day2 = event['end_date']
 | 
				
			||||||
teams = sorted(tba.event_teams(eventKey), key=operator.attrgetter('team_number'))
 | 
					teams = sorted(tba.event_teams(eventKey), key=operator.attrgetter('team_number'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Create checklist
 | 
				
			||||||
checklist = api.items.add('{} Photos'.format(event['name']),
 | 
					checklist = api.items.add('{} Photos'.format(event['name']),
 | 
				
			||||||
                          project_id=projectID,
 | 
					                          project_id=projectID,
 | 
				
			||||||
                          date_string=event['end_date'],
 | 
					                          date_string=day2,
 | 
				
			||||||
                          priority=2)
 | 
					                          priority=2)
 | 
				
			||||||
api.commit()
 | 
					 | 
				
			||||||
createPitList(api, teams, projectID, checklist, event['start_date'])
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
name = api.state['user']['full_name']
 | 
					# Setup
 | 
				
			||||||
print(name)
 | 
					createPitList(api, teams, projectID, checklist, setupDay)
 | 
				
			||||||
 | 
					createChecklistItem('**Schedule** Judges photo', api, projectID, checklist, setupDay)
 | 
				
			||||||
 | 
					createChecklistItem('**Schedule** Inspectors photo', api, projectID, checklist, setupDay)
 | 
				
			||||||
 | 
					createChecklistItem('**Schedule** Seniors photo', api, projectID, checklist, setupDay)
 | 
				
			||||||
 | 
					createGroupsList(api, projectID, checklist, setupDay)
 | 
				
			||||||
 | 
					# Day 1
 | 
				
			||||||
 | 
					createPhotoChecklistItem('Guest Speakers', api, projectID, checklist, day1)
 | 
				
			||||||
 | 
					createRobotList(api, teams, projectID, checklist, day1)
 | 
				
			||||||
 | 
					# Day 2
 | 
				
			||||||
 | 
					createPhotoChecklistItem('Guest Speakers', api, projectID, checklist, day2)
 | 
				
			||||||
 | 
					createPhotoChecklistItem('Mentors after parade', api, projectID, checklist, day2)
 | 
				
			||||||
 | 
					createPhotoChecklistItem('Seniors', api, projectID, checklist, day2)
 | 
				
			||||||
 | 
					createPhotoChecklistItem('Alliances Representatives', api, projectID, checklist, day2)
 | 
				
			||||||
 | 
					createWinnersList(api, projectID, checklist, day2)
 | 
				
			||||||
 | 
					createChecklistItem('**Email** guest speakers and winners photos', api, projectID, checklist, day2)
 | 
				
			||||||
 | 
					api.commit()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user