FactorioClient: End the log on "No Archipelago mod was loaded. Aborting." if no bridge mod was found.

CommonClient: give separate error for invalid URI
This commit is contained in:
Fabian Dill 2021-09-09 16:02:45 +02:00
parent b4c3c5deea
commit 282e7b4006
2 changed files with 21 additions and 21 deletions

View File

@ -252,13 +252,13 @@ async def server_loop(ctx: CommonContext, address=None):
logger.error('Unable to connect to multiworld server at cached address. ' logger.error('Unable to connect to multiworld server at cached address. '
'Please use the connect button above.') 'Please use the connect button above.')
else: else:
logger.error('Connection refused by the multiworld server') logger.exception('Connection refused by the multiworld server')
except websockets.InvalidURI:
logger.exception('Failed to connect to the multiworld server (invalid URI)')
except (OSError, websockets.InvalidURI): except (OSError, websockets.InvalidURI):
logger.error('Failed to connect to the multiworld server') logger.exception('Failed to connect to the multiworld server')
except Exception as e: except Exception as e:
logger.error('Lost connection to the multiworld server, type /connect to reconnect') logger.exception('Lost connection to the multiworld server, type /connect to reconnect')
if not isinstance(e, websockets.WebSocketException):
logger.exception(e)
finally: finally:
await ctx.connection_closed() await ctx.connection_closed()
if ctx.server_address: if ctx.server_address:

View File

@ -239,7 +239,7 @@ def get_info(ctx, rcon_client):
ctx.seed_name = info["seed_name"] ctx.seed_name = info["seed_name"]
async def factorio_spinup_server(ctx: FactorioContext): async def factorio_spinup_server(ctx: FactorioContext) -> bool:
savegame_name = os.path.abspath("Archipelago.zip") savegame_name = os.path.abspath("Archipelago.zip")
if not os.path.exists(savegame_name): if not os.path.exists(savegame_name):
logger.info(f"Creating savegame {savegame_name}") logger.info(f"Creating savegame {savegame_name}")
@ -267,24 +267,23 @@ async def factorio_spinup_server(ctx: FactorioContext):
ctx.mod_version = Utils.Version(*(int(number) for number in parts[-2].split("."))) ctx.mod_version = Utils.Version(*(int(number) for number in parts[-2].split(".")))
if not rcon_client and "Starting RCON interface at IP ADDR:" in msg: if not rcon_client and "Starting RCON interface at IP ADDR:" in msg:
rcon_client = factorio_rcon.RCONClient("localhost", rcon_port, rcon_password) rcon_client = factorio_rcon.RCONClient("localhost", rcon_port, rcon_password)
if ctx.mod_version == ctx.__class__.mod_version:
raise Exception("No Archipelago mod was loaded. Aborting.")
get_info(ctx, rcon_client) get_info(ctx, rcon_client)
await asyncio.sleep(0.01) await asyncio.sleep(0.01)
if ctx.mod_version == ctx.__class__.mod_version:
raise Exception("No Archipelago mod was loaded. Aborting.")
except Exception as e: except Exception as e:
logging.exception(e) logger.exception(e)
logging.error("Aborted Factorio Server Bridge") logger.error("Aborted Factorio Server Bridge")
ctx.exit_event.set() ctx.exit_event.set()
else: else:
logger.info(f"Got World Information from AP Mod {tuple(ctx.mod_version)} for seed {ctx.seed_name} in slot {ctx.auth}") logger.info(f"Got World Information from AP Mod {tuple(ctx.mod_version)} for seed {ctx.seed_name} in slot {ctx.auth}")
return True
finally: finally:
factorio_process.terminate() factorio_process.terminate()
factorio_process.wait(5) factorio_process.wait(5)
return False
async def main(args): async def main(args):
ctx = FactorioContext(args.connect, args.password) ctx = FactorioContext(args.connect, args.password)
@ -298,7 +297,8 @@ async def main(args):
input_task = asyncio.create_task(console_loop(ctx), name="Input") input_task = asyncio.create_task(console_loop(ctx), name="Input")
ui_task = None ui_task = None
factorio_server_task = asyncio.create_task(factorio_spinup_server(ctx), name="FactorioSpinupServer") factorio_server_task = asyncio.create_task(factorio_spinup_server(ctx), name="FactorioSpinupServer")
await factorio_server_task succesful_launch = await factorio_server_task
if succesful_launch:
factorio_server_task = asyncio.create_task(factorio_server_watcher(ctx), name="FactorioServer") factorio_server_task = asyncio.create_task(factorio_server_watcher(ctx), name="FactorioServer")
progression_watcher = asyncio.create_task( progression_watcher = asyncio.create_task(
game_watcher(ctx), name="FactorioProgressionWatcher") game_watcher(ctx), name="FactorioProgressionWatcher")