class Config:
	def __init__(self):
		self._config = {
			"DEBUG": config("DEBUG", default="0", cast=bool),

			"DB_HOST": config("DB_HOST", default="localhost"),
			"DB_PORT": config("DB_PORT", default="3306", cast=int),
			"DB_USERNAME": config("DB_USERNAME", default="ripple"),
			"DB_PASSWORD": config("DB_PASSWORD", default="changeme"),
			"DB_NAME": config("DB_NAME", default="ripple"),
			# "DB_WORKERS": config("DB_WORKERS", default="8", cast=int),

			"REDIS_HOST": config("REDIS_HOST", default="127.0.0.1"),
			"REDIS_PORT": config("REDIS_PORT", default="6379", cast=int),
			"REDIS_DATABASE": config("REDIS_DATABASE", default="0", cast=int),
			"REDIS_PASSWORD": config("REDIS_PASSWORD", default=None),

			"HTTP_HOST": config("HTTP_HOST", default="0.0.0.0"),
			"HTTP_PORT": config("HTTP_PORT", default="5002", cast=int),

			"BEATMAP_CACHE_EXPIRE": config("BEATMAP_CACHE_EXPIRE", default="86400", cast=int),

			"SERVER_URL": config("SERVER_URL", default="http://127.0.0.1:5002"),
			"BANCHO_URL": config("BANCHO_URL", default="http://127.0.0.1:5001"),
			"BANCHO_API_KEY": config("BANCHO_API_KEY", default="changeme"),

			"THREADS": config("THREADS", default="16", cast=int),
			# "REPLAYS_FOLDERS": config("REPLAYS_FOLDERS", default=".data/replays", cast=Csv(str)),
			"REPLAYS_FOLDER": config("REPLAYS_FOLDER", default=".data/local_replays"),
			"BEATMAPS_FOLDER": config("BEATMAPS_FOLDER", default=".data/beatmaps", cast=str),
			"SCREENSHOTS_FOLDER": config("SCREENSHOTS_FOLDER", default=".data/screenshots", cast=str),

			"SENTRY_DSN": config("SENTRY_DSN", default=""),

			"DATADOG_API_KEY": config("DATADOG_API_KEY", default=""),
			"DATADOG_APP_KEY": config("DATADOG_APP_KEY", default=""),

			"PROMETHEUS_PORT": config("PROMETHEUS_PORT", default=""),

			"OSU_API_ENABLE": config("OSU_API_ENABLE", default="1", cast=bool),
			"OSU_API_URL": config("OSU_API_URL", default="https://osu.ppy.sh"),
			"OSU_API_KEY": config("OSU_API_KEY", default=""),

			"CHEESEGULL_API_URL": config("CHEESEGULL_API_URL", default="http://cheesegu.ll/api"),

			"SCHIAVO_URL": config("SCHIAVO_URL", default=""),
			"DISCORD_SECRET_WEB_HOOK": config("DISCORD_SECRET_WEB_HOOK", default=""),

			"CONO_ENABLE": config("CONO_ENABLE", default="0", cast=bool),

			"FOKABOT_API_BASE": config("FOKABOT_API_BASE", default="http://127.0.0.1:4334"),
			"FOKABOT_API_SECRET": config("FOKABOT_API_SECRET", default=""),

			"S3_ENDPOINT_URL": config("S3_ENDPOINT_URL", default="https://s3.fr-par.scw.cloud"),
			"S3_REGION": config("S3_REGION", default="fr-par"),
			"S3_ACCESS_KEY_ID": config("S3_ACCESS_KEY_ID", default=""),
			"S3_SECRET_ACCESS_KEY": config("S3_SECRET_ACCESS_KEY", default=""),

			"S3_SCREENSHOTS_ENDPOINT_URL": config("S3_SCREENSHOTS_ENDPOINT_URL", default="https://s3.fr-par.scw.cloud"),
			"S3_SCREENSHOTS_REGION": config("S3_SCREENSHOTS_REGION", default="fr-par"),
			"S3_SCREENSHOTS_BUCKET": config("S3_SCREENSHOTS_BUCKET", default=""),

			"FAILED_REPLAYS_FOLDER": config("FAILED_REPLAYS_FOLDER", default=".data/failed_replays")
		}

	@property
	def sentry_enabled(self):
		return bool(self["SENTRY_DSN"])

	@property
	def datadog_enabled(self):
		return bool(self["DATADOG_API_KEY"]) and bool(self["DATADOG_APP_KEY"])

	@property
	def schiavo_enabled(self):
		return bool(self["SCHIAVO_URL"])

	@property
	def s3_enabled(self):
		return bool(self["S3_ACCESS_KEY_ID"]) and bool(self["S3_SECRET_ACCESS_KEY"])

	def __getitem__(self, item):
		return self._config[item]

	def __setitem__(self, key, value):
		self._config[key] = value class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "api/cacheBeatmap"
	def asyncPost(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "rate"
	def asyncGet(self): class ChangelogDate:
class ChangelogEntry:
class handler(requestsManager.asyncRequestHandler):
    def __init__(self, timestamp):
    def __str__(self):
    def __init__(self, timestamp, author, description, repo):
    def description(self):
    def symbol(self):
    def __str__(self):
    def asyncGet(self):
    MODULE_NAME = "changelog" class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "api/pp"
	def asyncGet(self):
def calculatePPFromAcc(ppcalc, acc): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "api/status"
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "bancho_connect"
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "check_updates"
	def asyncGet(self):
 class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "default"
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "direct_download"
	def asyncGet(self, bid): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "empty"
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "get_full_replay"
	def asyncGet(self, replayID): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "get_replay"
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "get_screenshot"
	def asyncGet(self, screenshotID = None): class handler(requestsManager.asyncRequestHandler):
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "osu_download"
	def asyncGet(self, fileName = None): class handler(requestsManager.asyncRequestHandler):
	def asyncGet(self):
 class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "osu_direct_search"
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "osu_direct_np"
	def asyncGet(self): class handler(requestsManager.asyncRequestHandler):
	def initialize(self, destination):
	def asyncGet(self, args=()): MODULE_NAME = "screenshot"
class handler(requestsManager.asyncRequestHandler):
	def asyncPost(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "comments"
	CLIENT_WHO = {"normal": "", "player": "player", "admin": "bat", "donor": "subscriber"}
	def asyncPost(self):
	def clientWho(y):
	def _getComments(self):
	def _addComment(self): class handler(requestsManager.asyncRequestHandler):
	MODULE_NAME = "seasonal"
	def asyncGet(self): ASCII = """ (                 (     
 )\\ )        *   ) )\\ )  
(()/(  (   ` )  /((()/(  
 /(_)) )\\   ( )(_))/(_)) 
(_))  ((_) (_(_())(_))   
| |   | __||_   _|/ __|  
| |__ | _|   | |  \\__ \\  
|____||___|  |_|  |___/  \n"""
def printServerStartHeader(asciiArt): 		VERSION = f.read().strip()
	VERSION = "Unknown"
ACHIEVEMENTS_VERSION = 1
DATADOG_PREFIX = "lets" def updateSet(beatmapSetID):
	def __init__(self):
	def handle(self, data):
class handler(generalPubSubHandler.generalPubSubHandler):
import argparse
import logging
import signal
import os
import sys
import tornado.gen
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.netutil
import redis
import prometheus_client
import secret.achievements.utils
from helpers.config import Config
from multiprocessing.pool import ThreadPool
from raven.contrib.tornado import AsyncSentryClient
from common.db import dbConnector
from common.ddog import datadogClient
from common.redis import pubSub
from common.web import schiavo
from handlers import apiCacheBeatmapHandler, rateHandler, changelogHandler
from handlers import apiPPHandler
from handlers import apiStatusHandler
from handlers import banchoConnectHandler
from handlers import checkUpdatesHandler
from handlers import defaultHandler
from handlers import downloadMapHandler
from handlers import emptyHandler
from handlers import getFullReplayHandler
from handlers import getReplayHandler
from handlers import getScoresHandler
from handlers import getScreenshotHandler
from handlers import loadTestHandler
from handlers import mapsHandler
from handlers import osuErrorHandler
from handlers import osuSearchHandler
from handlers import osuSearchSetHandler
from handlers import redirectHandler
from handlers import submitModularHandler
from handlers import uploadScreenshotHandler
from handlers import commentHandler
from handlers import seasonalHandler
from helpers import consoleHelper
from common import agpl
from objects import glob
from pubSubHandlers import beatmapUpdateHandler
# General imports

logging.basicConfig(level=logging.DEBUG if Config()["DEBUG"] else logging.INFO)





def make_app():
	return tornado.web.Application([
		(r"/web/bancho_connect.php", banchoConnectHandler.handler),
		(r"/web/osu-osz2-getscores.php", getScoresHandler.handler),
		(r"/web/osu-submit-modular.php", submitModularHandler.handler),
		(r"/web/osu-submit-modular-selector.php", submitModularHandler.handler),
		(r"/web/osu-getreplay.php", getReplayHandler.handler),
		(r"/web/osu-screenshot.php", uploadScreenshotHandler.handler),
		(r"/web/osu-search.php", osuSearchHandler.handler),
		(r"/web/osu-search-set.php", osuSearchSetHandler.handler),
		(r"/web/check-updates.php", checkUpdatesHandler.handler),
		(r"/web/osu-error.php", osuErrorHandler.handler),
		(r"/web/osu-comment.php", commentHandler.handler),
		(r"/web/osu-rate.php", rateHandler.handler),
		(r"/p/changelog", changelogHandler.handler),

		(r"/ss/(.*)", getScreenshotHandler.handler),