def run(self): while True: try: counter = 29 while not self.stop_flag: counter += 1 if counter == 30: posted_ids = twitter_ex.read_tweets(self.first_run) self.first_run = False # if settings.DEBUG: # print posted_ids for user_id in posted_ids: if not twitter_ex.is_id_in_record(user_id): suspend, spam = twitter_ex.is_id_suspended(user_id) #check if this is already suspended; #only when it is not suspended then output it as spammer. if not suspend and spam: print user_id twitter_ex.add_to_posted_spams(user_id) counter = 0 time.sleep(60) break except Exception as err: if settings.DEBUG: logger = logging.getLogger('QQ') logger.info('RecorderThread exception') logger.exception(err) time.sleep(300)
def run(self): if settings.DEBUG: logger = logging.getLogger('QQ') try: settings.write_api.PostUpdates('Test Start') except: pass try: for tweet in settings.stream_api.GetStreamSample(): if self.stop_flag: break if tweet.GetId(): if twitter_ex.is_url_spam(tweet.urls): user = tweet.GetUser() user_id = user.GetId() if not twitter_ex.is_id_in_record(user_id): if twitter_ex.is_user_spam(user): print user_id if settings.DEBUG: logger.info('newly found in stream: %d' % user_id) twitter_ex.add_to_posted_spams(user_id) #twitter_ex.add_to_spam_buffer(user_id) else: twitter_ex.add_to_normal_accounts(user_id) except Exception as err: if settings.DEBUG: logger.info('StreamerThread exception') logger.exception(err)