def setup_nhl(): """ Load team ID and delay from settings.txt or supply defaults """ lines = "" team = "" team_id = "" settings_file = '{0}/settings.txt'.format(main_dir) if os.path.exists(settings_file): # get settings from file f = open(settings_file, 'r') lines = f.readlines() # find team_id try: team_id = lines[1].strip('\n') except IndexError: team_id = "" if team_id == "": team = "Hurricanes" # query the api to get the ID team_id = nhl.get_team_id(team) # find delay try: delay = lines[2].strip('\n') except IndexError: delay = "" if delay is "": delay = 0.0 return (team_id, delay)
def setup_nhl(self): """Function to setup the nhl_goal_light.py with team, team_id and delay""" """Try to find a settings.txt file in the folder to automaticly setup the goal light with pre-desired team and delay. settings.txt file should as such : Enter team_id and delay, each on a separate line in this order. LEAVE EMPTY if you want to manually input every time. If program can't find settings.txt file or if file is empty, it will ask for user input. """ lines = "" team = "" team_id = "" settings_file = '/home/pi/nhlscoreboard/settings.txt' if os.path.exists(settings_file): # get settings from file f = open(settings_file, 'r') lines = f.readlines() # find team_id try: team_id = lines[1].strip('\n') except IndexError: team_id = "" if team_id == "": team = input( "Enter team you want to setup (without city) (Default: Canadiens) \n" ) if team == "": team = "Canadiens" else: team = team.title() # query the api to get the ID team_id = nhl.get_team_id(team) # find delay try: delay = lines[2].strip('\n') except IndexError: delay = "" if delay is "": delay = input("Enter delay required to sync : \n") if delay is "": delay = 0 delay = float(delay) delay = 0.0 return (team_id, delay)
def setup_nhl(): """Function to setup the nhl_goal_light.py with team, team_id and delay""" """Try to find a settings.txt file in the folder to automaticly setup the goal light with pre-desired team and delay. settings.txt file should as such : Enter team_id and delay, each on a separate line in this order. LEAVE EMPTY if you want to manually input every time. If program can't find settings.txt file or if file is empty, it will ask for user input. """ lines = "" team = "" team_id = "" settings_file = '/home/pi/nhl_goal_light/settings.txt' if os.path.exists(settings_file): # get settings from file f = open(settings_file, 'r') lines = f.readlines() # find team_id try: team_id = lines[1].strip('\n') except IndexError: team_id = "" if team_id == "": team = raw_input("Enter team you want to setup (without city) (Default: Canadiens) \n") if team == "": team = "Canadiens" else: team = team.title() # query the api to get the ID team_id = nhl.get_team_id(team) # find delay try: delay = lines[2].strip('\n') except IndexError: delay = "" if delay is "": delay = raw_input("Enter delay required to sync : \n") if delay is "": delay = 0 delay = float(delay) return (team_id, delay)
def team_id(team): # Fetch and return the official ID of the team response = { 'id': nhl.get_team_id(team) } return jsonify(response)