def home(self,handle): access_token = "563806852-9m6OTWv0bnpDfbEVYZXke1MoWwiB77IGRSpqwlaq" access_token_secret = "BsKrwRvSutkADZX73J53i2dTz3WgCPzSYj1KQ5NI5GQW5" consumer_key = "VlFNycQDt1xgm1w7ggatd748Q" consumer_secret = "NKfuFXkIcIQNdMtOpim2TJ1avcwXuOCsAOVcR7gl9AQa5dQ1JS" auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) user = api.get_user(handle) print user.name + " has logged in" dynamo = DynamoTable('default', 'twitty-users') if dynamo.checkUserExists(user.id) is False: print "New User" interests = UserInterests(api, None) interests.generateInterests(handle) interests_dict = interests.getInterests() print interests_dict # print "\nEnriching Interests" # interests.enrichTopicList() # interests_dict = interests.getInterests() # print interests_dict print "interests generated" last_tweet_id = user.status.id if len(interests_dict) is not 0 else -1L print "Last Tweet ID: " + `last_tweet_id` User = { 'user_id': user.id, 'name': user.name, 'screen_name': user.screen_name, 'profile_image_url': user.profile_image_url, 'location': user.location if len(user.location) > 0 else 'Earth, Milky Way', 'follower_count': user.followers_count, 'friends_count': user.friends_count, 'profile_url': "http:/twitter.com/" + user.screen_name, 'description': user.description if len(user.description) > 0 else 'Sorry I have no description', 'statuses_count': user.statuses_count, 'interests': interests_dict, 'interests_count': len(interests_dict), 'last_tweet_id': last_tweet_id } print "User Item created" dynamo.addUserToDB(User) print "User added to DB" else: print "User already exists"
def home(): id = request.args.get('user_id') api = db[int(id)]['api'] user = api.me() dynamo = DynamoTable('default', 'twitty-users') if dynamo.checkUserExists(user.id) is False: print "New User" interests = processFirstTimeUser(api, dynamo) db[user.id]['interests'] = interests else: print "Existing User" interests = processExistingUser(api, dynamo) db[user.id]['interests'] = interests # do matching here now!! if 'matcher' not in db.keys(): print "Begin Matching" items = dynamo.scanTable() users = dict() for item in items: users[item['user_id']] = dynamo.formatContent(item) matcher = Matcher(items, users) matcher.doMatching() db['matcher'] = matcher db['users'] = users print "Matching Done" if session['device'] == "mobile": del session['device'] return redirect(url_for('dashboard', user_id=id, device="mobile")) else: del session['device'] return render_template('home.html', name=user.name, user_id=id)
def home(self, handle): access_token = "563806852-9m6OTWv0bnpDfbEVYZXke1MoWwiB77IGRSpqwlaq" access_token_secret = "BsKrwRvSutkADZX73J53i2dTz3WgCPzSYj1KQ5NI5GQW5" consumer_key = "VlFNycQDt1xgm1w7ggatd748Q" consumer_secret = "NKfuFXkIcIQNdMtOpim2TJ1avcwXuOCsAOVcR7gl9AQa5dQ1JS" auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) user = api.get_user(handle) print user.name + " has logged in" dynamo = DynamoTable('default', 'twitty-users') if dynamo.checkUserExists(user.id) is False: print "New User" interests = UserInterests(api, None) interests.generateInterests(handle) interests_dict = interests.getInterests() print interests_dict # print "\nEnriching Interests" # interests.enrichTopicList() # interests_dict = interests.getInterests() # print interests_dict print "interests generated" last_tweet_id = user.status.id if len( interests_dict) is not 0 else -1L print "Last Tweet ID: " + ` last_tweet_id ` User = { 'user_id': user.id, 'name': user.name, 'screen_name': user.screen_name, 'profile_image_url': user.profile_image_url, 'location': user.location if len(user.location) > 0 else 'Earth, Milky Way', 'follower_count': user.followers_count, 'friends_count': user.friends_count, 'profile_url': "http:/twitter.com/" + user.screen_name, 'description': user.description if len(user.description) > 0 else 'Sorry I have no description', 'statuses_count': user.statuses_count, 'interests': interests_dict, 'interests_count': len(interests_dict), 'last_tweet_id': last_tweet_id } print "User Item created" dynamo.addUserToDB(User) print "User added to DB" else: print "User already exists"