Ejemplo n.º 1
0
    logging.info( u'CHK_MON %s client_id: %s' % ( city_code, client_id ) )
    logging.info( u'CHK_MON %s client_secret: %s' % ( city_code, client_secret ) )
    logging.info( u'CHK_MON %s access_tokens: %s' % ( city_code, access_tokens[0] ) )
    logging.info( u'CHK_MON %s api gateways initialised' % city_code )

    # get the centre point for the city and construct a bounding area
    centre = _credentials.centres[city_code]
    centre = Point(centre[0], centre[1])
    logging.info( u'CHK_MON %s centre: %s' % ( city_code, centre ) )

    polygon = centre.buffer( 0.25, resolution=20 )
    logging.info( u'CHK_MON %s bounding polygon: %s' % ( city_code, polygon ) )

    # retrieve the list of venues from the database
    venues = dbw.get_venues_in_city( city_code )
    logging.info( u'CHK_MON retrieved %d venues from database for %s' % ( len(venues), city_code ) )

    # loop forever checking the venues for checkins
    while True:
        count_venues = 0
        count_checkins = 0
        count_venues_with_checkins = 0
        logging.info( u'CHK_MON start running checkin crawl in %s' % city_code )
        # log the start of a crawl
        crawl_string = 'MONITOR_CHECKINS_' + city_code
        dbw.add_crawl_to_database( crawl_string, 'START', now.now( ) )
        for venue in venues:
            if dbw.is_active( venue ):
                location = venue.location
                lat = location.latitude