Esempio n. 1
0
 def GET(self):
     web.header("Content-Type", "text/html; charset=utf-8")  
     query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING']))
     debug = int(query_dict.get('debug', 0))
     game_id = query_dict['game_id']
     yyyymmdd = game.Game.get_date_from_id(game_id)
     contents = codecs.open('static/scrape_data/%s/%s' % (
             yyyymmdd, game_id), 'r', encoding='utf-8').read()
     body_err_msg = ('<body><b>Error annotating game, tell ' 
                     '[email protected]!</b>')
     try:
         return annotate_game.annotate_game(contents, game_id, debug)
     except parse_game.BogusGameError, b:
         return contents.replace('<body>',
                                 body_err_msg + ': foo? ' + str(b))
Esempio n. 2
0
 def GET(self):
     web.header("Content-Type", "text/html; charset=utf-8")  
     query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING']))
     debug = int(query_dict.get('debug', 0))
     game_id = query_dict['game_id']
     yyyymmdd = game.Game.get_date_from_id(game_id)
     contents = codecs.open('static/scrape_data/%s/%s' % (
             yyyymmdd, game_id), 'r', encoding='utf-8').read()
     body_err_msg = ('<body><b>Error annotating game, tell ' 
                     '[email protected]!</b>')
     try:
         return annotate_game.annotate_game(contents, game_id, debug)
     except parse_game.BogusGameError, b:
         return contents.replace('<body>',
                                 body_err_msg + ': foo? ' + str(b))
Esempio n. 3
0
    def GET(self):
        web.header("Content-Type", "text/html; charset=utf-8")  
        query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING']))
        debug = int(query_dict.get('debug', 0))
        game_id = query_dict['game_id']
        if game_id.endswith('.gz'):
            game_id = game_id[:-len('.gz')]
        yyyymmdd = game.Game.get_date_from_id(game_id)

        db = utils.get_mongo_database()
        raw_games_col = db.raw_games
        rawgame = raw_games_col.find_one({'_id': game_id})
        if rawgame is None:
            return 'could not find game ' + game_id
        contents = bz2.decompress(rawgame['text']).decode('utf-8')

        body_err_msg = ('<body><b>Error annotating game, tell ' 
                        '[email protected]!</b>')
        try:
            return annotate_game.annotate_game(contents, game_id, debug)
        except parse_game.BogusGameError, b:
            return contents.replace('<body>',
                                    body_err_msg + ': foo? ' + str(b))
Esempio n. 4
0
 def GET(self):
     web.header("Content-Type", "text/html; charset=utf-8")  
     query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING']))
     debug = int(query_dict.get('debug', 0))
     game_id = query_dict['game_id']
     if game_id.endswith('.gz'):
         game_id = game_id[:-len('.gz')]
     yyyymmdd = game.Game.get_date_from_id(game_id)
     uncompressed_fn = 'static/scrape_data/%s/%s' % (yyyymmdd, game_id)
     compressed_fn = uncompressed_fn + '.bz2'
     if os.path.exists(uncompressed_fn):
         contents = codecs.open(uncompressed_fn, 'r', 
                                encoding='utf-8').read()
     elif os.path.exists(compressed_fn):
         contents = bz2.BZ2File(compressed_fn).read().decode('utf-8')
     else:
         return 'could not find game ' + game_id
     body_err_msg = ('<body><b>Error annotating game, tell ' 
                     '[email protected]!</b>')
     try:
         return annotate_game.annotate_game(contents, game_id, debug)
     except parse_game.BogusGameError, b:
         return contents.replace('<body>',
                                 body_err_msg + ': foo? ' + str(b))
Esempio n. 5
0
    def GET(self):
        web.header("Content-Type", "text/html; charset=utf-8")  
        query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING']))
        debug = int(query_dict.get('debug', 0))
        game_id = query_dict['game_id']
        if game_id.endswith('.gz'):
            game_id = game_id[:-len('.gz')]
        yyyymmdd = game.Game.get_date_from_id(game_id)

        db = utils.get_mongo_database()
        raw_games_col = db.raw_games
        rawgame = raw_games_col.find_one({'_id': game_id})
        if rawgame is None:
            return 'could not find game ' + game_id
        contents = bz2.decompress(rawgame['text']).decode('utf-8')

        body_err_msg = ('<body><b>Error annotating game, please send the details of this message to the '
                        '<a href="mailto:[email protected]?Subject=Game%20Annotation%20Error">'
                        'Council Room Developers</a></b>')
        try:
            return annotate_game.annotate_game(contents, game_id, debug)
        except parse_common.BogusGameError, b:
            return contents.replace('<body>',
                                    body_err_msg + ': foo? ' + str(b))
Esempio n. 6
0
    def GET(self):
        web.header("Content-Type", "text/html; charset=utf-8")  
        query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING']))
        debug = int(query_dict.get('debug', 0))
        game_id = query_dict['game_id']
        if game_id.endswith('.gz'):
            game_id = game_id[:-len('.gz')]
        yyyymmdd = game.Game.get_date_from_id(game_id)

        db = utils.get_mongo_database()
        raw_games_col = db.raw_games
        rawgame = raw_games_col.find_one({'_id': game_id})
        if rawgame is None:
            return 'could not find game ' + game_id
        contents = bz2.decompress(rawgame['text']).decode('utf-8')

        body_err_msg = ('<body><b>Error annotating game, please send the details of this message to the '
                        '<a href="mailto:[email protected]?Subject=Game%20Annotation%20Error">'
                        'Council Room Developers</a></b>')
        try:
            return annotate_game.annotate_game(contents, game_id, debug)
        except parse_game.BogusGameError, b:
            return contents.replace('<body>',
                                    body_err_msg + ': foo? ' + str(b))