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))
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) state = client.get_state() if name not in state: raise XoException('no such game: {}'.format(name)) game = state[name] player1 = '' player2 = '' if 'Player1' in game: player1 = game['Player1'] if 'Player2' in game: player2 = game['Player2'] board = list(game['Board'].replace('-', ' ')) game_state = game['State'] print "GAME: : {}".format(name) print "PLAYER 1 : {}".format(player1) print "PLAYER 2 : {}".format(player2) 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 ""
def do_create(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) response = client.create(name) print("Response: {}".format(response))
def do_create(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) client.create(name=name) if args.wait: client.wait_for_commit()
def do_take(args, config): name = args.name space = args.space url = config.get('DEFAULT', 'url') key_file = config.get('DEFAULT', 'key_file') client = XoClient(base_url=url, keyfile=key_file) client.take(name=name, space=space) if args.wait: client.wait_for_commit()
def do_take(args, config): name = args.name space = args.space 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) response = client.take( name, space, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
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_create(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) if args.wait and args.wait > 0: response = client.create(name, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.create(name, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
def do_create(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) if args.wait and args.wait > 0: response = client.create( name, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.create( name, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
def do_delete(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) if args.wait and args.wait > 0: response = client.delete( name, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.delete( name, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
def do_create(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) if args.wait and args.wait > 0: response = client.create(name, wait=args.wait, auth_user=auth_user, auth_password=auth_password) else: response = client.create(name, auth_user=auth_user, auth_password=auth_password) print("Response: {}".format(response))
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) state = client.get_state() fmt = "%-15s %-15.15s %-15.15s %-9s %s" print fmt % ('GAME', 'PLAYER 1', 'PLAYER 2', 'BOARD', 'STATE') for name in state: if 'Player1' in state[name]: player1 = state[name]['Player1'] else: player1 = '' if 'Player2' in state[name]: player2 = state[name]['Player2'] else: player2 = '' board = state[name]['Board'] game_state = state[name]['State'] print fmt % (name, player1, player2, board, game_state)
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) state = client.get_state() fmt = "%-15s %-15.15s %-15.15s %-9s %s" print fmt % ('GAME', 'PLAYER 1', 'PLAYER 2', 'BOARD', 'STATE') for name in state: if 'Player1' in state[name]: player1 = state[name]['Player1'] else: player1 = '' if 'Player2' in state[name]: player2 = state[name]['Player2'] else: player2 = '' board = state[name]['Board'] game_state = state[name]['State'] print fmt % (name, player1, player2, board, game_state)
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 = [ game.split(',') for games in client.list() 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.")
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.")
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.")
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))
def do_show(args): name = args.name url = _get_url(args) auth_user, auth_password = _get_auth_info(args) client = XoClient(base_url=url, keyfile=None) 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))
def do_create(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) client.create(name=name) if args.wait: client.wait_for_commit()
def do_take(args, config): name = args.name space = args.space url = config.get('DEFAULT', 'url') key_file = config.get('DEFAULT', 'key_file') client = XoClient(base_url=url, keyfile=key_file) client.take(name=name, space=space) if args.wait: client.wait_for_commit()