Fix a few places using enums directly instead of their value, formalize 'support' entry in config.
This commit is contained in:
parent
b92cd4f579
commit
5fe48fb1c3
@ -209,7 +209,7 @@ def lookup(protoversion: str, requestgame: str, requestversion: str) -> Dict[str
|
|||||||
('reflecbeat', GameConstants.REFLEC_BEAT),
|
('reflecbeat', GameConstants.REFLEC_BEAT),
|
||||||
('soundvoltex', GameConstants.SDVX),
|
('soundvoltex', GameConstants.SDVX),
|
||||||
]:
|
]:
|
||||||
if g.config.get('support', {}).get(constant, False):
|
if constant in g.config['support']:
|
||||||
gamemapping[gameid] = constant
|
gamemapping[gameid] = constant
|
||||||
game = gamemapping.get(requestgame)
|
game = gamemapping.get(requestgame)
|
||||||
if game is None:
|
if game is None:
|
||||||
|
@ -88,20 +88,19 @@ class GlobalUserData(BaseGlobalData):
|
|||||||
'extid': profile['extid'],
|
'extid': profile['extid'],
|
||||||
}
|
}
|
||||||
|
|
||||||
profilegame = GameConstants(profile['game'])
|
if profile['game'] == GameConstants.DDR:
|
||||||
if profilegame == GameConstants.DDR:
|
|
||||||
base.update(self.__format_ddr_profile(profile))
|
base.update(self.__format_ddr_profile(profile))
|
||||||
if profilegame == GameConstants.IIDX:
|
if profile['game'] == GameConstants.IIDX:
|
||||||
base.update(self.__format_iidx_profile(profile))
|
base.update(self.__format_iidx_profile(profile))
|
||||||
if profilegame == GameConstants.JUBEAT:
|
if profile['game'] == GameConstants.JUBEAT:
|
||||||
base.update(self.__format_jubeat_profile(profile))
|
base.update(self.__format_jubeat_profile(profile))
|
||||||
if profilegame == GameConstants.MUSECA:
|
if profile['game'] == GameConstants.MUSECA:
|
||||||
base.update(self.__format_museca_profile(profile))
|
base.update(self.__format_museca_profile(profile))
|
||||||
if profilegame == GameConstants.POPN_MUSIC:
|
if profile['game'] == GameConstants.POPN_MUSIC:
|
||||||
base.update(self.__format_popn_profile(profile))
|
base.update(self.__format_popn_profile(profile))
|
||||||
if profilegame == GameConstants.REFLEC_BEAT:
|
if profile['game'] == GameConstants.REFLEC_BEAT:
|
||||||
base.update(self.__format_reflec_profile(profile))
|
base.update(self.__format_reflec_profile(profile))
|
||||||
if profilegame == GameConstants.SDVX:
|
if profile['game'] == GameConstants.SDVX:
|
||||||
base.update(self.__format_sdvx_profile(profile))
|
base.update(self.__format_sdvx_profile(profile))
|
||||||
|
|
||||||
return ValidatedDict(base)
|
return ValidatedDict(base)
|
||||||
@ -135,7 +134,7 @@ class GlobalUserData(BaseGlobalData):
|
|||||||
del profile['match']
|
del profile['match']
|
||||||
|
|
||||||
# Add in our defaults we always provide
|
# Add in our defaults we always provide
|
||||||
profile['game'] = game.value
|
profile['game'] = game
|
||||||
profile['version'] = version if exact_match else 0
|
profile['version'] = version if exact_match else 0
|
||||||
profile['refid'] = refid
|
profile['refid'] = refid
|
||||||
profile['extid'] = extid
|
profile['extid'] = extid
|
||||||
@ -224,7 +223,7 @@ class GlobalUserData(BaseGlobalData):
|
|||||||
extid = self.user.get_extid(game, version, userid)
|
extid = self.user.get_extid(game, version, userid)
|
||||||
|
|
||||||
# Add in our defaults we always provide
|
# Add in our defaults we always provide
|
||||||
profile['game'] = game.value
|
profile['game'] = game
|
||||||
profile['version'] = version if exact_match else 0
|
profile['version'] = version if exact_match else 0
|
||||||
profile['refid'] = refid
|
profile['refid'] = refid
|
||||||
profile['extid'] = extid
|
profile['extid'] = extid
|
||||||
@ -283,7 +282,7 @@ class GlobalUserData(BaseGlobalData):
|
|||||||
extid = self.user.get_extid(game, version, userid)
|
extid = self.user.get_extid(game, version, userid)
|
||||||
|
|
||||||
# Add in our defaults we always provide
|
# Add in our defaults we always provide
|
||||||
profile['game'] = game.value
|
profile['game'] = game
|
||||||
profile['version'] = version
|
profile['version'] = version
|
||||||
profile['refid'] = refid
|
profile['refid'] = refid
|
||||||
profile['extid'] = extid
|
profile['extid'] = extid
|
||||||
|
@ -503,7 +503,7 @@ class UserData(BaseData):
|
|||||||
profile = {
|
profile = {
|
||||||
'refid': result['refid'],
|
'refid': result['refid'],
|
||||||
'extid': result['extid'],
|
'extid': result['extid'],
|
||||||
'game': game.value,
|
'game': game,
|
||||||
'version': version,
|
'version': version,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,7 +602,7 @@ class UserData(BaseData):
|
|||||||
profile = {
|
profile = {
|
||||||
'refid': result['refid'],
|
'refid': result['refid'],
|
||||||
'extid': result['extid'],
|
'extid': result['extid'],
|
||||||
'game': game.value,
|
'game': game,
|
||||||
'version': version,
|
'version': version,
|
||||||
}
|
}
|
||||||
profile.update(self.deserialize(result['data']))
|
profile.update(self.deserialize(result['data']))
|
||||||
|
@ -156,9 +156,9 @@ def viewevents() -> Response:
|
|||||||
'refresh': url_for('admin_pages.listevents', since=-1),
|
'refresh': url_for('admin_pages.listevents', since=-1),
|
||||||
'backfill': url_for('admin_pages.backfillevents', until=-1),
|
'backfill': url_for('admin_pages.backfillevents', until=-1),
|
||||||
'viewuser': url_for('admin_pages.viewuser', userid=-1),
|
'viewuser': url_for('admin_pages.viewuser', userid=-1),
|
||||||
'jubeatsong': url_for('jubeat_pages.viewtopscores', musicid=-1) if g.config.get('support', {}).get(GameConstants.JUBEAT, False) else None,
|
'jubeatsong': url_for('jubeat_pages.viewtopscores', musicid=-1) if GameConstants.JUBEAT in g.config['support'] else None,
|
||||||
'iidxsong': url_for('iidx_pages.viewtopscores', musicid=-1) if g.config.get('support', {}).get(GameConstants.IIDX, False) else None,
|
'iidxsong': url_for('iidx_pages.viewtopscores', musicid=-1) if GameConstants.IIDX in g.config['support'] else None,
|
||||||
'pnmsong': url_for('popn_pages.viewtopscores', musicid=-1) if g.config.get('support', {}).get(GameConstants.POPN_MUSIC, False) else None,
|
'pnmsong': url_for('popn_pages.viewtopscores', musicid=-1) if GameConstants.POPN_MUSIC in g.config['support'] else None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.BISHI_BASHI, False):
|
if GameConstants.BISHI_BASHI in g.config['support']:
|
||||||
# BishiBashi pages
|
# BishiBashi pages
|
||||||
bishi_entries = []
|
bishi_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.BISHI_BASHI]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.BISHI_BASHI]) > 0:
|
||||||
@ -301,7 +301,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.DDR, False):
|
if GameConstants.DDR in g.config['support']:
|
||||||
# DDR pages
|
# DDR pages
|
||||||
ddr_entries = []
|
ddr_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.DDR]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.DDR]) > 0:
|
||||||
@ -350,7 +350,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.IIDX, False):
|
if GameConstants.IIDX in g.config['support']:
|
||||||
# IIDX pages
|
# IIDX pages
|
||||||
iidx_entries = []
|
iidx_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.IIDX]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.IIDX]) > 0:
|
||||||
@ -399,7 +399,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.JUBEAT, False):
|
if GameConstants.JUBEAT in g.config['support']:
|
||||||
# Jubeat pages
|
# Jubeat pages
|
||||||
jubeat_entries = []
|
jubeat_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.JUBEAT]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.JUBEAT]) > 0:
|
||||||
@ -448,7 +448,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.MUSECA, False):
|
if GameConstants.MUSECA in g.config['support']:
|
||||||
# Museca pages
|
# Museca pages
|
||||||
museca_entries = []
|
museca_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.MUSECA]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.MUSECA]) > 0:
|
||||||
@ -493,7 +493,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.POPN_MUSIC, False):
|
if GameConstants.POPN_MUSIC in g.config['support']:
|
||||||
# Pop'n Music pages
|
# Pop'n Music pages
|
||||||
popn_entries = []
|
popn_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.POPN_MUSIC]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.POPN_MUSIC]) > 0:
|
||||||
@ -542,7 +542,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.REFLEC_BEAT, False):
|
if GameConstants.REFLEC_BEAT in g.config['support']:
|
||||||
# ReflecBeat pages
|
# ReflecBeat pages
|
||||||
reflec_entries = []
|
reflec_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.REFLEC_BEAT]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.REFLEC_BEAT]) > 0:
|
||||||
@ -591,7 +591,7 @@ def navigation() -> Dict[str, Any]:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if g.config.get('support', {}).get(GameConstants.SDVX, False):
|
if GameConstants.SDVX in g.config['support']:
|
||||||
# SDVX pages
|
# SDVX pages
|
||||||
sdvx_entries = []
|
sdvx_entries = []
|
||||||
if len([p for p in profiles if p[0] == GameConstants.SDVX]) > 0:
|
if len([p for p in profiles if p[0] == GameConstants.SDVX]) > 0:
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import yaml
|
|
||||||
|
|
||||||
from bemani.data import Data
|
|
||||||
from bemani.api import app, config # noqa: F401
|
from bemani.api import app, config # noqa: F401
|
||||||
|
from bemani.utils.config import load_config as base_load_config
|
||||||
|
|
||||||
|
|
||||||
def load_config(filename: str) -> None:
|
def load_config(filename: str) -> None:
|
||||||
global config
|
global config
|
||||||
|
base_load_config(filename, config)
|
||||||
config.update(yaml.safe_load(open(filename)))
|
|
||||||
config['database']['engine'] = Data.create_engine(config)
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
43
bemani/utils/config.py
Normal file
43
bemani/utils/config.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import yaml
|
||||||
|
from typing import Any, Dict, Set
|
||||||
|
|
||||||
|
from bemani.backend.iidx import IIDXFactory
|
||||||
|
from bemani.backend.popn import PopnMusicFactory
|
||||||
|
from bemani.backend.jubeat import JubeatFactory
|
||||||
|
from bemani.backend.bishi import BishiBashiFactory
|
||||||
|
from bemani.backend.ddr import DDRFactory
|
||||||
|
from bemani.backend.sdvx import SoundVoltexFactory
|
||||||
|
from bemani.backend.reflec import ReflecBeatFactory
|
||||||
|
from bemani.backend.museca import MusecaFactory
|
||||||
|
from bemani.common import GameConstants
|
||||||
|
from bemani.data import Data
|
||||||
|
|
||||||
|
|
||||||
|
def load_config(filename: str, config: Dict[str, Any]) -> None:
|
||||||
|
config.update(yaml.safe_load(open(filename)))
|
||||||
|
config['database']['engine'] = Data.create_engine(config)
|
||||||
|
|
||||||
|
supported_series: Set[GameConstants] = set()
|
||||||
|
for series in GameConstants:
|
||||||
|
if config.get('support', {}).get(series.value, False):
|
||||||
|
supported_series.add(series)
|
||||||
|
config['support'] = supported_series
|
||||||
|
|
||||||
|
|
||||||
|
def register_games(config: Dict[str, Any]) -> None:
|
||||||
|
if GameConstants.POPN_MUSIC in config['support']:
|
||||||
|
PopnMusicFactory.register_all()
|
||||||
|
if GameConstants.JUBEAT in config['support']:
|
||||||
|
JubeatFactory.register_all()
|
||||||
|
if GameConstants.IIDX in config['support']:
|
||||||
|
IIDXFactory.register_all()
|
||||||
|
if GameConstants.BISHI_BASHI in config['support']:
|
||||||
|
BishiBashiFactory.register_all()
|
||||||
|
if GameConstants.DDR in config['support']:
|
||||||
|
DDRFactory.register_all()
|
||||||
|
if GameConstants.SDVX in config['support']:
|
||||||
|
SoundVoltexFactory.register_all()
|
||||||
|
if GameConstants.REFLEC_BEAT in config['support']:
|
||||||
|
ReflecBeatFactory.register_all()
|
||||||
|
if GameConstants.MUSECA in config['support']:
|
||||||
|
MusecaFactory.register_all()
|
@ -1,16 +1,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import yaml
|
|
||||||
|
|
||||||
from bemani.backend.iidx import IIDXFactory
|
|
||||||
from bemani.backend.popn import PopnMusicFactory
|
|
||||||
from bemani.backend.jubeat import JubeatFactory
|
|
||||||
from bemani.backend.bishi import BishiBashiFactory
|
|
||||||
from bemani.backend.ddr import DDRFactory
|
|
||||||
from bemani.backend.sdvx import SoundVoltexFactory
|
|
||||||
from bemani.backend.reflec import ReflecBeatFactory
|
|
||||||
from bemani.backend.museca import MusecaFactory
|
|
||||||
from bemani.common import GameConstants
|
from bemani.common import GameConstants
|
||||||
from bemani.data import Data
|
|
||||||
from bemani.frontend import app, config # noqa: F401
|
from bemani.frontend import app, config # noqa: F401
|
||||||
from bemani.frontend.account import account_pages
|
from bemani.frontend.account import account_pages
|
||||||
from bemani.frontend.admin import admin_pages
|
from bemani.frontend.admin import admin_pages
|
||||||
@ -24,6 +14,7 @@ from bemani.frontend.ddr import ddr_pages
|
|||||||
from bemani.frontend.sdvx import sdvx_pages
|
from bemani.frontend.sdvx import sdvx_pages
|
||||||
from bemani.frontend.reflec import reflec_pages
|
from bemani.frontend.reflec import reflec_pages
|
||||||
from bemani.frontend.museca import museca_pages
|
from bemani.frontend.museca import museca_pages
|
||||||
|
from bemani.utils.config import load_config as base_load_config, register_games as base_register_games
|
||||||
|
|
||||||
|
|
||||||
def register_blueprints() -> None:
|
def register_blueprints() -> None:
|
||||||
@ -34,50 +25,32 @@ def register_blueprints() -> None:
|
|||||||
app.register_blueprint(arcade_pages)
|
app.register_blueprint(arcade_pages)
|
||||||
app.register_blueprint(home_pages)
|
app.register_blueprint(home_pages)
|
||||||
|
|
||||||
if config.get('support', {}).get(GameConstants.IIDX, False):
|
if GameConstants.IIDX in config['support']:
|
||||||
app.register_blueprint(iidx_pages)
|
app.register_blueprint(iidx_pages)
|
||||||
if config.get('support', {}).get(GameConstants.POPN_MUSIC, False):
|
if GameConstants.POPN_MUSIC in config['support']:
|
||||||
app.register_blueprint(popn_pages)
|
app.register_blueprint(popn_pages)
|
||||||
if config.get('support', {}).get(GameConstants.JUBEAT, False):
|
if GameConstants.JUBEAT in config['support']:
|
||||||
app.register_blueprint(jubeat_pages)
|
app.register_blueprint(jubeat_pages)
|
||||||
if config.get('support', {}).get(GameConstants.BISHI_BASHI, False):
|
if GameConstants.BISHI_BASHI in config['support']:
|
||||||
app.register_blueprint(bishi_pages)
|
app.register_blueprint(bishi_pages)
|
||||||
if config.get('support', {}).get(GameConstants.DDR, False):
|
if GameConstants.DDR in config['support']:
|
||||||
app.register_blueprint(ddr_pages)
|
app.register_blueprint(ddr_pages)
|
||||||
if config.get('support', {}).get(GameConstants.SDVX, False):
|
if GameConstants.SDVX in config['support']:
|
||||||
app.register_blueprint(sdvx_pages)
|
app.register_blueprint(sdvx_pages)
|
||||||
if config.get('support', {}).get(GameConstants.REFLEC_BEAT, False):
|
if GameConstants.REFLEC_BEAT in config['support']:
|
||||||
app.register_blueprint(reflec_pages)
|
app.register_blueprint(reflec_pages)
|
||||||
if config.get('support', {}).get(GameConstants.MUSECA, False):
|
if GameConstants.MUSECA in config['support']:
|
||||||
app.register_blueprint(museca_pages)
|
app.register_blueprint(museca_pages)
|
||||||
|
|
||||||
|
|
||||||
def register_games() -> None:
|
def register_games() -> None:
|
||||||
global config
|
global config
|
||||||
|
base_register_games(config)
|
||||||
if config.get('support', {}).get(GameConstants.POPN_MUSIC, False):
|
|
||||||
PopnMusicFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.JUBEAT, False):
|
|
||||||
JubeatFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.IIDX, False):
|
|
||||||
IIDXFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.BISHI_BASHI, False):
|
|
||||||
BishiBashiFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.DDR, False):
|
|
||||||
DDRFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.SDVX, False):
|
|
||||||
SoundVoltexFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.REFLEC_BEAT, False):
|
|
||||||
ReflecBeatFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.MUSECA, False):
|
|
||||||
MusecaFactory.register_all()
|
|
||||||
|
|
||||||
|
|
||||||
def load_config(filename: str) -> None:
|
def load_config(filename: str) -> None:
|
||||||
global config
|
global config
|
||||||
|
base_load_config(filename, config)
|
||||||
config.update(yaml.safe_load(open(filename)))
|
|
||||||
config['database']['engine'] = Data.create_engine(config)
|
|
||||||
app.secret_key = config['secret_key']
|
app.secret_key = config['secret_key']
|
||||||
|
|
||||||
|
|
||||||
|
@ -3656,7 +3656,13 @@ if __name__ == "__main__":
|
|||||||
# Load the config so we can talk to the server
|
# Load the config so we can talk to the server
|
||||||
config = yaml.safe_load(open(args.config))
|
config = yaml.safe_load(open(args.config))
|
||||||
|
|
||||||
if args.series == GameConstants.POPN_MUSIC:
|
series = None
|
||||||
|
try:
|
||||||
|
series = GameConstants(args.series)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if series == GameConstants.POPN_MUSIC:
|
||||||
popn = ImportPopn(config, args.version, args.no_combine, args.update)
|
popn = ImportPopn(config, args.version, args.no_combine, args.update)
|
||||||
if args.bin:
|
if args.bin:
|
||||||
songs = popn.scrape(args.bin)
|
songs = popn.scrape(args.bin)
|
||||||
@ -3670,7 +3676,7 @@ if __name__ == "__main__":
|
|||||||
popn.import_music_db(songs)
|
popn.import_music_db(songs)
|
||||||
popn.close()
|
popn.close()
|
||||||
|
|
||||||
elif args.series == GameConstants.JUBEAT:
|
elif series == GameConstants.JUBEAT:
|
||||||
jubeat = ImportJubeat(config, args.version, args.no_combine, args.update)
|
jubeat = ImportJubeat(config, args.version, args.no_combine, args.update)
|
||||||
if args.tsv is not None:
|
if args.tsv is not None:
|
||||||
# Special case for Jubeat, grab the title/artist metadata that was
|
# Special case for Jubeat, grab the title/artist metadata that was
|
||||||
@ -3691,7 +3697,7 @@ if __name__ == "__main__":
|
|||||||
jubeat.import_emblems(emblems)
|
jubeat.import_emblems(emblems)
|
||||||
jubeat.close()
|
jubeat.close()
|
||||||
|
|
||||||
elif args.series == GameConstants.IIDX:
|
elif series == GameConstants.IIDX:
|
||||||
iidx = ImportIIDX(config, args.version, args.no_combine, args.update)
|
iidx = ImportIIDX(config, args.version, args.no_combine, args.update)
|
||||||
if args.tsv is not None:
|
if args.tsv is not None:
|
||||||
# Special case for IIDX, grab the title/artist metadata that was
|
# Special case for IIDX, grab the title/artist metadata that was
|
||||||
@ -3712,7 +3718,7 @@ if __name__ == "__main__":
|
|||||||
iidx.import_qpros(qpros)
|
iidx.import_qpros(qpros)
|
||||||
iidx.close()
|
iidx.close()
|
||||||
|
|
||||||
elif args.series == GameConstants.DDR:
|
elif series == GameConstants.DDR:
|
||||||
ddr = ImportDDR(config, args.version, args.no_combine, args.update)
|
ddr = ImportDDR(config, args.version, args.no_combine, args.update)
|
||||||
if args.server and args.token:
|
if args.server and args.token:
|
||||||
songs = ddr.lookup(args.server, args.token)
|
songs = ddr.lookup(args.server, args.token)
|
||||||
@ -3735,7 +3741,7 @@ if __name__ == "__main__":
|
|||||||
ddr.import_music_db(songs)
|
ddr.import_music_db(songs)
|
||||||
ddr.close()
|
ddr.close()
|
||||||
|
|
||||||
elif args.series == GameConstants.SDVX:
|
elif series == GameConstants.SDVX:
|
||||||
sdvx = ImportSDVX(config, args.version, args.no_combine, args.update)
|
sdvx = ImportSDVX(config, args.version, args.no_combine, args.update)
|
||||||
if args.server and args.token:
|
if args.server and args.token:
|
||||||
sdvx.import_from_server(args.server, args.token)
|
sdvx.import_from_server(args.server, args.token)
|
||||||
@ -3754,7 +3760,7 @@ if __name__ == "__main__":
|
|||||||
sdvx.import_appeal_cards(args.csv)
|
sdvx.import_appeal_cards(args.csv)
|
||||||
sdvx.close()
|
sdvx.close()
|
||||||
|
|
||||||
elif args.series == GameConstants.MUSECA:
|
elif series == GameConstants.MUSECA:
|
||||||
museca = ImportMuseca(config, args.version, args.no_combine, args.update)
|
museca = ImportMuseca(config, args.version, args.no_combine, args.update)
|
||||||
if args.server and args.token:
|
if args.server and args.token:
|
||||||
museca.import_from_server(args.server, args.token)
|
museca.import_from_server(args.server, args.token)
|
||||||
@ -3767,7 +3773,7 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
museca.close()
|
museca.close()
|
||||||
|
|
||||||
elif args.series == GameConstants.REFLEC_BEAT:
|
elif series == GameConstants.REFLEC_BEAT:
|
||||||
reflec = ImportReflecBeat(config, args.version, args.no_combine, args.update)
|
reflec = ImportReflecBeat(config, args.version, args.no_combine, args.update)
|
||||||
if args.bin is not None:
|
if args.bin is not None:
|
||||||
songs = reflec.scrape(args.bin)
|
songs = reflec.scrape(args.bin)
|
||||||
@ -3781,7 +3787,7 @@ if __name__ == "__main__":
|
|||||||
reflec.import_music_db(songs)
|
reflec.import_music_db(songs)
|
||||||
reflec.close()
|
reflec.close()
|
||||||
|
|
||||||
elif args.series == GameConstants.DANCE_EVOLUTION:
|
elif series == GameConstants.DANCE_EVOLUTION:
|
||||||
danevo = ImportDanceEvolution(config, args.version, args.no_combine, args.update)
|
danevo = ImportDanceEvolution(config, args.version, args.no_combine, args.update)
|
||||||
if args.server and args.token:
|
if args.server and args.token:
|
||||||
songs = danevo.lookup(args.server, args.token)
|
songs = danevo.lookup(args.server, args.token)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import yaml
|
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
from bemani.backend.popn import PopnMusicFactory
|
from bemani.backend.popn import PopnMusicFactory
|
||||||
@ -20,6 +19,7 @@ from bemani.frontend.reflec import ReflecBeatCache
|
|||||||
from bemani.frontend.museca import MusecaCache
|
from bemani.frontend.museca import MusecaCache
|
||||||
from bemani.common import GameConstants, Time
|
from bemani.common import GameConstants, Time
|
||||||
from bemani.data import Data
|
from bemani.data import Data
|
||||||
|
from bemani.utils.config import load_config
|
||||||
|
|
||||||
|
|
||||||
def run_scheduled_work(config: Dict[str, Any]) -> None:
|
def run_scheduled_work(config: Dict[str, Any]) -> None:
|
||||||
@ -28,28 +28,28 @@ def run_scheduled_work(config: Dict[str, Any]) -> None:
|
|||||||
# Only run scheduled work for enabled components
|
# Only run scheduled work for enabled components
|
||||||
enabled_factories: List[Any] = []
|
enabled_factories: List[Any] = []
|
||||||
enabled_caches: List[Any] = []
|
enabled_caches: List[Any] = []
|
||||||
if config.get('support', {}).get(GameConstants.IIDX, False):
|
if GameConstants.IIDX in config['support']:
|
||||||
enabled_factories.append(IIDXFactory)
|
enabled_factories.append(IIDXFactory)
|
||||||
enabled_caches.append(IIDXCache)
|
enabled_caches.append(IIDXCache)
|
||||||
if config.get('support', {}).get(GameConstants.POPN_MUSIC, False):
|
if GameConstants.POPN_MUSIC in config['support']:
|
||||||
enabled_factories.append(PopnMusicFactory)
|
enabled_factories.append(PopnMusicFactory)
|
||||||
enabled_caches.append(PopnMusicCache)
|
enabled_caches.append(PopnMusicCache)
|
||||||
if config.get('support', {}).get(GameConstants.JUBEAT, False):
|
if GameConstants.JUBEAT in config['support']:
|
||||||
enabled_factories.append(JubeatFactory)
|
enabled_factories.append(JubeatFactory)
|
||||||
enabled_caches.append(JubeatCache)
|
enabled_caches.append(JubeatCache)
|
||||||
if config.get('support', {}).get(GameConstants.BISHI_BASHI, False):
|
if GameConstants.BISHI_BASHI in config['support']:
|
||||||
enabled_factories.append(BishiBashiFactory)
|
enabled_factories.append(BishiBashiFactory)
|
||||||
enabled_caches.append(BishiBashiCache)
|
enabled_caches.append(BishiBashiCache)
|
||||||
if config.get('support', {}).get(GameConstants.DDR, False):
|
if GameConstants.DDR in config['support']:
|
||||||
enabled_factories.append(DDRFactory)
|
enabled_factories.append(DDRFactory)
|
||||||
enabled_caches.append(DDRCache)
|
enabled_caches.append(DDRCache)
|
||||||
if config.get('support', {}).get(GameConstants.SDVX, False):
|
if GameConstants.SDVX in config['support']:
|
||||||
enabled_factories.append(SoundVoltexFactory)
|
enabled_factories.append(SoundVoltexFactory)
|
||||||
enabled_caches.append(SoundVoltexCache)
|
enabled_caches.append(SoundVoltexCache)
|
||||||
if config.get('support', {}).get(GameConstants.REFLEC_BEAT, False):
|
if GameConstants.REFLEC_BEAT in config['support']:
|
||||||
enabled_factories.append(ReflecBeatFactory)
|
enabled_factories.append(ReflecBeatFactory)
|
||||||
enabled_caches.append(ReflecBeatCache)
|
enabled_caches.append(ReflecBeatCache)
|
||||||
if config.get('support', {}).get(GameConstants.MUSECA, False):
|
if GameConstants.MUSECA in config['support']:
|
||||||
enabled_factories.append(MusecaFactory)
|
enabled_factories.append(MusecaFactory)
|
||||||
enabled_caches.append(MusecaCache)
|
enabled_caches.append(MusecaCache)
|
||||||
|
|
||||||
@ -75,8 +75,8 @@ if __name__ == '__main__':
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Set up global configuration
|
# Set up global configuration
|
||||||
config = yaml.safe_load(open(args.config))
|
config: Dict[str, Any] = {}
|
||||||
config['database']['engine'] = Data.create_engine(config)
|
load_config(args.config, config)
|
||||||
|
|
||||||
# Run out of band work
|
# Run out of band work
|
||||||
run_scheduled_work(config)
|
run_scheduled_work(config)
|
||||||
|
@ -1,22 +1,13 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import copy
|
import copy
|
||||||
import traceback
|
import traceback
|
||||||
import yaml
|
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
from flask import Flask, request, redirect, Response, make_response
|
from flask import Flask, request, redirect, Response, make_response
|
||||||
|
|
||||||
from bemani.protocol import EAmuseProtocol
|
from bemani.protocol import EAmuseProtocol
|
||||||
from bemani.backend import Dispatch, UnrecognizedPCBIDException
|
from bemani.backend import Dispatch, UnrecognizedPCBIDException
|
||||||
from bemani.backend.iidx import IIDXFactory
|
|
||||||
from bemani.backend.popn import PopnMusicFactory
|
|
||||||
from bemani.backend.jubeat import JubeatFactory
|
|
||||||
from bemani.backend.bishi import BishiBashiFactory
|
|
||||||
from bemani.backend.ddr import DDRFactory
|
|
||||||
from bemani.backend.sdvx import SoundVoltexFactory
|
|
||||||
from bemani.backend.reflec import ReflecBeatFactory
|
|
||||||
from bemani.backend.museca import MusecaFactory
|
|
||||||
from bemani.common import GameConstants
|
|
||||||
from bemani.data import Data
|
from bemani.data import Data
|
||||||
|
from bemani.utils.config import load_config as base_load_config, register_games as base_register_games
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -125,32 +116,14 @@ def receive_request(path: str) -> Response:
|
|||||||
dataprovider.close()
|
dataprovider.close()
|
||||||
|
|
||||||
|
|
||||||
def load_config(filename: str) -> None:
|
|
||||||
global config
|
|
||||||
|
|
||||||
config.update(yaml.safe_load(open(filename)))
|
|
||||||
config['database']['engine'] = Data.create_engine(config)
|
|
||||||
|
|
||||||
|
|
||||||
def register_games() -> None:
|
def register_games() -> None:
|
||||||
global config
|
global config
|
||||||
|
base_register_games(config)
|
||||||
|
|
||||||
if config.get('support', {}).get(GameConstants.POPN_MUSIC, False):
|
|
||||||
PopnMusicFactory.register_all()
|
def load_config(filename: str) -> None:
|
||||||
if config.get('support', {}).get(GameConstants.JUBEAT, False):
|
global config
|
||||||
JubeatFactory.register_all()
|
base_load_config(filename, config)
|
||||||
if config.get('support', {}).get(GameConstants.IIDX, False):
|
|
||||||
IIDXFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.BISHI_BASHI, False):
|
|
||||||
BishiBashiFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.DDR, False):
|
|
||||||
DDRFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.REFLEC_BEAT, False):
|
|
||||||
ReflecBeatFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.SDVX, False):
|
|
||||||
SoundVoltexFactory.register_all()
|
|
||||||
if config.get('support', {}).get(GameConstants.MUSECA, False):
|
|
||||||
MusecaFactory.register_all()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -160,7 +133,7 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument("-r", "--profile", help="Turn on profiling for services, writing CProfile data to the currenct directory", action="store_true")
|
parser.add_argument("-r", "--profile", help="Turn on profiling for services, writing CProfile data to the currenct directory", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Set up global configuration, overriding config port for convenience
|
# Set up global configuration, overriding config port for convenience in debugging.
|
||||||
load_config(args.config)
|
load_config(args.config)
|
||||||
config['server']['port'] = args.port
|
config['server']['port'] = args.port
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user