I’m trying to write some code with functions, and it was working yesterday, but today, when I run it, nothing happens. I don’t get en error code, either. I am using VSCode
This is my code:
#importing modules
import statbotics
import requests
import json
from requests.auth import HTTPBasicAuth
import pandas as pd
#note that so far, the functions that call to The Blue Alliance will only print data in json
#work is going on to convert this to more readable csv data for programs like excel
#the statbotics functions return data in python dictionary
#work is also in progress for a more user-friendly interface
#the season year
year = '2023'
#event codes
houstonChampionships = year + 'cmptx'
canadianPacificRegional = year + 'bcvi'
#statbotics object
sb = statbotics.Statbotics()
#authentication headers
headers = {'X-TBA-Auth-Key': 'Ra4ErLM8H0zAHHFrZjFYQIlHHDdKQOqTOdYpaz19g5HI5JGaIKStRqYbysW5qr6D'}
#get OPRS for an event
def eventOPR(eventCode):
OPRSRaw = requests.get('https://www.thebluealliance.com/api/v3/event/%s/oprs'%(eventCode), headers=headers)
OPRS = OPRSRaw.content
print(OPRS)
#get the teams for an event
def eventTeams(eventCode):
teamsRaw = requests.get('https://www.thebluealliance.com/api/v3/event/%s/teams'%(eventCode), headers=headers)
teams = teamsRaw.content
print(teams)
#gets a team's matches for an event
def teamMatches(teamCode, eventCode):
matchesRaw = requests.get('https://www.thebluealliance.com/api/v3/team/%s/event/%s/matches'%(teamCode, eventCode), headers=headers)
matches = matchesRaw.content
print(matches)
#get awards from an event
def eventAwards(eventCode):
awardsRaw = requests.get('https://www.thebluealliance.com/api/v3/event/%s/awards'%(eventCode), headers=headers)
awards = awardsRaw.content
print(awards)
#get the events that a team has this year (year is corresponding to the year set in the year variable)
def teamEvents(teamCode):
eventsRaw = requests.get('https://www.thebluealliance.com/api/v3/team/%s/events/'%(teamCode) + year, headers=headers)
events = eventsRaw.content
print(events)
#get the awards that a team won at an event
def teamAwardsEvents(teamCode, eventCode):
teamAwardsRaw = requests.get('https://www.thebluealliance.com/api/v3/team/%s/event/%s/awards'%(teamCode, eventCode), headers=headers)
teamAwards = teamAwardsRaw.content
print(teamAwards)
#get the statbotics stats for a team
def sbTeamStats(teamCode):
teamStats = sb.get_team(teamCode)
print(teamStats)
#get the mean EPA of a team at a certain event
def sbTeamEventEPA(teamCode, eventCode):
teamEventEPA = sb.get_team_event(teamCode, eventCode, ['epa_mean'])
print(teamEventEPA)
#get certain statbotics stats for a team at en event
def sbTeamEventStats(teamCode, eventCode, fields=['all']):
teamEventStats = sb.get_team_event(teamCode, eventCode, fields)
print(teamEventStats)
# get teams by country or state/province (only for US and Canada)
def sbTeamSorts(country=None, adminDivision=None, activeOrNo=True, fieldsParam=['all']):
teamSorts = sb.get_teams(country, adminDivision, active=activeOrNo, fields=fieldsParam)
print(teamSorts)
# call your functions here
sbTeamStats(9180)
This is what vscode shows:
I’m using Ubuntu 20.04