本文整理匯總了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)
示例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()
示例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
示例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)
示例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)