From b2b28850ddf8c593f58a42110e9ff36ceb1b3511 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Sat, 4 Mar 2023 21:39:38 -0500 Subject: [PATCH] ongeki: add get_allnet_info, --- titles/ongeki/__init__.py | 8 -------- titles/ongeki/index.py | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/titles/ongeki/__init__.py b/titles/ongeki/__init__.py index 26e107c..7f03a8f 100644 --- a/titles/ongeki/__init__.py +++ b/titles/ongeki/__init__.py @@ -6,13 +6,5 @@ from titles.ongeki.read import OngekiReader index = OngekiServlet database = OngekiData reader = OngekiReader - -use_default_title = True -include_protocol = True -title_secure = False game_codes = [OngekiConstants.GAME_CODE] -trailing_slash = True -use_default_host = False -host = "" - current_schema_version = 2 \ No newline at end of file diff --git a/titles/ongeki/index.py b/titles/ongeki/index.py index c636659..9e512b2 100644 --- a/titles/ongeki/index.py +++ b/titles/ongeki/index.py @@ -6,6 +6,8 @@ import string import logging, coloredlogs import zlib from logging.handlers import TimedRotatingFileHandler +from os import path +from typing import Tuple from core.config import CoreConfig from titles.ongeki.config import OngekiConfig @@ -23,7 +25,8 @@ class OngekiServlet(): def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None: self.core_cfg = core_cfg self.game_cfg = OngekiConfig() - self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/ongeki.yaml"))) + if path.exists(f"{cfg_dir}/ongeki.yaml"): + self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/ongeki.yaml"))) self.versions = [ OngekiBase(core_cfg, self.game_cfg), @@ -52,6 +55,19 @@ class OngekiServlet(): self.logger.setLevel(self.game_cfg.server.loglevel) coloredlogs.install(level=self.game_cfg.server.loglevel, logger=self.logger, fmt=log_fmt_str) + + @classmethod + def get_allnet_info(cls, game_code: str, core_cfg: CoreConfig, cfg_dir: str) -> Tuple[bool, str, str]: + game_cfg = OngekiConfig() + game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/ongeki.yaml"))) + + if not game_cfg.server.enable: + return (False, "", "") + + if core_cfg.server.is_develop: + return (True, f"http://{core_cfg.title.hostname}:{core_cfg.title.port}/{game_code}/$v/", f"{core_cfg.title.hostname}:{core_cfg.title.port}/") + + return (True, f"http://{core_cfg.title.hostname}/{game_code}/$v/", f"{core_cfg.title.hostname}/") def render_POST(self, request: Request, version: int, url_path: str) -> bytes: req_raw = request.content.getvalue()