本文整理汇总了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)