Пример #1
0
def init_connect():
    game_state = 0
    while game_state == 0:
        try:
            game_state = echovr_api.fetch_state()
        except:
            print("Retrying game state API connect")
    return game_state
Пример #2
0
def main():
    game_state = init_connect()
    p_info = get_new_all_player_info(game_state)

    # Loop to iterate continuously
    while True:
        try:
            game_state = echovr_api.fetch_state()
        except:
            main()
        #print('test')
        p_info_new = get_new_all_player_info(game_state)
        #print("p_info_new: ",p_info_new)
        launches = get_launch_info(p_info_new, p_info, CAT_EXIT)
        #print("Launches: ",launches)
        if len(launches) > 0:
            announce_catapult_launches(launches)
        p_info = p_info_new
Пример #3
0
    def _refresh_game_client_status(self):
        """Check if Echo VR is running and update game state"""

        try:
            self._game_state = echovr_api.fetch_state()
            self._game_client_running = True
            log.debug("Echo VR game state updated")
        except ConnectionError:
            self._game_state = None
            self._game_client_running = False
            log.debug(
                "Failed to connect to Echo VR API. Either Echo VR is not running, or it was not started with the -http flag."
            )
        except JSONDecodeError:
            self._game_state = None
            self._game_client_running = True
            log.debug(
                "Echo VR API returned invalid response, likely because a game is not in-progress."
            )
Пример #4
0
from requests.exceptions import ConnectionError
import json
import echovr_api

def _output_json(data):
    print(json.dumps(data, indent=2))

if __name__ == "__main__":
    try:
        response_object = echovr_api.fetch_state_data()
        game_state = echovr_api.fetch_state()
    except ConnectionError as e:
        _output_json({'error': "Connection refused. Make sure you're running Echo VR with the -http option and that you're in a match."})
    except json.decoder.JSONDecodeError as e:
        _output_json({'error': "Could not decode response. (Not valid JSON.)"})

    _output_json(response_object)