當前位置: 首頁>>代碼示例>>Python>>正文


Python eventsProcessor.EventsProcessor類代碼示例

本文整理匯總了Python中eventsProcessor.EventsProcessor的典型用法代碼示例。如果您正苦於以下問題:Python EventsProcessor類的具體用法?Python EventsProcessor怎麽用?Python EventsProcessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EventsProcessor類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __run

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)
開發者ID:aliasfoxkde,項目名稱:BingRewards,代碼行數:55,代碼來源:main.py

示例2: __run

def __run(config):
    report = list()

    accountIndex = 0

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

# sleep between two accounts logins
        if accountIndex > 0:
            isFirstAccount = False
            extra = config.general.betweenAccountsInterval + random.uniform(0, config.general.betweenAccountsSalt)
            time.sleep(extra)

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

        __processAccount(config, reportItem, account.password)

        report.append(reportItem)

        accountIndex += 1

    EventsProcessor.onScriptComplete(config)

    #
    # trigger full report if needed
    #

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

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

        print

    #
    # print footer
    #

    print "Total points earned: %d" % totalPoints
    print
    print "%s - script ended" % helpers.getLoggingTime()
開發者ID:chrisarant,項目名稱:BingRewards,代碼行數:50,代碼來源:main.py

示例3: __processAccount

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
開發者ID:JustLikeIcarus,項目名稱:BingRewards,代碼行數:21,代碼來源:main.py

示例4: __run

def __run(config):
    report = list()

    doSleep = False

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

        reportItem = __processAccountUserAgent(config, account, bingCommon.USER_AGENTS_PC, doSleep)
        report.append(reportItem)
        doSleep = True

    
    #
    # trigger full report if needed
    #

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

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

        print

    #
    # print footer
    #

    print ("Total points earned: %d" % totalPoints)
    print
    print ("%s - script ended" % helpers.getLoggingTime())
    
    EventsProcessor.onScriptComplete(config)
開發者ID:AuthenticAMD,項目名稱:BingRewards,代碼行數:40,代碼來源:main.py

示例5: in

            showFullReport = True
        elif o in ("-v", "--verbose"):
            verbose = True
        elif o == "--version":
            printVersion()
            sys.exit()
        else:
            raise NotImplementedError("option '" + o + "' is not implemented")

    print "%s - script started" % helpers.getLoggingTime()
    print "-" * 80
    print

    helpers.createResultsDir(__file__)

    config = Config()

    try:
        config.parseFromFile(configFile)
    except IOError, e:
        print "IOError: %s" % e
        sys.exit(2)
    except ConfigError, e:
        print "ConfigError: %s" % e
        sys.exit(2)

    try:
        __run(config)
    except BaseException, e:
        EventsProcessor.onScriptFailure(config, e)
開發者ID:JustLikeIcarus,項目名稱:BingRewards,代碼行數:30,代碼來源:main.py


注:本文中的eventsProcessor.EventsProcessor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。