# check end of game
                    game_end = nhl.check_game_end(team_id)

                    if not game_end:

                        # Check score online and save score
                        new_score = nhl.fetch_score(team_id)

                        # If score change...
                        if new_score != old_score:
                            time.sleep(delay)
                            if new_score > old_score:
                                # save new score
                                print("GOAL!")
                                # activate_goal_light()
                                light.activate_goal_light()
                            old_score = new_score

                    else:
                        print("Game Over!")
                        old_score = 0  # Reset for new game
                        sleep("day")  # sleep till tomorrow
                else:
                    print("No Game Today!")
                    sleep("day")  # sleep till tomorrow
            else:
                print("OFF SEASON!")
                sleep("season")  # sleep till next season

    except KeyboardInterrupt:
        print("\nCtrl-C pressed")
Exemple #2
0
def goal_light_activate():
    light.activate_goal_light()
    return "OK"
                    # check end of game
                    game_end = nhl.check_game_end(team_id)
                    
                    if not game_end:
            
                        # Check score online and save score
                        new_score = nhl.fetch_score(team_id)

                        # If score change...
                        if new_score != old_score:
                            time.sleep(delay) 
                            if new_score > old_score:
                                # save new score
                                print("GOAL!")
                                # activate_goal_light()
                                light.activate_goal_light()
                            old_score = new_score
                            

                    else:
                        print("Game Over!")
                        old_score = 0 # Reset for new game
                        sleep("day")  # sleep till tomorrow
                else:
                    print("No Game Today!")
                    sleep("day")  # sleep till tomorrow
            else:
                print("OFF SEASON!")
                sleep("season")  # sleep till next season

    except KeyboardInterrupt:
                        # If score change...
                        if new_opposition_score != old_opposition_score:
                            print("Opposition Scores: {0}".format(
                                new_opposition_score))
                            light.writeOppositionScore(new_opposition_score)

                        if new_score != old_score:
                            time.sleep(delay)
                            if new_score > old_score:
                                # save new score
                                print("GOAL!")
                                # activate_goal_light()
                                light.writeScore(new_score)
                                if not RESTART_INGAME:
                                    light.activate_goal_light(
                                        main_dir=main_dir)
                                else:
                                    RESTART_INGAME = False  # Reset RESTART_INGAME to false so we don't skip anymore goals

                            old_score = new_score
                            old_opposition_score = new_opposition_score

                    else:
                        print("Game Over!")
                        old_score = 0  # Reset for new game
                        old_opposition_score = 0
                        time.sleep(
                            3600)  # Sleep for 5 minutes, then clear scoreboard
                        light.shutdownScoreboard()
                        sleep("day")  # sleep till tomorrow
                else: