def doReceive(self, mail_message):
        """receives an email and log it"""
        logging.info("We have received someting new")
        # log the entry .DEBUG
        logging.debug(mail_message.subject)
        #logging.debug(self.getBody(mail_message)) #  too many output

        # extract the links to episodes in the email received
        episodeLinks = extract.linksToEpisodes(
            self.getBody(mail_message))  # Links list

        # for each one, we will create an task
        for ep in episodeLinks:
            logging.debug("creating a task for the episode found")
            logging.debug(ep)
            try:
                # Create a queue
                queue = taskqueue.Queue('newEpisode')
                # Conform a task
                task = taskqueue.Task(url='/tasks/newEpisode',
                                      params={
                                          'episodeLink': ep,
                                          'submitter': mail_message.sender,
                                      })
                # Add the task to the queue.
                queue.add(task)
            except TypeError as err:
                logging.error("Error")
                logging.error(err)
                logging.error(mail_message)
    def doReceive(self, mail_message):
        """receives an email and log it"""
        logging.info("We have received someting new")
        # log the entry .DEBUG
        logging.debug(mail_message.subject)
        #logging.debug(self.getBody(mail_message)) #  too many output

        # extract the links to episodes in the email received
        episodeLinks = extract.linksToEpisodes(
                                self.getBody(mail_message))  # Links list

        # for each one, we will create an task
        for ep in episodeLinks:
            logging.debug("creating a task for the episode found")
            logging.debug(ep)
            try:
                # Create a queue
                queue = taskqueue.Queue('newEpisode')
                # Conform a task
                task = taskqueue.Task(url='/tasks/newEpisode',
                              params={'episodeLink': ep,
                              'submitter': mail_message.sender,})
                # Add the task to the queue.
                queue.add(task)
            except TypeError as err:
                logging.error("Error")
                logging.error(err)
                logging.error(mail_message)
Example #3
0
def test_matching_extractors_are_executed():
    def fake_extractor1(msg):
        print "nice"
        return ["nice"]

    def fake_extractor2(msg):
        print "beautiful"
        return ["beautiful"]

    def fake_extractor3(msg):
        print "ugly"
        return ["ugly"]

    extractors = {
        "foo": fake_extractor1,
        "gaita": fake_extractor2,
        "ochourizo": fake_extractor3
    }

    result = extract.linksToEpisodes("foo gaita", extractors)
    expect = ["beautiful", "nice"]
    assert_equal(result, expect)
Example #4
0
def test_matching_extractors_are_executed():
    def fake_extractor1(msg):
        print "nice"
        return ["nice"]

    def fake_extractor2(msg):
        print "beautiful"
        return ["beautiful"]

    def fake_extractor3(msg):
        print "ugly"
        return ["ugly"]

    extractors = {
           "foo": fake_extractor1,
           "gaita": fake_extractor2,
           "ochourizo": fake_extractor3
           }

    result = extract.linksToEpisodes("foo gaita", extractors)
    expect = ["beautiful","nice"]
    assert_equal(result, expect)
Example #5
0
def test_with_a_failing_extractor_die_and_cry():
    def fake_extractor(msg):
        raise FakeException

    extract.linksToEpisodes("foo", {"foo": fake_extractor})
Example #6
0
def test_with_no_extractors_die_and_cry():
    extract.linksToEpisodes("", {})
Example #7
0
def test_with_a_failing_extractor_die_and_cry():
    def fake_extractor(msg):
        raise FakeException

    extract.linksToEpisodes("foo", {"foo": fake_extractor})
Example #8
0
def test_with_no_extractors_die_and_cry():
    extract.linksToEpisodes("",{})