Ejemplo n.º 1
0
 def test_event(self):
     """
     test event
     :return:
     """
     self.assertIsNone(EventsProcessor.onScriptFailure(self.config, Exception()), "should be none")
     self.assertIsNone(EventsProcessor.onScriptComplete(self.config), "should be none")
     self.assertRaisesRegexp(ConfigError, "not found", self.config.parseFromString, EVENT)
     self.config.parseFromString(EVENTLESS)
     self.assertRaisesRegexp(Exception, ".*", EventsProcessor.onScriptFailure, self.config, Exception())
     self.assertIsNone(EventsProcessor.onScriptComplete(self.config), "should be none")
     ep = EventsProcessor(self.config, BingRewardsReportItem())
     self.assertIsNotNone(ep.processReportItem(), "should not be none and be done")
Ejemplo n.º 2
0
def __processAccount(config, httpHeaders, userAgents, reportItem, accountPassword):
    global totalPoints
    eventsProcessor = EventsProcessor(config, reportItem)
    while True:
        reportItem.retries += 1

        if reportItem.retries > 1:
            print "retry #" + str(reportItem.retries)

        earnRewards(config, httpHeaders, userAgents, reportItem, accountPassword)
        totalPoints += reportItem.pointsEarned

        result, extra = eventsProcessor.processReportItem()
        if result == EventsProcessor.OK:
            break
        elif result == EventsProcessor.RETRY:
            time.sleep(extra)
        else:
            # TODO: implement as Utils.warn() or something
            print "Unexpected result from eventsProcessor.processReportItem() = ( %s, %s )" % (result, extra)
            break