# 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
			osuapiData = osuapiHelper.osuApiRequest("get_beatmaps", "b={}".format(beatmapID))
			if osuapiData is None or "file_md5" not in osuapiData or "beatmapset_id" not in osuapiData:
				raise exceptions.invalidBeatmapException(self.MODULE_NAME)
			beatmapMd5 = osuapiData["file_md5"]
			beatmapSetID = osuapiData["beatmapset_id"]

			# Create beatmap object
			bmap = beatmap.beatmap(beatmapMd5, beatmapSetID)

			# Check beatmap length
			if bmap.hitLength > 900:
				raise exceptions.beatmapTooLongException(self.MODULE_NAME)

			if gameMode == gameModes.STD and bmap.starsStd == 0:
				# Mode Specific beatmap, auto detect game mode
				if bmap.starsTaiko > 0:
					gameMode = gameModes.TAIKO
				if bmap.starsCtb > 0:
					gameMode = gameModes.CTB
				if bmap.starsMania > 0:
					gameMode = gameModes.MANIA

			# Calculate pp
			if gameMode in (gameModes.STD, gameModes.TAIKO):
				# osu!standard and osu!taiko
				oppai = ez.Ez(bmap, mods_=modsEnum, tillerino=accuracy is None, acc=accuracy, gameMode=gameMode)
				bmap.starsStd = oppai.stars
				returnPP = oppai.pp
			elif gameMode == gameModes.CTB:
				# osu!catch

# 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

			osuapiData = osuapiHelper.osuApiRequest("get_beatmaps", "b={}".format(beatmapID))
			if osuapiData is None or "file_md5" not in osuapiData or "beatmapset_id" not in osuapiData:
				raise exceptions.invalidBeatmapException(self.MODULE_NAME)
			beatmapMd5 = osuapiData["file_md5"]
			beatmapSetID = osuapiData["beatmapset_id"]

			# Create beatmap object
			bmap = beatmap.beatmap(beatmapMd5, beatmapSetID)

			# Check beatmap length
			if bmap.hitLength > 900:
				raise exceptions.beatmapTooLongException(self.MODULE_NAME)

			if gameMode == gameModes.STD and bmap.starsStd == 0:
				# Mode Specific beatmap, auto detect game mode
				if bmap.starsTaiko > 0:
					gameMode = gameModes.TAIKO
				if bmap.starsCtb > 0:
					gameMode = gameModes.CTB
				if bmap.starsMania > 0:
					gameMode = gameModes.MANIA

			# Calculate pp
			if gameMode in (gameModes.STD, gameModes.TAIKO):
				# osu!standard and osu!taiko
				oppai = ez.Ez(bmap, mods_=modsEnum, tillerino=accuracy is None, acc=accuracy, gameMode=gameMode)
				bmap.starsStd = oppai.stars
				returnPP = oppai.pp
			elif gameMode == gameModes.CTB:
				# osu!catch

				ciccio = cicciobello.Cicciobello(