# Path: constants/exceptions.py
# class invalidArgumentsException(Exception):
# class loginFailedException(Exception):
# class userBannedException(Exception):
# class userLockedException(Exception):
# class noBanchoSessionException(Exception):
# class osuApiFailException(Exception):
# class fileNotFoundException(Exception):
# class invalidBeatmapException(Exception):
# class unsupportedGameModeException(Exception):
# class beatmapTooLongException(Exception):
# class need2FAException(Exception):
# class noAPIDataError(Exception):
# class scoreNotFoundError(Exception):
# class ppCalcException(Exception):
# 	def __init__(self, handler):
# 	def __init__(self, handler, who):
# 	def __init__(self, handler, who):
# 	def __init__(self, handler, who):
# 	def __init__(self, handler, who, ip):
# 	def __init__(self, handler):
# 	def __init__(self, handler, f):
# 	def __init__(self, handler):
# 	def __init__(self, handler, who, ip):
# 	def __init__(self, exception):
# 
# Path: helpers/osuapiHelper.py
# def osuApiRequest(request, params, getFirst=True):
# def getOsuFileFromName(fileName):
# def getOsuFileFromID(beatmapID):
# 		URL = "{}/web/maps/{}".format(glob.conf["OSU_API_URL"], quote(fileName))
# 		URL = "{}/osu/{}".format(glob.conf["OSU_API_URL"], beatmapID)
# 
# Path: pp/ez.py
# MODULE_NAME = "ez"
# class Ez:
# 	def __init__(self, beatmap_, score_=None, acc=None, mods_=None, tillerino=False, gameMode=gameModes.STD):
# 	def _calculatePP(self):
# 	def calculatePP(self):
# 
# Path: pp/cicciobello.py
# class Cicciobello:
#     def __init__(self, beatmap_, score_=None, accuracy=1, mods_=mods.NOMOD, combo=None, misses=0, tillerino=False):
#     def unrelaxMods(self):
#     def _calculate_pp(self):
#     def calculate_pp(self):
# 
# Path: pp/wifipiano3.py
# class PianoError(Exception):
# class WiFiPiano:
# 	def __init__(self, beatmap_, score_):
# 	def _runProcess(self):
# 	def getPP(self):
# 	def mapPath(self):


import json
import tornado.gen
import tornado.web
from objects import beatmap
from common.constants import gameModes
from common.log import logUtils as log
from common.web import requestsManager
from constants import exceptions
from helpers import osuapiHelper
from pp import ez, cicciobello, wifipiano3
from common.sentry import sentry




class handler(requestsManager.asyncRequestHandler):
	"""
	Handler for /api/v1/pp
	"""
	MODULE_NAME = "api/pp"

	@tornado.web.asynchronous
	@tornado.gen.engine
	@sentry.captureTornado
	def asyncGet(self):
		statusCode = 400
		data = {"message": "unknown error"}
		try:
			# Check arguments
			if not requestsManager.checkArguments(self.request.arguments, ["b"]):

# Path: constants/exceptions.py
# class invalidArgumentsException(Exception):
# class loginFailedException(Exception):
# class userBannedException(Exception):
# class userLockedException(Exception):
# class noBanchoSessionException(Exception):
# class osuApiFailException(Exception):
# class fileNotFoundException(Exception):
# class invalidBeatmapException(Exception):
# class unsupportedGameModeException(Exception):
# class beatmapTooLongException(Exception):
# class need2FAException(Exception):
# class noAPIDataError(Exception):
# class scoreNotFoundError(Exception):
# class ppCalcException(Exception):
# 	def __init__(self, handler):
# 	def __init__(self, handler, who):
# 	def __init__(self, handler, who):
# 	def __init__(self, handler, who):
# 	def __init__(self, handler, who, ip):
# 	def __init__(self, handler):
# 	def __init__(self, handler, f):
# 	def __init__(self, handler):
# 	def __init__(self, handler, who, ip):
# 	def __init__(self, exception):
# 
# Path: helpers/osuapiHelper.py
# def osuApiRequest(request, params, getFirst=True):
# def getOsuFileFromName(fileName):
# def getOsuFileFromID(beatmapID):
# 		URL = "{}/web/maps/{}".format(glob.conf["OSU_API_URL"], quote(fileName))
# 		URL = "{}/osu/{}".format(glob.conf["OSU_API_URL"], beatmapID)
# 
# Path: pp/ez.py
# MODULE_NAME = "ez"
# class Ez:
# 	def __init__(self, beatmap_, score_=None, acc=None, mods_=None, tillerino=False, gameMode=gameModes.STD):
# 	def _calculatePP(self):
# 	def calculatePP(self):
# 
# Path: pp/cicciobello.py
# class Cicciobello:
#     def __init__(self, beatmap_, score_=None, accuracy=1, mods_=mods.NOMOD, combo=None, misses=0, tillerino=False):
#     def unrelaxMods(self):
#     def _calculate_pp(self):
#     def calculate_pp(self):
# 
# Path: pp/wifipiano3.py
# class PianoError(Exception):
# class WiFiPiano:
# 	def __init__(self, beatmap_, score_):
# 	def _runProcess(self):
# 	def getPP(self):
# 	def mapPath(self):


# Path: handlers/apiPPHandler.py
import json
import tornado.gen
import tornado.web
from objects import beatmap
from common.constants import gameModes
from common.log import logUtils as log
from common.web import requestsManager
from constants import exceptions
from helpers import osuapiHelper
from pp import ez, cicciobello, wifipiano3
from common.sentry import sentry





class handler(requestsManager.asyncRequestHandler):
	"""
	Handler for /api/v1/pp
	"""
	MODULE_NAME = "api/pp"

	@tornado.web.asynchronous
	@tornado.gen.engine
	@sentry.captureTornado
	def asyncGet(self):
		statusCode = 400
		data = {"message": "unknown error"}
		try:
			# Check arguments
			if not requestsManager.checkArguments(self.request.arguments, ["b"]):

				raise exceptions.invalidArgumentsException(self.MODULE_NAME)