def refresh_playoff(self): """ Currently the series ticker request all the games of a series everytime its asked to load on screen. This create a lot of delay between showing each series. TODO: Add a refresh function to the Series object instead and trigger a refresh only at specific time in the renderer.(End of a game, new day) """ attempts_remaining = 5 while attempts_remaining > 0: try: # Get the plaoffs data from the nhl api self.playoffs = nhl_api.playoff(self.status.season_id) # Check if there is any rounds avaialable and grab the most recent one available. if self.playoffs.rounds: self.current_round = self.playoffs.rounds[str( self.playoffs.default_round)] self.current_round_name = self.current_round.names.name if self.current_round_name == "Stanley Cup Qualifier": self.current_round_name = "Qualifier" if self.playoffs.default_round == 4: self.stanleycup_round = True debug.info("defaultround number is : {}".format( self.playoffs.default_round)) try: # Grab the series of the current round of playoff. self.series = self.current_round.series # Check if prefered team are part of the current round of playoff self.pref_series = prioritize_pref_series( filter_list_of_series(self.series, self.pref_teams), self.pref_teams) # If the user as set to show his favorite teams in the seriesticker if self.config.seriesticker_preferred_teams_only and self.pref_series: self.series = self.pref_series except AttributeError: debug.error( "The {} Season playoff has not started yet or is unavailable" .format(self.playoffs.season)) self.isPlayoff = False break self.isPlayoff = True break except ValueError as error_message: self.network_issues = True debug.error( "Failed to refresh the list of Series. {} attempt remaining." .format(attempts_remaining)) debug.error(error_message) attempts_remaining -= 1 sleep(NETWORK_RETRY_SLEEP_TIME)
def refresh_playoff(self): attempts_remaining = 5 while attempts_remaining > 0: try: # Get the plaoffs data from the nhl api self.playoffs = nhl_api.playoff(self.status.season_id) # Check if there is any rounds avaialable and grab the most recent one available. if self.playoffs.rounds: self.current_round = self.playoffs.rounds[str( self.playoffs.default_round)] self.current_round_name = self.current_round.names.name if self.current_round_name == "Stanley Cup Qualifier": self.current_round_name = "Qualifier" debug.info("defaultround number is : {}".format( self.playoffs.default_round)) try: # Grab the series of the current round of playoff. self.series = self.current_round.series # Check if prefered team are part of the current round of playoff self.pref_series = prioritize_pref_series( filter_list_of_series(self.series, self.pref_teams), self.pref_teams) # If the user as set to show his favorite teams in the seriesticker if self.config.seriesticker_preferred_teams_only and self.pref_series: self.series = self.pref_series except AttributeError: debug.error( "The {} Season playoff has to started yet or unavailable" .format(self.playoffs.season)) break except ValueError as error_message: self.network_issues = True debug.error( "Failed to refresh the list of Series. {} attempt remaining." .format(attempts_remaining)) debug.error(error_message) attempts_remaining -= 1 sleep(NETWORK_RETRY_SLEEP_TIME)