<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import utils <EOL> from demos import demo_services <EOL> from auth import get_auth_service <EOL> import json <EOL> import logging <EOL> from datetime import datetime <EOL> from google . appengine . ext import ndb <EOL> class TimelineNotifyHandler ( utils . BaseHandler ) : <EOL> """<STR_LIT>""" <EOL> def post ( self , test ) : <EOL> """<STR_LIT>""" <EOL> message = self . request . body <EOL> data = json . loads ( message ) <EOL> logging . info ( data ) <EOL> self . response . status = <NUM_LIT:200> <EOL> gplus_id = data [ "<STR_LIT>" ] <EOL> verifyToken = data [ "<STR_LIT>" ] <EOL> if test is not None : <EOL> user = ndb . Key ( "<STR_LIT>" , gplus_id ) . get ( ) <EOL> else : <EOL> user = ndb . Key ( "<STR_LIT>" , gplus_id ) . get ( ) <EOL> if user is None or user . verifyToken != verifyToken : <EOL> logging . info ( "<STR_LIT>" ) <EOL> return <EOL> if data [ "<STR_LIT>" ] != "<STR_LIT>" : <EOL> logging . info ( "<STR_LIT>" ) <EOL> return <EOL> service = get_auth_service ( gplus_id , test ) <EOL> if service is None : <EOL> logging . info ( "<STR_LIT>" ) <EOL> return <EOL> result = service . timeline ( ) . get ( id = data [ "<STR_LIT>" ] ) . execute ( ) <EOL> logging . info ( result ) <EOL> for demo_service in demo_services : <EOL> if hasattr ( demo_service , "<STR_LIT>" ) : <EOL> demo_service . handle_item ( result , data , service , test ) <EOL> class LocationNotifyHandler ( utils . BaseHandler ) : <EOL> """<STR_LIT>""" <EOL> def post ( self , test ) : <EOL> """<STR_LIT>""" <EOL> message = self . request . body <EOL> data = json . loads ( message ) <EOL> self . response . status = <NUM_LIT:200> <EOL> gplus_id = data [ "<STR_LIT>" ] <EOL> verifyToken = data [ "<STR_LIT>" ] <EOL> if test is not None : <EOL> user = ndb . Key ( "<STR_LIT>" , gplus_id ) . get ( ) <EOL> else : <EOL> user = ndb . Key ( "<STR_LIT>" , gplus_id ) . get ( ) <EOL> if user is None or user . verifyToken != verifyToken : <EOL> logging . info ( "<STR_LIT>" ) <EOL> return <EOL> if data [ "<STR_LIT>" ] != "<STR_LIT>" : <EOL> logging . info ( "<STR_LIT>" ) <EOL> return <EOL> if data [ "<STR_LIT>" ] != "<STR_LIT>" : <EOL> logging . info ( "<STR_LIT>" ) <EOL> return <EOL> service = get_auth_service ( gplus_id , test ) <EOL> if service is None : <EOL> logging . info ( "<STR_LIT>" ) <EOL> return <EOL> result = service . locations ( ) . get ( id = data [ "<STR_LIT>" ] ) . execute ( ) <EOL> logging . info ( result ) <EOL> if "<STR_LIT>" in result and "<STR_LIT>" in result : <EOL> user . longitude = result [ "<STR_LIT>" ] <EOL> user . latitude = result [ "<STR_LIT>" ] <EOL> user . locationUpdate = datetime . utcnow ( ) <EOL> user . put ( ) <EOL> for demo_service in demo_services : <EOL> if hasattr ( demo_service , "<STR_LIT>" ) : <EOL> demo_service . handle_location ( result , data , service , test ) <EOL> NOTIFY_ROUTES = [ <EOL> ( r"<STR_LIT>" , TimelineNotifyHandler ) , <EOL> ( r"<STR_LIT>" , LocationNotifyHandler ) <EOL> ] </s>
