本文整理汇总了Python中models.Status.status_id方法的典型用法代码示例。如果您正苦于以下问题:Python Status.status_id方法的具体用法?Python Status.status_id怎么用?Python Status.status_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Status
的用法示例。
在下文中一共展示了Status.status_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import status_id [as 别名]
def put(self, status):
s = Status()
s.status_id = status.id
s.user = status.from_user
s.text = status.text
s.icon_url = status.profile_image_url
s.put()
示例2: updateStatus
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import status_id [as 别名]
def updateStatus(params):
new_text = params.get("status")
location = params.get("location")
if location:
del params["location"]
new_source_id = params.get("source_id")
if new_source_id:
del params["source_id"]
db.init_db()
statuses = db.session.query(Status).all()
logger.info("Number of statuses: %d" % len(statuses))
existing_texts = [status.text for status in statuses]
source_ids = [status.source_id for status in statuses if status.source_id] or []
if new_text in existing_texts or new_source_id in source_ids:
logger.info("Duplicate status")
return
lat = None
lon = None
status_data = {}
if params.get("media[]"):
# Post with media
status_data = twitter_api.statuses.update_with_media(**params)
else:
# Regular tweet settings
locations = {"home": config.TWEET_HOME_GEO, "work": config.TWEET_WORK_GEO}
if isinstance(location, basestring):
# Somewhat randomize location
lat = locations.get(location)[0] + (0.00001 * randrange(150))
lon = locations.get(location)[1] + (0.00001 * randrange(150))
elif location:
lat = location[0]
lon = location[1]
params["lat"] = lat
params["long"] = lon
params["possibly_sensitive"] = True
status_data = twitter_api.statuses.update(**params)
new_status = Status()
new_status.status_id = status_data.get("id_str")
new_status.created_at = parser.parse(status_data.get("created_at")).replace(tzinfo=None)
if lat:
new_status.lat = lat
if lon:
new_status.lon = lon
new_status.text = new_text
if new_source_id:
new_status.source_id = new_source_id
db.session.merge(new_status)
db.session.commit()
logger.info("Tweeted: %s" % new_text)