From 06896cc168deb4e5daa39c85d11f5b065fbaf390 Mon Sep 17 00:00:00 2001 From: Jan Behrens Date: Wed, 8 Jan 2014 19:05:01 +0100 Subject: [PATCH] add some log output --- xonstat/__init__.py | 3 +-- xonstat/util.py | 4 ++-- xonstat/views/player.py | 16 +++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/xonstat/__init__.py b/xonstat/__init__.py index 0433461..49493d8 100644 --- a/xonstat/__init__.py +++ b/xonstat/__init__.py @@ -45,8 +45,7 @@ def main(global_config, **settings): config.add_route("player_game_index_json", "/player/{player_id:\d+}/games.json") config.add_view(player_game_index_json, route_name="player_game_index_json", renderer="jsonp") - #config.add_route("player_hashkey_info_text", "/player/me") - config.add_route("player_hashkey_info_text", "/player/{hashkey}") + config.add_route("player_hashkey_info_text", "/player/me") config.add_view(player_hashkey_info_text, route_name="player_hashkey_info_text", renderer="player_hashkey_info_text.mako") config.add_route("player_info", "/player/{id:\d+}") diff --git a/xonstat/util.py b/xonstat/util.py index d859930..0891765 100644 --- a/xonstat/util.py +++ b/xonstat/util.py @@ -1,3 +1,4 @@ +import sys import logging import pyramid.httpexceptions import re @@ -261,9 +262,8 @@ def verify_request(request): sig=request.headers['X-D0-Blind-Id-Detached-Signature'], querystring='', postdata=request.body) - - log.debug('\nidfp: {0}\nstatus: {1}'.format(idfp, status)) except: + log.debug('ERROR: Could not verify request: {0}'.format(sys.exc_info())) idfp = None status = None diff --git a/xonstat/views/player.py b/xonstat/views/player.py index 87967b9..38fced4 100644 --- a/xonstat/views/player.py +++ b/xonstat/views/player.py @@ -789,9 +789,10 @@ def player_damage_json(request): def player_hashkey_info_data(request): (idfp, status) = verify_request(request) - print "player_hashkey_info_data [idfp={0} status={1}]".format(idfp, status) + log.debug("d0_blind_id verification: idfp={0} status={1}\n".format(idfp, status)) - hashkey = request.matchdict['hashkey'] + log.debug("\n----- BEGIN REQUEST BODY -----\n" + request.body + + "----- END REQUEST BODY -----\n\n") # if config is to *not* verify requests and we get nothing back, this # query will return nothing and we'll 404. @@ -799,7 +800,7 @@ def player_hashkey_info_data(request): player = DBSession.query(Player).\ filter(Player.player_id == Hashkey.player_id).\ filter(Player.active_ind == True).\ - filter(Hashkey.hashkey == hashkey).one() + filter(Hashkey.hashkey == idfp).one() games_played = get_games_played(player.player_id) overall_stats = get_overall_stats(player.player_id) @@ -811,7 +812,7 @@ def player_hashkey_info_data(request): raise pyramid.httpexceptions.HTTPNotFound return {'player':player, - 'hashkey':hashkey, + 'hashkey':idfp, 'games_played':games_played, 'overall_stats':overall_stats, 'fav_maps':fav_maps, @@ -908,8 +909,13 @@ def player_elo_info_data(request): """ Provides elo information on a specific player. Raw data is returned. """ + (idfp, status) = verify_request(request) + log.debug("d0_blind_id verification: idfp={0} status={1}\n".format(idfp, status)) + hashkey = request.matchdict['hashkey'] - print "player_elo_info_data [hashkey={0}]".format(hashkey) + log.debug("\n----- BEGIN REQUEST BODY -----\n" + request.body + + "----- END REQUEST BODY -----\n\n") + try: player = DBSession.query(Player).\ filter(Player.player_id == Hashkey.player_id).\ -- 2.39.2