我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用settings.PORT。
def __init__(self): #TODO: Add assertions self.host = settings.HOST self.port = settings.PORT self.username = settings.USERNAME self.password = settings.PASSWORD self.pin = settings.PIN
def Pyom(): sys.path.append(os.getcwd()) logger.boot('Logging system initialized.') server = TelnetServer(port=PORT) server.on_connect = init_descriptor server.on_disconnect = close_socket init_monitoring() logger.boot('Entering Game Loop') game_loop(server) logger.critical('System halted.')
def run(self): if ENV == "prod": self._updater.start_webhook(listen='0.0.0.0', port=PORT, url_path=TOKEN) self._updater.bot.set_webhook(URL + TOKEN) self._updater.idle() else: self._updater.start_polling(poll_interval=1)
def main(): parser = argparse.ArgumentParser(description='Run a Tic Tac Toe game server') parser.add_argument('board_x_size', metavar='X', type=int, nargs='?', default=3, help='The horizontal size of the board') parser.add_argument('board_y_size', metavar='Y', type=int, nargs='?', default=3, help='The vertical size of the board') parser.add_argument('needed_symbols', metavar='Z', type=int, nargs='?', default=3, help='The number of consecutive symbols that account for a winning move.') parser.add_argument('player_count', metavar='P', type=int, nargs='?', default=2, help='The number of players.', choices=range(2, 10)) args = parser.parse_args() server_socket = socket(AF_INET, SOCK_STREAM) server_socket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) server_socket.bind((HOSTNAME, PORT)) server_socket.listen(15) active_games = [] curr_game_serv = GameServer(player_count=args.player_count, board_x_size=args.board_x_size, board_y_size=args.board_y_size, needed_symbols=args.needed_symbols) while True: client_socket, address = await server_socket.accept() print(f'Accepted a player - {client_socket} @ {address}') await curr_game_serv.add_player(client_socket, address) # add the player to the server print(f'Current game server is hosting {len(curr_game_serv.players)}/{len(curr_game_serv.players)} players') if curr_game_serv.should_start(): # Start the game and start accepting players for the next game print('Starting Game') await spawn(curr_game_serv.start_game) active_games.append(curr_game_serv) curr_game_serv = GameServer(player_count=args.player_count, board_x_size=args.board_x_size, board_y_size=args.board_y_size, needed_symbols=args.needed_symbols)
def main(): client = await create_connection((HOSTNAME, PORT)) await play_game(client, HOSTNAME)