2019-12-08 22:43:49 +01:00
|
|
|
import argparse
|
2021-09-05 13:29:43 +02:00
|
|
|
|
2019-12-08 22:43:49 +01:00
|
|
|
from bemani.common import GameConstants
|
|
|
|
from bemani.frontend import app, config # noqa: F401
|
|
|
|
from bemani.frontend.account import account_pages
|
|
|
|
from bemani.frontend.admin import admin_pages
|
|
|
|
from bemani.frontend.arcade import arcade_pages
|
|
|
|
from bemani.frontend.home import home_pages
|
|
|
|
from bemani.frontend.iidx import iidx_pages
|
|
|
|
from bemani.frontend.popn import popn_pages
|
|
|
|
from bemani.frontend.bishi import bishi_pages
|
2021-09-04 17:17:22 +02:00
|
|
|
from bemani.frontend.mga import mga_pages
|
2019-12-08 22:43:49 +01:00
|
|
|
from bemani.frontend.jubeat import jubeat_pages
|
|
|
|
from bemani.frontend.ddr import ddr_pages
|
|
|
|
from bemani.frontend.sdvx import sdvx_pages
|
|
|
|
from bemani.frontend.reflec import reflec_pages
|
|
|
|
from bemani.frontend.museca import museca_pages
|
2021-08-19 21:25:10 +02:00
|
|
|
from bemani.utils.config import load_config as base_load_config, register_games as base_register_games
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def register_blueprints() -> None:
|
|
|
|
global config
|
|
|
|
|
|
|
|
app.register_blueprint(account_pages)
|
|
|
|
app.register_blueprint(admin_pages)
|
|
|
|
app.register_blueprint(arcade_pages)
|
|
|
|
app.register_blueprint(home_pages)
|
|
|
|
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.IIDX in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(iidx_pages)
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.POPN_MUSIC in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(popn_pages)
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.JUBEAT in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(jubeat_pages)
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.BISHI_BASHI in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(bishi_pages)
|
2021-09-04 17:17:22 +02:00
|
|
|
if GameConstants.MGA in config.support:
|
|
|
|
app.register_blueprint(mga_pages)
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.DDR in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(ddr_pages)
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.SDVX in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(sdvx_pages)
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.REFLEC_BEAT in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(reflec_pages)
|
2021-08-20 06:43:59 +02:00
|
|
|
if GameConstants.MUSECA in config.support:
|
2019-12-08 22:43:49 +01:00
|
|
|
app.register_blueprint(museca_pages)
|
|
|
|
|
|
|
|
|
|
|
|
def register_games() -> None:
|
|
|
|
global config
|
2021-08-19 21:25:10 +02:00
|
|
|
base_register_games(config)
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def load_config(filename: str) -> None:
|
|
|
|
global config
|
2021-08-19 21:25:10 +02:00
|
|
|
base_load_config(filename, config)
|
2021-08-20 06:43:59 +02:00
|
|
|
app.secret_key = config.secret_key
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
parser = argparse.ArgumentParser(description="A front end services provider for eAmusement games.")
|
|
|
|
parser.add_argument("-p", "--port", help="Port to listen on. Defaults to 80", type=int, default=80)
|
|
|
|
parser.add_argument("-c", "--config", help="Core configuration. Defaults to server.yaml", type=str, default="server.yaml")
|
2021-08-12 17:57:54 +02:00
|
|
|
parser.add_argument("-r", "--profile", help="Turn on profiling for front end, writing CProfile data to the currenct directory", action="store_true")
|
2021-08-20 21:37:26 +02:00
|
|
|
parser.add_argument("-o", "--read-only", action="store_true", help="Force the database into read-only mode.")
|
2019-12-08 22:43:49 +01:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Set up app
|
|
|
|
load_config(args.config)
|
2021-08-20 21:37:26 +02:00
|
|
|
if args.read_only:
|
|
|
|
config['database']['read_only'] = True
|
2019-12-08 22:43:49 +01:00
|
|
|
|
|
|
|
# Register all blueprints
|
|
|
|
register_blueprints()
|
|
|
|
|
|
|
|
# Register all games
|
|
|
|
register_games()
|
|
|
|
|
|
|
|
if args.profile:
|
2021-05-31 20:07:03 +02:00
|
|
|
from werkzeug.contrib.profiler import ProfilerMiddleware
|
2019-12-08 22:43:49 +01:00
|
|
|
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, profile_dir='.') # type: ignore
|
|
|
|
|
|
|
|
# Run the app
|
|
|
|
app.run(host='0.0.0.0', port=args.port, debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|