def update(self): try: self.profile = self.conn.users_show(screen_name=self.id) # numerical fields, convert them to strings to make the buffer code more clean for field in [ 'id', 'created_at', 'followers_count', 'friends_count', 'favourites_count', 'statuses_count' ]: self.profile[field] = str(self.profile[field]) # special handling for following if self.profile['following']: self.profile['following'] = "Yes" else: self.profile['following'] = "No" # create this field specially locale.setlocale( locale.LC_TIME, 'C' ) # hacky fix because statusnet uses english timestrings regardless of locale datetime_joined = datetime.datetime.strptime( self.profile['created_at'], DATETIME_FORMAT) locale.setlocale(locale.LC_TIME, '') # other half of the hacky fix days_since_join = helpers.single_unit( helpers.time_since(datetime_joined), "days")['days'] self.profile['notices_per_day'] = "%0.2f" % ( float(self.profile['statuses_count']) / days_since_join) except StatusNetError, e: if e.errcode == 404: self.profile = None
def update(self): try: self.profile = self.conn.users_show(screen_name=self.id) # numerical fields, convert them to strings to make the buffer code more clean for field in ["id", "created_at", "followers_count", "friends_count", "favourites_count", "statuses_count"]: self.profile[field] = str(self.profile[field]) # special handling for following if self.profile["following"]: self.profile["following"] = "Yes" else: self.profile["following"] = "No" # create this field specially locale.setlocale( locale.LC_TIME, "C" ) # hacky fix because statusnet uses english timestrings regardless of locale datetime_joined = datetime.datetime.strptime(self.profile["created_at"], DATETIME_FORMAT) locale.setlocale(locale.LC_TIME, "") # other half of the hacky fix days_since_join = helpers.single_unit(helpers.time_since(datetime_joined), "days")["days"] self.profile["notices_per_day"] = "%0.2f" % (float(self.profile["statuses_count"]) / days_since_join) except StatusNetError, e: if e.errcode == 404: self.profile = None
def update(self): self.update_name() if self.paused: self.update_buffer() return get_count = config.config['notice_limit'] if self.prev_page != self.page: self.timeline = [] last_id = 0 if len(self.timeline) > 0: for notice in self.timeline: if notice["ic__from_web"]: # don't consider inserted posts latest last_id = notice['id'] break if self.timeline_type == "home": raw_timeline = self.conn.statuses_home_timeline(count=get_count, page=self.page, since_id=last_id) elif self.timeline_type == "mentions": raw_timeline = self.conn.statuses_mentions(count=get_count, page=self.page, since_id=last_id) elif self.timeline_type == "direct": raw_timeline = self.conn.direct_messages(count=get_count, page=self.page, since_id=last_id) elif self.timeline_type == "user": raw_timeline = self.conn.statuses_user_timeline(user_id=self.type_params['user_id'], screen_name=self.type_params['screen_name'], count=get_count, page=self.page, since_id=last_id) try: self.profile = self.conn.users_show(screen_name=self.type_params['screen_name']) # numerical fields, convert them to strings to make the buffer code more clean for field in ['id', 'created_at', 'followers_count', 'friends_count', 'favourites_count', 'statuses_count']: self.profile[field] = str(self.profile[field]) # special handling for following if self.profile['following']: self.profile['following'] = "Yes" else: self.profile['following'] = "No" # create this field specially datetime_joined = helpers.normalise_datetime(self.profile['created_at']) days_since_join = helpers.single_unit(helpers.time_since(datetime_joined), "days")['days'] self.profile['notices_per_day'] = "%0.2f" % (float(self.profile['statuses_count']) / days_since_join) except StatusNetError, e: if e.errcode == 404: self.profile = None
def update(self): self.update_name() if self.paused: self.update_buffer() return get_count = config.config['notice_limit'] if self.prev_page != self.page: self.timeline = [] last_id = 0 if len(self.timeline) > 0: for notice in self.timeline: if notice[ "ic__from_web"]: # don't consider inserted posts latest last_id = notice['id'] break if self.timeline_type == "home": raw_timeline = self.conn.statuses_home_timeline(count=get_count, page=self.page, since_id=last_id) elif self.timeline_type == "mentions": raw_timeline = self.conn.statuses_mentions(count=get_count, page=self.page, since_id=last_id) elif self.timeline_type == "direct": raw_timeline = self.conn.direct_messages(count=get_count, page=self.page, since_id=last_id) elif self.timeline_type == "user": raw_timeline = self.conn.statuses_user_timeline( user_id=self.type_params['user_id'], screen_name=self.type_params['screen_name'], count=get_count, page=self.page, since_id=last_id) try: self.profile = self.conn.users_show( screen_name=self.type_params['screen_name']) # numerical fields, convert them to strings to make the buffer code more clean for field in [ 'id', 'created_at', 'followers_count', 'friends_count', 'favourites_count', 'statuses_count' ]: self.profile[field] = str(self.profile[field]) # special handling for following if self.profile['following']: self.profile['following'] = "Yes" else: self.profile['following'] = "No" # create this field specially datetime_joined = helpers.normalise_datetime( self.profile['created_at']) days_since_join = helpers.single_unit( helpers.time_since(datetime_joined), "days")['days'] self.profile['notices_per_day'] = "%0.2f" % ( float(self.profile['statuses_count']) / days_since_join) except StatusNetError, e: if e.errcode == 404: self.profile = None