def do_list(args, config): url = config.get('DEFAULT', 'url') key_file = config.get('DEFAULT', 'key_file') client = XoClient(base_url=url, keyfile=key_file) game_list = client.list() if game_list is not None: fmt = "%-15s %-15.15s %-15.15s %-9s %s" print(fmt % ('GAME', 'PLAYER 1', 'PLAYER 2', 'BOARD', 'STATE')) for game_data in game_list: board, game_state, player1, player2, name = \ game_data.decode().split(",") print(fmt % (name, player1[:6], player2[:6], board, game_state)) else: raise XoException("Could not retrieve game listing.")
def do_list(args): url = _get_url(args) auth_user, auth_password = _get_auth_info(args) client = XoClient(base_url=url, keyfile=None) game_list = [ game.split(',') for games in client.list(auth_user=auth_user, auth_password=auth_password) for game in games.decode().split('|') ] if game_list is not None: fmt = "%-15s %-15.15s %-15.15s %-9s %s" print(fmt % ('GAME', 'PLAYER 1', 'PLAYER 2', 'BOARD', 'STATE')) for game_data in game_list: name, board, game_state, player1, player2 = game_data print(fmt % (name, player1[:6], player2[:6], board, game_state)) else: raise XoException("Could not retrieve game listing.")