• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python twitter_user.TwitterUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中smarttypes.model.twitter_user.TwitterUser的典型用法代码示例。如果您正苦于以下问题:Python TwitterUser类的具体用法?Python TwitterUser怎么用?Python TwitterUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TwitterUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: user

def user(request):
    
    if 'user_id' in request.params:
        user_id = int(request.params['user_id'])
        twitter_user = TwitterUser.get_by_id(user_id)
    else:
        screen_name = request.params['screen_name']
        twitter_user = TwitterUser.by_screen_name(screen_name)
    
    return {
        'twitter_user':twitter_user,
    }
开发者ID:greeness,项目名称:SmartTypes,代码行数:12,代码来源:__init__.py


示例2: get_igraph_g

    def get_igraph_g(self):
        from smarttypes.model.twitter_user import TwitterUser
        from smarttypes.graphreduce.reduce_graph import get_igraph_graph

        network = {}
        for score, user_id in self.get_members():
            user = TwitterUser.get_by_id(user_id, self.postgres_handle)
            network[user.id] = set(user.following_ids)
        g = get_igraph_graph(network)
        pagerank = g.pagerank(damping=0.65)
        both = zip(pagerank, g.vs["name"])
        for x, y in sorted(both):
            print x
            print TwitterUser.get_by_id(y, self.postgres_handle).screen_name
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:14,代码来源:twitter_community.py


示例3: complete_signin

def complete_signin(request_key, verifier, postgres_handle):
    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    session = TwitterSession.get_by_request_key(request_key, postgres_handle)
    if session.access_key:
        #this happens if we get multiple same exact responses from twitter
        #perhaps crazy clicking or back / forward browsing 
        credentials = TwitterCredentials.get_by_access_key(session.access_key, postgres_handle)
    else:
        auth.set_request_token(request_key, session.request_secret)
        auth.get_access_token(verifier)
        # may have signed up already
        credentials = TwitterCredentials.get_by_access_key(auth.access_token.key, postgres_handle)
        if not credentials:
            credentials = TwitterCredentials.create(auth.access_token.key, auth.access_token.secret, postgres_handle)
        session.access_key = credentials.access_key
    if not credentials.twitter_user:
        #probably don't have the user in our db yet
        user = TwitterUser.upsert_from_api_user(credentials.api_handle.me(), postgres_handle)
        credentials.twitter_id = user.id
        credentials.save()

    #email
    screen_name = credentials.twitter_user.screen_name
    email_utils.send_email('[email protected]', ['[email protected]'],
                           '%s signed up' % screen_name, 'smarttypes signup!')

    return session.save()
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:27,代码来源:twitter_api_utils.py


示例4: logged_in_user

def logged_in_user(request):
    
    screen_name = request.params['screen_name']
    logged_in_user = TwitterUser.by_screen_name(screen_name)
    return {
        'logged_in_user':logged_in_user,
        'TwitterGroup':TwitterGroup,
    }
开发者ID:greeness,项目名称:SmartTypes,代码行数:8,代码来源:__init__.py


示例5: load_user_and_the_people_they_follow

def load_user_and_the_people_they_follow(creds, user_id, postgres_handle):

    remaining_hits_threshold = 10
    api_handle = creds.api_handle
    root_user = creds.root_user
    is_root_user = False
    if root_user.id == user_id:
        is_root_user = True

    # if is_root_user and 'root_user.is_fake_user':
    #     return None

    remaining_hits, reset_time = get_rate_limit_status(api_handle)
    if remaining_hits < remaining_hits_threshold:
        raise Exception("%s: remaining_hits less than threshold!" % root_user.screen_name)

    try:
        api_user = api_handle.get_user(user_id=user_id)
    except TweepError, ex:
        print "%s: api_handle.get_user(%s) got a TweepError %s" % (root_user.screen_name, user_id, ex)
        if 'Sorry, that page does not exist' in str(ex) or 'User has been suspended' in str(ex):
            print 'setting caused_an_error'
            model_user = TwitterUser.get_by_id(user_id, postgres_handle)
            if not model_user:
                properties = {'id': user_id, 'screen_name': user_id}
                model_user = TwitterUser(postgres_handle=postgres_handle, **properties)
                model_user.save()
                postgres_handle.connection.commit()
            model_user.caused_an_error = datetime.now()
            model_user.save()
            postgres_handle.connection.commit()
        return None
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:32,代码来源:get_twitter_friends.py


示例6: index

def index(req, session, postgres_handle):
    root_user = None
    if 'user_id' in req.params:
        root_user = TwitterUser.get_by_id(req.params['user_id'], postgres_handle)
    if not root_user:
        root_user = TwitterUser.by_screen_name('SmartTypes', postgres_handle)
    reduction = TwitterReduction.get_latest_reduction(root_user.id, postgres_handle)
    if not reduction:
        root_user = TwitterUser.by_screen_name('SmartTypes', postgres_handle)
        reduction = TwitterReduction.get_latest_reduction(root_user.id, postgres_handle)
    return {
        'active_tab': 'social_map',
        'template_path': 'social_map/index.html',
        'root_user': root_user,
        'reduction': reduction,
        'num_groups': len(TwitterGroup.all_groups(reduction.id, postgres_handle)),
        'users_with_a_reduction': TwitterReduction.get_users_with_a_reduction(postgres_handle),
    }
开发者ID:osiloke,项目名称:smarttypes,代码行数:18,代码来源:social_map.py


示例7: get_user_reduction_counts

 def get_user_reduction_counts(cls, postgres_handle):
     from smarttypes.model.twitter_user import TwitterUser
     return_users = []
     qry = """
     select root_user_id, count(root_user_id) as reduction_count
     from twitter_reduction
     group by root_user_id;
     """
     for result in postgres_handle.execute_query(qry):
         user = TwitterUser.get_by_id(result['root_user_id'], postgres_handle)
         return_users.append((user, result['reduction_count']))
     return return_users
开发者ID:galabad,项目名称:smarttypes,代码行数:12,代码来源:twitter_reduction.py


示例8: get_users_with_a_reduction

 def get_users_with_a_reduction(cls, postgres_handle):
     from smarttypes.model.twitter_user import TwitterUser
     return_users = []
     qry = """
     select distinct root_user_id
     from twitter_reduction
     order by root_user_id;
     """
     for result in postgres_handle.execute_query(qry):
         user = TwitterUser.get_by_id(result['root_user_id'], postgres_handle)
         return_users.append(user)
     return return_users
开发者ID:galabad,项目名称:smarttypes,代码行数:12,代码来源:twitter_reduction.py


示例9: top_users

 def top_users(self, num_users=20, just_ids=False):
     from smarttypes.model.twitter_user import TwitterUser
     return_list = []
     score_user_id_tup_list = self.get_members()
     for score, user_id in heapq.nlargest(num_users, score_user_id_tup_list):
         if score:
             add_this = (score, user_id)
             if not just_ids: add_this = (score, TwitterUser.get_by_id(user_id, self.postgres_handle))
             return_list.append(add_this)
         else:
             break
     return return_list
开发者ID:galabad,项目名称:smarttypes,代码行数:12,代码来源:twitter_group.py


示例10: community_features

def community_features(req, session, postgres_handle):
    reduction = None
    if req.path.split('/') > 3 and req.path.split('/')[3]:  # path looks like '/social_map/community_features/something'
        root_user = TwitterUser.by_screen_name(req.path.split('/')[3], postgres_handle)
        if root_user:
            reduction = TwitterReduction.get_latest_reduction(root_user.id, postgres_handle)
        if not reduction and is_int(req.path.split('/')[3]):
            reduction = TwitterReduction.get_by_id(req.path.split('/')[3], postgres_handle)
    return {
        'content_type': 'application/json',
        'json':reduction.get_geojson_community_features() if reduction else [],
    }
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:12,代码来源:social_map.py


示例11: node_details

def node_details(req, session, postgres_handle):
    twitter_user, in_links, out_links = None, [], []
    if 'node_id' in req.params and 'reduction_id' in req.params:
        reduction = TwitterReduction.get_by_id(req.params['reduction_id'], postgres_handle)
        twitter_user = TwitterUser.get_by_id(req.params['node_id'], postgres_handle)
        if twitter_user:
            in_links, out_links = reduction.get_in_and_out_links_for_user(req.params['node_id'])
    return {
        'template_path': 'social_map/node_details.html',
        'twitter_user': twitter_user,
        'in_links':in_links,
        'out_links':out_links,
    }
开发者ID:osiloke,项目名称:smarttypes,代码行数:13,代码来源:social_map.py


示例12: load_user_and_the_people_they_follow

def load_user_and_the_people_they_follow(api_handle, screen_name):
    print "Attempting to load %s" % screen_name
    continue_or_exit(api_handle)
    
    try:    
        api_user = api_handle.get_user(screen_name=screen_name)
    except TweepError, ex:
        print "Got a TweepError: %s." % ex  
        if str(ex) == "Not found":
            print "Setting caused_an_error for %s " % screen_name
            model_user = TwitterUser.by_screen_name(screen_name)
            model_user.caused_an_error = datetime.now()
            model_user.save()
            return model_user
开发者ID:greeness,项目名称:SmartTypes,代码行数:14,代码来源:get_twitter_friends.py


示例13: top_users

 def top_users(self, num_users=20, just_ids=False):
     from smarttypes.model.twitter_user import TwitterUser
     
     return_list = []
     i = 0
     for score, user_id in sorted(self.scores_users, reverse=True):
         if i <= num_users and score > .001:
             add_this = (score, user_id)
             if not just_ids: add_this = (score, TwitterUser.get_by_id(user_id))
             return_list.append(add_this)
         else:
             break
         i += 1
     return return_list
开发者ID:greeness,项目名称:SmartTypes,代码行数:14,代码来源:twitter_group.py


示例14: pull_some_users

def pull_some_users(user_id):
    postgres_handle = PostgresHandle(smarttypes.connection_string)
    root_user = TwitterUser.get_by_id(user_id, postgres_handle)
    if not root_user:
        raise Exception('User ID: %s not in our DB!' % user_id)
    if not root_user.credentials:
        raise Exception('%s does not have api credentials!' % root_user.screen_name)
    api_handle = root_user.credentials.api_handle
    root_user = load_user_and_the_people_they_follow(api_handle, root_user.id, postgres_handle, is_root_user=True)
    load_this_user_id = root_user.get_id_of_someone_in_my_network_to_load()
    while load_this_user_id:
        load_user_and_the_people_they_follow(api_handle, load_this_user_id, postgres_handle)
        load_this_user_id = root_user.get_id_of_someone_in_my_network_to_load()
        #load_this_user_id = None
    print "Finshed loading all related users for %s!" % root_user.screen_name
开发者ID:galabad,项目名称:smarttypes,代码行数:15,代码来源:get_twitter_friends.py


示例15: load_network_from_the_db

def load_network_from_the_db(postgres_handle, distance):
  network = OrderedDict()
  def add_user_to_network(user):
    network[user.id] = {}
    network[user.id]['following_ids'] = set(user.following_ids)
    #network[user.id]['following_ids'].add(user.id)
    network[user.id]['follower_ids'] = set([])
    network[user.id]['following_count'] = user.following_count
    network[user.id]['followers_count'] = user.followers_count
  twitter_user = TwitterUser.by_screen_name('SmartTypes', postgres_handle)
  add_user_to_network(twitter_user)
  for following in twitter_user.following:
    add_user_to_network(following)
    for following_following in following.following[:distance]:
      add_user_to_network(following_following)
  return network
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:16,代码来源:cluster_w_linlog.py


示例16: complete_signin

def complete_signin(request_key, verifier, postgres_handle):
    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    session = TwitterSession.get_by_request_key(request_key, postgres_handle)
    auth.set_request_token(request_key, session.request_secret)
    auth.get_access_token(verifier)
    # may have signed up already
    credentials = TwitterCredentials.get_by_access_key(auth.access_token.key, postgres_handle)
    if not credentials:
        credentials = TwitterCredentials.create(auth.access_token.key, auth.access_token.secret, postgres_handle)
    session.access_key = credentials.access_key
    if not credentials.twitter_user:
        user = TwitterUser.upsert_from_api_user(credentials.api_handle.me(), postgres_handle)
        credentials.twitter_id = user.id
        credentials.save()
    screen_name = credentials.twitter_user.screen_name
    email_utils.send_email('[email protected]', ['[email protected]'],
                           '%s signed up' % screen_name, 'smarttypes signup!')
    return session.save()
开发者ID:galabad,项目名称:smarttypes,代码行数:18,代码来源:twitter_api_utils.py


示例17: index

def index(req, session, postgres_handle):
    #if it's not a valid request keep reduction_id None
    #don't do work for bots that don't know what they're 
    #looking for
    reduction = None
    user_reduction_counts = TwitterReduction.get_user_reduction_counts(postgres_handle)
    random.shuffle(user_reduction_counts)

    if req.path.split('/') > 1 and req.path.split('/')[1]:  # path looks like '/something'
        root_user = TwitterUser.by_screen_name(req.path.split('/')[1], postgres_handle)
        if root_user:
            reduction = TwitterReduction.get_latest_reduction(root_user.id, postgres_handle)
        if not reduction and is_int(req.path.split('/')[1]):
            reduction = TwitterReduction.get_by_id(req.path.split('/')[1], postgres_handle)
    else:
        reduction = TwitterReduction.get_latest_reduction(user_reduction_counts[0][0].id, postgres_handle)

    return {
        'reduction_id': reduction.id if reduction and reduction.tiles_are_written_to_disk else None,
        'reduction': reduction if reduction and reduction.tiles_are_written_to_disk else None,
        'user_reduction_counts': user_reduction_counts
    }
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:22,代码来源:__init__.py


示例18: PostgresHandle

import os
import pickle
from datetime import datetime
import numpy as np

import smarttypes, random
from smarttypes.utils.postgres_handle import PostgresHandle

postgres_handle = PostgresHandle(smarttypes.connection_string)

from smarttypes.graphreduce import GraphReduce
from smarttypes.model.twitter_user import TwitterUser
from smarttypes.model.twitter_group import TwitterGroup
from smarttypes.model.twitter_reduction import TwitterReduction
from smarttypes.model.twitter_credentials import TwitterCredentials

screen_name = "SmartTypes"
root_user = TwitterUser.by_screen_name(screen_name, postgres_handle)
follower_followies_map = root_user.get_graph_info(distance=0, min_followers=60)
gr = GraphReduce(screen_name, follower_followies_map)
gr.reduce_with_linloglayout()
gr.figure_out_reduction_distances()


# model_user = TwitterUser.by_screen_name('SmartTypes', postgres_handle)
# api_handle = model_user.credentials.api_handle
# api_user = api_handle.get_user(screen_name='SmartTypes')

# print os.path.dirname(os.path.abspath(__file__))
开发者ID:osiloke,项目名称:smarttypes,代码行数:29,代码来源:bootstrap_ipython.py


示例19: root_user

 def root_user(self):
     from smarttypes.model.twitter_user import TwitterUser
     if not self.root_user_id:
         return None
     return TwitterUser.get_by_id(self.root_user_id, self.postgres_handle)
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:5,代码来源:twitter_credentials.py


示例20: print_user_details

def print_user_details(user_ids, postgres_handle):
  for user in TwitterUser.get_by_ids(user_ids, postgres_handle):
    print "%s -- %s" % (user.screen_name, 
      user.description[:100].replace('\n', ' ') if user.description else '')
开发者ID:mrcrabby,项目名称:smarttypes,代码行数:4,代码来源:cluster_w_linlog.py



注:本文中的smarttypes.model.twitter_user.TwitterUser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python smartypants.smartyPants函数代码示例发布时间:2022-05-27
下一篇:
Python smartcsv.reader函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap