def scan(self, limit=None): """Scans the sub. :param limit: If None, the limit in the policy will be used :return: True if self.last_seen was reached, False otherwise """ lim = limit if limit else self.policy.Posts_To_Load # first ask for posts posts = self.get_posts(lim) if posts is None: return scan_result.Error found_old = False post_data = [] for post in posts: try: if not post.is_self: post_data.append(( post.created_utc, post.name, post.url, Actions.get_username(post), post)) except socket.error, e: if e.errno == 10061: logging.critical("praw-multiprocess not started!") else: logging.error(str(e)) return scan_result.Error except (HTTPError, NotFound) as e: # bad resolve logging.warn('Bad resolve for post {}'.format(post))
def historical_scan(self, goto): posts = self.get_historial_posts(goto) if posts is not None and len(posts): post_data = [(post.created_utc, post.name, post.url, Actions.get_username(post), post) for post in posts if not post.is_self] self.__process_post_list(post_data) return scan_result.FoundOld return scan_result.Error
def on_viewcount(self, post, website, viewcount, limit): self.remove_and_post(post, self.format_viewcount(Actions.get_username(post), post.shortlink, website, viewcount, limit))