예제 #1
0
def do_show(args, config):
    name = args.name

    url = config.get('DEFAULT', 'url')
    key_file = config.get('DEFAULT', 'key_file')

    client = XoClient(base_url=url, keyfile=key_file)
    game = client.show(name).decode()

    if game is not None:

        board_str, game_state, player1, player2, name = \
            game.split(",")

        board = list(board_str.replace("-", " "))

        print("GAME:     : {}".format(name))
        print("PLAYER 1  : {}".format(player1[:6]))
        print("PLAYER 2  : {}".format(player2[:6]))
        print("STATE     : {}".format(game_state))
        print("")
        print("  {} | {} | {}".format(board[0], board[1], board[2]))
        print(" ---|---|---")
        print("  {} | {} | {}".format(board[3], board[4], board[5]))
        print(" ---|---|---")
        print("  {} | {} | {}".format(board[6], board[7], board[8]))
        print("")

    else:
        raise XoException("Game not found: {}".format(name))
예제 #2
0
def do_show(args):
    name = args.name

    url = _get_url(args)
    keyfile = _get_keyfile(args)
    auth_user, auth_password = _get_auth_info(args)

    client = XoClient(base_url=url, keyfile=keyfile)

    data = client.show(name, auth_user=auth_user, auth_password=auth_password)

    if data is not None:

        board_str, game_state, player1, player2 = {
            name: (board, state, player_1, player_2)
            for name, board, state, player_1, player_2 in
            [game.split(',') for game in data.decode().split('|')]
        }[name]

        board = list(board_str.replace("-", " "))

        print("GAME:     : {}".format(name))
        print("PLAYER 1  : {}".format(player1[:6]))
        print("PLAYER 2  : {}".format(player2[:6]))
        print("STATE     : {}".format(game_state))
        print("")
        print("  {} | {} | {}".format(board[0], board[1], board[2]))
        print(" ---|---|---")
        print("  {} | {} | {}".format(board[3], board[4], board[5]))
        print(" ---|---|---")
        print("  {} | {} | {}".format(board[6], board[7], board[8]))
        print("")

    else:
        raise XoException("Game not found: {}".format(name))
예제 #3
0
def do_show(args, config):
    name = args.name

    url = config.get('DEFAULT', 'url')
    key_file = config.get('DEFAULT', 'key_file')
    auth_user, auth_password = _get_auth_info(args)

    client = XoClient(base_url=url, keyfile=key_file)

    data = client.show(name, auth_user=auth_user, auth_password=auth_password)

    if data is not None:

        board_str, game_state, player1, player2 = {
            name: (board, state, player_1, player_2)
            for name, board, state, player_1, player_2 in [
                game.split(',')
                for game in data.decode().split('|')
            ]
        }[name]

        board = list(board_str.replace("-", " "))

        print("GAME:     : {}".format(name))
        print("PLAYER 1  : {}".format(player1[:6]))
        print("PLAYER 2  : {}".format(player2[:6]))
        print("STATE     : {}".format(game_state))
        print("")
        print("  {} | {} | {}".format(board[0], board[1], board[2]))
        print(" ---|---|---")
        print("  {} | {} | {}".format(board[3], board[4], board[5]))
        print(" ---|---|---")
        print("  {} | {} | {}".format(board[6], board[7], board[8]))
        print("")

    else:
        raise XoException("Game not found: {}".format(name))