Пример #1
0
class TweeterOffersParse:
    def __init__(self, config_path, send_user_ids_path):
        self.config = {}
        execfile(config_path, self.config)

        twitter_connect_info = [self.config["consumer_key"],self.config["consumer_secret"], self.config["token_key"], self.config["token_secret"]]
        self.tweeter_parser = TwitterParser(twitter_connect_info, REGEX, send_user_ids_path)
        self.email_sender = EmailSender(self.config["email_user"], self.config["email_psw"])

        for sig in (SIGABRT, SIGILL, SIGINT, SIGSEGV, SIGTERM):
            signal(sig, self.exitSignalHandler)

        self.startParsing()


    # main loop function
    def startParsing(self):
        # for each user
        for user in self.config["twitter_accounts"]:
            # get all tweets to be send
            tweets_status = self.tweeter_parser.parseUserTweets(user)
            for tweet_status in tweets_status:
                # send tweet
                self.email_sender.sendEmail(self.config["email_sender"],
                        self.config["offers_email_receivers"],
                        tweet_status)

    # function called at: SIGABRT, SIGILL, SIGINT, SIGSEGV, SIGTERM
    def exitSignalHandler(self, *args):
        self.tweeter_parser.saveSendUsersIds()
        sys.exit(0)
Пример #2
0
    def __init__(self, config_path, send_user_ids_path):
        self.config = {}
        execfile(config_path, self.config)

        twitter_connect_info = [self.config["consumer_key"],self.config["consumer_secret"], self.config["token_key"], self.config["token_secret"]]
        self.tweeter_parser = TwitterParser(twitter_connect_info, REGEX, send_user_ids_path)
        self.email_sender = EmailSender(self.config["email_user"], self.config["email_psw"])

        for sig in (SIGABRT, SIGILL, SIGINT, SIGSEGV, SIGTERM):
            signal(sig, self.exitSignalHandler)

        self.startParsing()