cm: added get_allnet_info

This commit is contained in:
Dniel97 2023-03-06 16:06:17 +01:00
parent 74f3ab7c3f
commit 6609732546
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
4 changed files with 24 additions and 10 deletions

View File

@ -5,12 +5,6 @@ from titles.cm.read import CardMakerReader
index = CardMakerServlet
reader = CardMakerReader
use_default_title = True
include_protocol = True
title_secure = False
game_codes = [CardMakerConstants.GAME_CODE]
trailing_slash = True
use_default_host = False
host = ""
current_schema_version = 1

View File

@ -1,6 +1,8 @@
class CardMakerConstants():
GAME_CODE = "SDED"
CONFIG_NAME = "cardmaker.yaml"
VER_CARD_MAKER = 0
VER_CARD_MAKER_136 = 1

View File

@ -1,4 +1,3 @@
from twisted.web.http import Request
import json
import inflection
import yaml
@ -6,6 +5,10 @@ import string
import logging
import coloredlogs
import zlib
from os import path
from typing import Tuple
from twisted.web.http import Request
from logging.handlers import TimedRotatingFileHandler
from core.config import CoreConfig
@ -19,7 +22,8 @@ class CardMakerServlet():
def __init__(self, core_cfg: CoreConfig, cfg_dir: str) -> None:
self.core_cfg = core_cfg
self.game_cfg = CardMakerConfig()
self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/cardmaker.yaml")))
if path.exists(f"{cfg_dir}/{CardMakerConstants.CONFIG_NAME}"):
self.game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/{CardMakerConstants.CONFIG_NAME}")))
self.versions = [
CardMakerBase(core_cfg, self.game_cfg),
@ -44,6 +48,20 @@ class CardMakerServlet():
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 = CardMakerConfig()
if path.exists(f"{cfg_dir}/{CardMakerConstants.CONFIG_NAME}"):
game_cfg.update(yaml.safe_load(open(f"{cfg_dir}/{CardMakerConstants.CONFIG_NAME}")))
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/", "")
return (True, f"http://{core_cfg.title.hostname}/{game_code}/$v/", "")
def render_POST(self, request: Request, version: int, url_path: str) -> bytes:
req_raw = request.content.getvalue()
url_split = url_path.split("/")