def check_new_goals(self): debug.log("Check new goal") pref_team_only = self.data.config.goal_anim_pref_team_only away_id = self.scoreboard.away_team.id away_name = self.scoreboard.away_team.name away_goals = self.scoreboard.away_team.goals away_score = self.away_score home_id = self.scoreboard.home_team.id home_name = self.scoreboard.home_team.name home_goals = self.scoreboard.home_team.goals home_score = self.home_score # Display goal details that are cached if there is any # GoalRenderer(self.data, self.matrix, self.sleepEvent, self.scoreboard.away_team).render() if self.goal_team_cache: try: while self.goal_team_cache: # create a goal object first to see if there are any missing data if self.goal_team_cache[0] == "away": GoalRenderer(self.data, self.matrix, self.sleepEvent, self.scoreboard.away_team).render() else: GoalRenderer(self.data, self.matrix, self.sleepEvent, self.scoreboard.home_team).render() # Remove the first cached goal self.goal_team_cache.pop(0) except IndexError: debug.error( "The scoreboard object failed to get the goal details, trying on the next data refresh" ) except KeyError: debug.error( "Last Goal is a No goal. Or the API is missing some information." ) self.goal_team_cache.pop(0) if away_score < away_goals: self.away_score = away_goals self.goal_team_cache.append("away") if away_id not in self.data.pref_teams and pref_team_only: return # run the goal animation self._draw_goal_animation(away_id, away_name) if home_score < home_goals: self.home_score = home_goals self.goal_team_cache.append("home") if home_id not in self.data.pref_teams and pref_team_only: return # run the goal animation self._draw_goal_animation(home_id, home_name)
def check_new_goals(self): debug.log("Check new goal") pref_team_only = self.data.config.goal_anim_pref_team_only away_id = self.scoreboard.away_team.id away_name = self.scoreboard.away_team.name away_goals = self.scoreboard.away_team.goals away_score = self.away_score home_id = self.scoreboard.home_team.id home_name = self.scoreboard.home_team.name home_goals = self.scoreboard.home_team.goals home_score = self.home_score # Display goal details that are cached if there is any # GoalRenderer(self.data, self.matrix, self.sleepEvent, self.scoreboard.away_team).render() if self.goal_team_cache: try: while self.goal_team_cache: # create a goal object first to see if there are any missing data if self.goal_team_cache[0] == "away": GoalRenderer(self.data, self.matrix, self.sleepEvent, self.scoreboard.away_team).render() else: GoalRenderer(self.data, self.matrix, self.sleepEvent, self.scoreboard.home_team).render() # Remove the first cached goal self.goal_team_cache.pop(0) except IndexError: debug.error( "The scoreboard object failed to get the goal details, trying on the next data refresh" ) except KeyError: debug.error( "Last Goal is a No goal. Or the API is missing some information." ) self.goal_team_cache.pop(0) # Save home_name,home_goals,away_name,away_goals to /dev/shm/getNHL.txt.1 f = open('/dev/shm/getNHL.txt.1', 'w') f.write('%s %d, %s %d\n' % (home_name, home_goals, away_name, away_goals)) f.close() subprocess_cmd = 'sudo -H -u pi bash -c "rsync /dev/shm/getNHL.txt.1 [email protected]:/dev/shm/"' # Check if first run, or "team name" changed (aka switched to a different game) if self.last_home_name != home_name: subprocess.run([subprocess_cmd], shell=True) self.last_home_name = home_name if away_score < away_goals: subprocess.run([subprocess_cmd], shell=True) self.away_score = away_goals self.goal_team_cache.append("away") if away_id not in self.data.pref_teams and pref_team_only: return # run the goal animation self._draw_event_animation("goal", away_id, away_name) if home_score < home_goals: subprocess.run([subprocess_cmd], shell=True) self.home_score = home_goals self.goal_team_cache.append("home") if home_id not in self.data.pref_teams and pref_team_only: return # run the goal animation self._draw_event_animation("goal", home_id, home_name)