def parse_follower(follower_info):
    flw = session.query(Follower).filter(Follower.user_id == follower_info.id, Follower.owner == sys.argv[-1]).first()
    if flw is None:
        location = get_geos(follower_info.id)
        if hasattr(location, "point"):
            if location.point != None:
                # follower_info.country = location.point.latitude
                follower_info.latitude = location.point.latitude
                follower_info.longitude = location.point.longitude
                # follower_info.country = locate_country(follower_info.latitude, follower_info.longitude)
                # follower_info.country = locate_country(location.point.latitude, location.point.longitude)
                return follower_info
    return False
def parse_follower(follower_info):
    flw = session.query(Follower).filter(Follower.user_id==follower_info.id, Follower.owner == sys.argv[-1]).first()
    if flw is None:
        location = get_geos(follower_info.id)
        user = api.user(user_id=follower_info.id)
        if 'counts' in user:
            follower_info.followers_count = user.counts['followed_by']
        if hasattr(location, 'point'):
            if(location.point != None):
                # follower_info.country = location.point.latitude
                follower_info.latitude = location.point.latitude
                follower_info.longitude = location.point.longitude
                # follower_info.country = locate_country(follower_info.latitude, follower_info.longitude)
                # follower_info.country = locate_country(location.point.latitude, location.point.longitude)
                return follower_info
    return False
def load_geos_test():
    session = Session()
    for follower in session.query(Follower).order_by(Follower.user_id):
        follower.geotag = get_geos(follower.user_id)
    session.commit()
def load_geos_test():
    session = Session()
    for follower in session.query(Follower).order_by(Follower.user_id):
        follower.geotag = get_geos(follower.user_id)
    session.commit()
Example #5
0
from lib import get_followers
from lib import get_geos
from follower import Follower

from instadb import geo_table
from instadb import Session

session = Session()

followed_by = get_followers('1921850126')

# mapper(Follower, geo_table)
# fill db with followers, step 1
for follower in followed_by:
    print follower.id
    session.add(Follower(user_id=follower.id))
session.commit()

#TODO fill DB with GEOS
# get_geos_for_followers(followed_by)

for follower in session.query(Follower).order_by(Follower.user_id):
    location = get_geos(follower.user_id)
    # if hasattr(location, 'id'):
    #     follower.location_id = location.id
    if hasattr(location, 'point'):
        if (location.point != None):
            follower.latitude = location.point.latitude
            follower.longitude = location.point.longitude
            session.commit()
from lib import get_geos
from follower import Follower

from instadb import geo_table
from instadb import Session


session = Session()

followed_by = get_followers('1921850126')

# mapper(Follower, geo_table)
# fill db with followers, step 1
for follower in followed_by:
    print follower.id
    session.add(Follower(user_id=follower.id))
session.commit()

#TODO fill DB with GEOS
# get_geos_for_followers(followed_by)

for follower in session.query(Follower).order_by(Follower.user_id):
    location = get_geos(follower.user_id)
    # if hasattr(location, 'id'):
    #     follower.location_id = location.id
    if hasattr(location, 'point'):
        if(location.point != None):
            follower.latitude = location.point.latitude
            follower.longitude = location.point.longitude
            session.commit()