import datetime\r
import logging\r
+import pyramid.httpexceptions\r
import re\r
import time\r
from pyramid.config import get_current_registry\r
\r
\r
def verify_request(request):\r
- (idfp, status) = d0_blind_id_verify(\r
- sig=request.headers['X-D0-Blind-Id-Detached-Signature'],\r
- querystring='',\r
- postdata=request.body)\r
+ try:\r
+ (idfp, status) = d0_blind_id_verify(\r
+ sig=request.headers['X-D0-Blind-Id-Detached-Signature'],\r
+ querystring='',\r
+ postdata=request.body)\r
\r
- log.debug('\nidfp: {0}\nstatus: {1}'.format(idfp, status))\r
+ log.debug('\nidfp: {0}\nstatus: {1}'.format(idfp, status))\r
+ except: \r
+ idfp = None\r
+ status = None\r
\r
return (idfp, status)\r
\r
\r
(idfp, status) = verify_request(request)\r
if not idfp:\r
- raise Exception("Request is not verified.")\r
+ raise pyramid.httpexceptions.HTTPUnauthorized\r
\r
(game_meta, players) = parse_body(request) \r
\r
if not has_required_metadata(game_meta):\r
- log.debug("Required game meta fields (T, G, M, or S) missing. "\\r
+ log.debug("Required game meta fields missing. "\\r
"Can't continue.")\r
- raise Exception("Required game meta fields (T, G, M, or S) missing.")\r
+ raise pyramid.exceptions.HTTPUnprocessableEntity\r
\r
if not is_supported_gametype(game_meta['G']):\r
- raise Exception("Gametype not supported.")\r
+ raise pyramid.httpexceptions.HTTPOk\r
\r
if not has_minimum_real_players(players):\r
- raise Exception("The number of real players is below the minimum. "\\r
- "Stats will be ignored.")\r
+ log.debug("The number of real players is below the minimum. " + \r
+ "Stats will be ignored.")\r
+ raise pyramid.httpexceptions.HTTPOk\r
\r
server = get_or_create_server(session=session, hashkey=idfp, \r
name=game_meta['S'])\r