コード例 #1
0
def main():
    this_dir = os.path.dirname(os.path.abspath(__file__))
    fixtures_path = os.path.join(this_dir, "warsaw_venues.json")

    # Connect to MongoDB
    connect()

    with open(fixtures_path) as f:
        fixtures = json.load(f)
    for venue in fixtures:
        FSVenue.objects.get_or_create(vid=venue["vid"], defaults={
            "name": venue["name"],
            "location": venue["location"],
            "people": venue["people"],
            "full_data": venue["full_data"],
        })
    print FSVenue.objects.count()
コード例 #2
0
ファイル: crawler.py プロジェクト: 10clouds/citypulse
from facepy import GraphAPI
from datetime import datetime
import dateutil.parser

from citypulse.settings.mongoconnection import connect
from citypulse.fbcrawler.models import FBEvent
from citypulse.main.models import Event, Pulse
import requests
import sys

connect()

class ExtendedGraphAPI(GraphAPI):
    def ext_search(self, term=None, type=None, page=False, **options):
        SUPPORTED_TYPES = ['post', 'user', 'page', 'event', 'group', 'place', 'checkin', 'location']
        if type not in SUPPORTED_TYPES:
            raise ValueError('Unsupported type "%s". Supported types are %s' % (type, ', '.join(SUPPORTED_TYPES)))

        options = dict({
            'type': type,
        }, **options)
        if term is not None:
            options['q'] = term

        response = self._query('GET', 'search', options, page)

        return response

    def get_event_members(self, eid):
        data = {
            'eid': eid,
コード例 #3
0
ファイル: visualise.py プロジェクト: 10clouds/citypulse
def load_data():
    from citypulse.fsq.models import FSVenue
    from citypulse.settings.mongoconnection import connect
    connect()
    return FSVenue.objects.values_list('location')