本文整理汇总了Python中smarttypes.model.twitter_user.TwitterUser.save方法的典型用法代码示例。如果您正苦于以下问题:Python TwitterUser.save方法的具体用法?Python TwitterUser.save怎么用?Python TwitterUser.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smarttypes.model.twitter_user.TwitterUser
的用法示例。
在下文中一共展示了TwitterUser.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_user_and_the_people_they_follow
# 需要导入模块: from smarttypes.model.twitter_user import TwitterUser [as 别名]
# 或者: from smarttypes.model.twitter_user.TwitterUser import save [as 别名]
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