Example #1
0
def main():
    options, args = parseCommandLine()
    
    stampedAPI = MongoStampedAPI(lite_mode=True)
    stats = stampedAPI.getStats(store=options.store)
    
    pprint(stats)
Example #2
0
def main():
    usage = "Usage: %prog --entity_id=<id>  OR  %prod --search_id=<id> OR %prod <query> <subcategory?> <index?>"
    version = "%prog " + __version__
    parser = OptionParser(usage=usage, version=version)
    parser.add_option('--entity_id', action='store', dest='entity_id', default=None)
    parser.add_option('--search_id', action='store', dest='search_id', default=None)
    (options, args) = parser.parse_args()

    if options.entity_id and options.search_id:
        print '--entity_id and --search_id are mutually exclusive!'
    id_provided = options.entity_id or options.search_id
    if id_provided and len(args) > 1:
        print '--entity_id and --search_id cannot be used with query arguments!'

    if options.entity_id:
        from api.db.mongodb.MongoEntityCollection import MongoEntityCollection
        entity = MongoEntityCollection().getEntity(options.entity_id)
    elif options.search_id:
        entity = getEntityFromSearchId(options.search_id)
    else:
        query = buildQueryFromArgs(args)
        from api.MongoStampedAPI import MongoStampedAPI
        cursor = MongoStampedAPI()._entityDB._collection.find(query)
        if cursor.count() == 0:
            print("Could not find a matching entity for query: %s" % query)
            return

        entity =  MongoStampedAPI()._entityDB._convertFromMongo(cursor[0])


    print( "Before:\n%s" % pformat( entity.dataExport() ) )

    container = FullResolveContainer()

    decorations = {}
    container.enrichEntity( entity, decorations )

    print( "After:\n%s" % pformat( entity.dataExport() ) )
    if len(decorations) > 0:
        print( "With decorations:")

        for k,v in decorations.items():
            print( "%s decoration:" % k )

            try:
                print( "%s" % pformat(v.dataExport()) )
            except Exception:
                print( "%s" % pformat(v) )

    from libs.CountedFunction import printFunctionCounts
    printFunctionCounts()
Example #3
0
def main():
    options, args = parseCommandLine()
    
    stampedAPI = MongoStampedAPI()
    accountDB  = stampedAPI._accountDB
    
    rs = accountDB._collection.find()
    for result in rs:
        account = accountDB._convertFromMongo(result)
        pprint(account)
        
        image = utils.getFile(account.profile_image)
        image = base64.encodestring(image)
        
        stampedAPI.updateProfileImage(account.screen_name, image)
Example #4
0
user_ids = set([ 
    #"4e57048dccc2175fca000005", # travis
    "4e57048accc2175fcd000001", # robby
    #"4e570489ccc2175fcd000000", # kevin
    #"4e57048bccc2175fcd000002", # bart
    #"4e57048eccc2175fca000006", # andybons
    #"4e57048cccc2175fca000003", # edmuki
    #"4eca8944e8ef21799d0001b3", # landon
])

request = SuggestedUserRequest(dict(
    limit           = 5, 
    personalized    = True, 
))

api     = MongoStampedAPI()
userDB  = api._userDB

rs = userDB._collection.find({'email' : { '$regex' : r'.*@stamped\.com', '$options' : 'i' }}, output=list)
for result in rs:
    user    = userDB._convertFromMongo(result)
    user_id = user.user_id
    
    if user_id not in user_ids:
        continue # only process team members
    
    utils.log('-' * 40)
    utils.log('%s) %s' % (user.screen_name, user_id))
    
    users   = api.getSuggestedUsers(user_id, request)
    
Example #5
0
#!/usr/bin/env python

import Globals, utils
import time

from api.MongoStampedAPI    import MongoStampedAPI
from api.Schemas            import *

api = MongoStampedAPI()
user_ids = [ 
    "4e57048dccc2175fca000005", 
    #"4e57048accc2175fcd000001", 
    #"4e57048bccc2175fcd000002", 
    #"4e570490ccc2175fcd000003", 
    #"4e985cc7fe4a1d2fc4000220", 
    #"4e98f376fe4a1d44dd00014c", 
    #"4eca8dd5112dea0809000182", 
    #"4ecb8f5534083316d300254b", 
]

for user_id in user_ids:
    s = FriendsSlice()
    
    print "%s" % user_id
    
    #for distance in xrange(5):
    distance    = 2
    s.distance  = distance
    s.inclusive = True
    
    t0   = time.time()
Example #6
0
from api.HTTPSchemas import *
from api.Schemas import *
from pprint import pprint
from api import Entity

from resolve                import FullResolveContainer
from resolve.AmazonSource           import AmazonSource
from resolve.FactualSource          import FactualSource
from resolve.GooglePlacesSource     import GooglePlacesSource
from resolve.iTunesSource           import iTunesSource
from resolve.RdioSource             import RdioSource
from resolve.SpotifySource          import SpotifySource
from resolve.TMDBSource             import TMDBSource
from resolve.StampedSource          import StampedSource

stampedAPI = MongoStampedAPI()

q = 'auction house'
# q = 'little owl'
q = '21 jump street'
# q = 'stamped'
# q = 'boyfriend'
# q = 'avec'
q = 'kanye west'
q = 'katy perry'
# coords = CoordinatesSchema({'lat': 37.781697, 'lng':-122.392146})   # SF
# coords = CoordinatesSchema({'lat': 40.742273, 'lng':-74.007549})   # NYC
# coords = None

# e = stampedAPI.getEntity({'entity_id': '4eb3001b41ad855d53000ac8'})
# e = stampedAPI.getEntity({'entity_id': '4e4c6e76db6bbe2bcd01ce85'})
Example #7
0
 import argparse
 parser = argparse.ArgumentParser()
 parser.add_argument('-d', '--db', action='store', default=None)
 parser.add_argument('-u', '--user', action='store', default=None)
 parser.add_argument('-U', '--users', action='append', default=[])
 parser.add_argument('-c', '--category', action='store', default=None)
 parser.add_argument('-l', '--limit', action='store', default=None, type=int)
 parser.add_argument('-s', '--s3', action='store_true', default=False)
 parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__)
 
 args = parser.parse_args()
 
 if args.db is not None:
     utils.init_db_config(args.db)
 
 api = MongoStampedAPI()
 
 collages   = {
     'default' : DefaultImageCollage(), 
     'place'   : PlaceImageCollage(), 
     'music'   : MusicImageCollage(), 
     'book'    : BookImageCollage(), 
     'film'    : FilmImageCollage(), 
     'app'     : AppImageCollage(), 
 }
 
 categories = collages.keys()
 
 if args.category is not None:
     assert args.category in categories
     
Example #8
0
    def setUp(self):
        (self.user, self.token) = self.createAccount(name='UserA')

        self._accountDB = MongoStampedAPI()._accountDB
        testuser = self._accountDB._getMongoDocumentFromId(bson.objectid.ObjectId(self.user['user_id']))

        oldFormatAccountData = {
            "alerts" : {
                "ios_alert_comment" : True,
                "ios_alert_follow" : True,
                "ios_alert_reply" : True,
                "ios_alert_fav" : True,
                "email_alert_credit" : True,
                "email_alert_reply" : True,
                "ios_alert_credit" : True,
                "ios_alert_mention" : True,
                "email_alert_like" : True,
                "email_alert_comment" : True,
                "email_alert_mention" : True,
                "ios_alert_like" : True,
                "email_alert_follow" : True,
                "email_alert_fav" : True
            },
            "bio" : "My life is short-lived :(",
            "color_primary" : "33B6DA",
            "color_secondary" : "006C89",
            "devices" : {
                "ios_device_tokens" : [
                    "df687e03345604f6b02a4c32bc7d5220ddd5f832c270645e06f22cc26f66516a",
                    "1c8cf15acb17f8362322ccff0452417dcd3f6b538193099e0347efb84e8a4a4f",
                    "f90a011543694238bde60ff04790f10f864adb2e04c279d91b3477c03a18ddcd"
                ]
            },
            "email" : "*****@*****.**",
            "linked_accounts" : {
                "facebook" : {
                    "facebook_alerts_sent" : True,
                    "facebook_id" : "1234567",
                    "facebook_name" : "Test User",
                    "facebook_alerts_sent" : True,
                },
                "twitter" : {
                    "twitter_alerts_sent" : True,
                    "twitter_id" : "12345678",
                    "twitter_screen_name" : "testusera0",
                    "twitter_alerts_sent" : True,
                },
                "netflix" : {
                    "netflix_token" : "abcdefghijkl_7mon6p9zdWyDB_-9QU4w4jcAn4WZA3HotKLMrG4oBT2CsB_Mum6N24aXCrmqRxnBSrNNuxKkhF8sZE6BtSh0",
                    "netflix_secret" : "abcdefghijkl",
                    "netflix_user_id" : "abcdefghijsQujGoAtBtnwbTBpSjBx00o2PE2ASmO9kgw-"
                },
                },
            "location" : "New York",
            "password" : "S3Flv0fae32460b5aa107be10c7d71885a4e28",
            "phone" : 1234567890,
            "privacy" : False,
            "stats" : {
                "num_unread_news" : 0,
                "num_credits" : 51,
                "num_stamps" : 65,
                "num_stamps_left" : 160,
                "num_faves" : 87,
                "num_likes_given" : 79,
                "num_followers" : 179,
                "num_likes" : 115,
                "num_stamps_total" : 65,
                "num_friends" : 70
            },
        }
        testuser.update(oldFormatAccountData)
        self._accountDB._updateMongoDocument(testuser)
        testAccount = self.showAccount(self.token)
        linkedAccounts = self.showLinkedAccounts(self.token)

        self.assertEqual(linkedAccounts['twitter'], { 'service_name': 'twitter', 'linked_screen_name' : 'testusera0', 'linked_user_id': '12345678'})
        self.assertEqual(linkedAccounts['facebook'], { 'service_name': 'facebook', 'linked_user_id' : '1234567', 'linked_name': 'Test User'})
        self.assertEqual(linkedAccounts['netflix'],
                {
                'service_name' : 'netflix',
                'token' : 'abcdefghijkl_7mon6p9zdWyDB_-9QU4w4jcAn4WZA3HotKLMrG4oBT2CsB_Mum6N24aXCrmqRxnBSrNNuxKkhF8sZE6BtSh0',
                'secret' : 'abcdefghijkl',
                'linked_user_id': 'abcdefghijsQujGoAtBtnwbTBpSjBx00o2PE2ASmO9kgw-',
                }
        )

        self.assertEqual(self._accountDB.checkLinkedAccountAlertHistory(self.user['user_id'], 'facebook', '1234567'), True)
        self.assertEqual(self._accountDB.checkLinkedAccountAlertHistory(self.user['user_id'], 'twitter', '12345678'), True)