ValvePython / dota2

🐸 Python package for interacting with Dota 2 Game Coordinator
http://dota2.readthedocs.io
205 stars 32 forks source link

WebAPI boostrap failed: maximum recursion depth exceeded #66

Closed Mrfull closed 3 years ago

Mrfull commented 3 years ago

I add my code on django website, but get this error Code: `from steam.client import SteamClient from dota2.client import Dota2Client from steam.enums import EResult from dota2.proto_enums import DOTA_GameMode from steam.steamid import SteamID

client = SteamClient() dota = Dota2Client(client)

def main(lobby_name, password, players): print("start controller ")

try:
    login_in_steam("tobirama134", "ANUARRSS2017")
except RuntimeError as err:
    print(err.args)
# client.wait_event('logged_on')

print('starting dota2...')
start_dota()
# dota.wait_event('ready')

create_lobby(lobby_name, password)
dota.wait_event('lobby_new')
print('lobby {} created'.format(dota.lobby.lobby_id))

invite_players_to_lobby(players)

dota.wait_event('lobby_changed')
dota.leave_practice_lobby()
dota.exit()
client.logout()

def login_in_steam(login, password): result = client.login(login, password)

result = client.cli_login()

if result != EResult.OK:
    raise RuntimeError("Login failed")

def start_dota(): dota.launch()

def create_lobby(lobby_name, password): settings = { 'game_name': lobby_name, "game_mode": DOTA_GameMode.DOTA_GAMEMODE_1V1MID, "pass_key": "PWA", } dota.create_practice_lobby(password, settings)

def invite_players_to_lobby(players): for player in (SteamID(p) for p in players): print('invite player {}'.format(player)) dota.invite_to_lobby(player)

`

Error code start controller some WebAPI boostrap failed: maximum recursion depth exceeded

rossengeorgiev commented 3 years ago

You are likely hitting this: https://github.com/ValvePython/steam/issues/97

Mrfull commented 3 years ago

Yes, i saw i't but it's didn't help New come after ValvePython/steam#97

`from steam.client import SteamClient from dota2.client import Dota2Client from steam.enums import EResult from dota2.proto_enums import DOTA_GameMode from steam.steamid import SteamID

import logging from gevent import monkey monkey.patch_all(thread=False)

logging.basicConfig( format='[%(asctime)s] %(levelname)s %(name)s: %(message)s', level=logging.DEBUG )

class DotaLobbyManager: def init(self): monkey.patch_socket() monkey.patch_ssl() self.client = SteamClient() self.dota = Dota2Client(self.client)

# def main(lobby_name, password, players):
def main(self):
    lobby_name = "test"
    players = ["[REDACTED]"]
    password = ""

    print("start controller ")
    self.dota.destroy_lobby()
    self.dota.exit()
    try:
        self.login_in_steam("[REDACTED]", "[REDACTED]")
    except RuntimeError as err:
        print(err.args)
    # client.wait_event('logged_on')

    print('starting dota2...')
    self.start_dota()
    # dota.wait_event('ready')
    self.dota.destroy_lobby()
    self.create_lobby(lobby_name, password)
    self.dota.wait_event('lobby_new')
    print('lobby {} created'.format(self.dota.lobby.lobby_id))

    self.invite_players_to_lobby(players)

    self.dota.wait_event('lobby_changed')
    self.dota.leave_practice_lobby()
    self.dota.exit()
    self.client.logout()

def login_in_steam(self, login, password):
    result = self.client.login(login, password)
    # result = client.cli_login()

    if result != EResult.OK:
        raise RuntimeError("Login failed")

def start_dota(self):
    self.dota.launch()

def create_lobby(self, lobby_name, password):
    settings = {
        'game_name': lobby_name,
        "game_mode": DOTA_GameMode.DOTA_GAMEMODE_1V1MID,
        "pass_key": "PWA",
    }
    self.dota.create_practice_lobby(password, settings)

def invite_players_to_lobby(self, players):
    for player in (SteamID(p) for p in players):
        print('invite player {}'.format(player))
        self.dota.invite_to_lobby(player)

`

Hekkta commented 3 years ago

Btw you have your user and pass in the code.

Mrfull commented 3 years ago

Yeah, for sure i did it. If i don't do it. i can't even create lobby