예제 #1
0
def __run(config):
    report = list()

    doSleep = False

    for key, account in config.accounts.iteritems():
        if account.disabled:
            continue

        # sleep between two accounts logins
        if doSleep:
            extra = config.general.betweenAccountsInterval + random.uniform(
                0, config.general.betweenAccountsSalt)
            if verbose:
                print("\nPausing between accounts for {0} seconds".format(
                    int(extra)))
            time.sleep(extra)

        reportItem = BingRewardsReportItem()
        reportItem.accountType = account.accountType
        reportItem.accountLogin = account.accountLogin

        agents = bingCommon.UserAgents.generate(account)

        httpHeaders = bingCommon.HEADERS
        httpHeaders["User-Agent"] = agents.pc

        __processAccount(config, httpHeaders, agents, reportItem,
                         account.password)

        report.append(reportItem)
        doSleep = True

    #
    # trigger full report if needed
    #

    if showFullReport or totalPoints > 0 and len(report) > 1:
        print
        print "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= FINAL REPORT =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
        print
        print "            Account           | Before | After  | Earned |  Lifetime  | Retries "
        print "------------------------------+--------+--------+--------+------------+---------"

        for r in report:
            print " %-28s | %6d | %6d | %6d | %10d | %7d" % (
                __stringifyAccount(r, 28), r.oldPoints, r.newPoints,
                r.pointsEarnedRetrying, r.lifetimeCredits, r.retries)

        print

    #
    # print footer
    #

    print "Total points earned: %d" % totalPoints
    print
    print "%s - script ended" % helpers.getLoggingTime()

    EventsProcessor.onScriptComplete(config)
예제 #2
0
    def test_config(self):
        """
        test config module
        :return:
        """
        configobj = Config()
        self.assertIsNotNone(configobj, "should return class")
        self.assertIsNotNone(Config.General(), "should return class")
        self.assertIsNotNone(ConfigError("ok"), "should return exception")
        self.assertIsNotNone(Config.Proxy(), "should return class")

        self.assertIsNotNone(Config.EventAccount(), "should return class")
        self.assertIsNotNone(Config.Event.Notify(), "should return class")
        ifs = Config.Event.IfStatement()
        ifs.op = lambda x, y: x
        ifs.lhs = lambda x: x
        ifs.rhs = "b"
        self.assertIsNotNone(str(ifs), "should return class")
        self.assertRaisesRegexp(ValueError, "None", ifs.evaluate, None)
        self.assertRaisesRegexp(TypeError, "is not of", ifs.evaluate, [])
        self.assertIsNotNone(ifs.evaluate(BingRewardsReportItem()))

        spec = Config.Event.Specifier()
        self.assertIsNotNone(spec, "should return class")
        self.assertRaisesRegexp(ValueError, "is None", spec.evaluate, None, BingRewardsReportItem())
        self.assertRaisesRegexp(TypeError, "list", spec.evaluate, [], BingRewardsReportItem())
        self.assertRaisesRegexp(ValueError, "is None", spec.evaluate, [], None)
        self.assertRaisesRegexp(TypeError, "not of BingRewardsReportItem type", spec.evaluate, [], self.config)
        self.assertIsNotNone(spec.evaluate("%a", BingRewardsReportItem()), "should return string")

        dist = os.path.join(os.path.dirname(__file__), "..", "config.xml")
        self.assertIsNone(configobj.parseFromFile(dist), "should be none")
        self.assertRaisesRegexp(ValueError, "_configFile_ is None", configobj.parseFromFile, None)
        self.assertRaisesRegexp(ValueError, "is None", self.config.parseFromString, None)
        self.assertRaisesRegexp(ConfigError, "Invalid subnode", configobj.parseFromString, InvalidXML)
        self.assertRaisesRegexp(ConfigError, "is not found", configobj.parseFromString, LOGINXML)
        self.assertRaisesRegexp(ConfigError, "is not found", configobj.parseFromString, PWDXML)
        self.assertRaisesRegexp(ConfigError, "should be either set", self.config.parseFromString, PROXYLOGINXML)
        self.assertRaisesRegexp(KeyError, "_specifier_ is not", validateSpecifier, "%not")
        self.assertRaisesRegexp(ConfigError, "Invalid subnode", self.config.parseFromString, FBXML)
예제 #3
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")
예제 #4
0
def __processAccountUserAgent(config, account, userAgents, doSleep):
# sleep between two accounts logins
    if doSleep:
        extra = config.general.betweenAccountsInterval + random.uniform(0, config.general.betweenAccountsSalt)
        time.sleep(extra)

    reportItem = BingRewardsReportItem()
    reportItem.accountType  = account.accountType
    reportItem.accountLogin = account.accountLogin

    agents = bingCommon.UserAgents.generate()

    httpHeaders = bingCommon.HEADERS
    httpHeaders["User-Agent"] = userAgents[ random.randint(0, len(userAgents) - 1) ]
    __processAccount(config, httpHeaders, agents, reportItem, account.password)

    return reportItem
예제 #5
0
def __processAccountUserAgent(config, account, userAgents, doSleep):
# sleep between two accounts logins
    if doSleep:
        extra = config.general.betweenAccountsInterval + random.uniform(0, config.general.betweenAccountsSalt)
        if verbose:
            print
            print("Pausing between accounts for {0} seconds".format(int(extra)))
        time.sleep(extra)

    reportItem = BingRewardsReportItem()
    reportItem.accountType  = account.accountType
    reportItem.accountLogin = account.accountLogin

    agents = bingCommon.UserAgents.generate(account)

    httpHeaders = bingCommon.HEADERS
    httpHeaders["User-Agent"] = agents.pc

    __processAccount(config, httpHeaders, agents, reportItem, account.password)

    return reportItem
예제 #6
0
def processAccount(config):
    bp = BingRewardsReportItem()
    return main.__processAccount(config, None, None, bp, "")