示例#1
0
def main():
	Globals.init()
	# Uncomment these lines if you are writing files to disk
#	if not os.path.exists("de"):
#		os.makedirs("de")
#	if not os.path.exists("es"):
#		os.makedirs("es")
#	if not os.path.exists("fr"):
#		os.makedirs("fr")
	mytime = "<span class=\"localtime\">" + datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')+u'+00:00</span>'
	print "Start: ", datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
	# will hold our guide names, so no more manually creating upload list
	guides = []
	# Will hold level:total xp pairs (array)
	xp_to_level = [0]
	# populate the xp chart
	for i in range(1,510):
		xp_to_level.append(Globals.xpreq(i)+xp_to_level[i-1])

	cList = appendCosts()

	out_q = Queue()
	#TODO change the way flags are passed so it is easier to understand

	cooking_karma = join(Chef.recipes, Chef_karma.recipes)
	rList = [[(u"cooking_karma_fast.html",cooking_karma,True,False,range(0,400,25)),
			 (u"cooking_karma_fast_light.html",cooking_karma,True,False,range(0,400,25))],
			 [(u"cooking_karma.html",cooking_karma,False,False,range(0,400,25)),
			 (u"cooking_karma_light.html",cooking_karma,False,False,range(0,400,25))],
			 (u"cooking_fast.html",Chef.recipes,True,False,range(0,400,25)),
			 (u"cooking.html",Chef.recipes,False,False,range(0,400,25)),
			 (u"cooking_fast_200.html",Chef.recipes,True,False,range(0,200,25)),
			 (u"cooking_karma_fast_200.html",cooking_karma,True,False,range(0,200,25)),
			 (u"jewelcraft_fast.html",Jeweler.recipes,True,False,range(0,400,25)),
			 (u"jewelcraft.html",Jeweler.recipes,False,False,range(0,400,25)),
			 (u"jewelcraft_400.html",Jeweler.recipes,False,True,range(400,500,25)),
			 (u"jewelcraft_450.html",Jeweler.recipes,False,True,range(400,450,25)),
			 (u"artificing_fast.html",Artificer.recipes,True,False,range(0,400,25)),
			 (u"artificing.html",Artificer.recipes,False,False,range(0,400,25)),
			 (u"artificing_400.html",Artificer.recipes,False,True,range(400,500,25)),
			 (u"artificing_450.html",Artificer.recipes,False,True,range(400,450,25)),
			 (u"weaponcraft_fast.html",Weaponsmith.recipes,True,False,range(0,400,25)),
			 (u"weaponcraft.html",Weaponsmith.recipes,False,False,range(0,400,25)),
			 (u"weaponcraft_400.html",Weaponsmith.recipes,False,True,range(400,500,25)),
			 (u"weaponcraft_450.html",Weaponsmith.recipes,False,True,range(400,450,25)),
			 (u"huntsman_fast.html",Huntsman.recipes,True,False,range(0,400,25)),
			 (u"huntsman.html",Huntsman.recipes,False,False,range(0,400,25)),
			 (u"huntsman_400.html",Huntsman.recipes,False,True,range(400,500,25)),
			 (u"huntsman_450.html",Huntsman.recipes,False,True,range(400,450,25)),
			 (u"armorcraft_fast.html",Armorsmith.recipes,True,False,range(0,400,25)),
			 (u"armorcraft.html",Armorsmith.recipes,False,False,range(0,400,25)),
			 (u"armorcraft_400.html",Armorsmith.recipes,False,True,range(400,500,25)),
			 (u"armorcraft_450.html",Armorsmith.recipes,False,True,range(400,450,25)),
			 (u"tailor_fast.html",Tailor.recipes,True,False,range(0,400,25)),
			 (u"tailor.html",Tailor.recipes,False,False,range(0,400,25)),
			 (u"tailor_400.html",Tailor.recipes,False,True,range(400,500,25)),
			 (u"tailor_450.html",Tailor.recipes,False,True,range(400,450,25)),
			 (u"leatherworking_fast.html",Leatherworker.recipes,True,False,range(0,400,25)),
			 (u"leatherworking.html",Leatherworker.recipes,False,False,range(0,400,25)),
			 (u"leatherworking_400.html",Leatherworker.recipes,False,True,range(400,500,25)),
			 (u"leatherworking_450.html",Leatherworker.recipes,False,True,range(400,450,25))]

	nprocs = cpu_count() * 2

	procs = []
	global header
	global cright

	chunksize = int(math.ceil(len(rList) / float(nprocs)))

	for i in range(nprocs):
		p = Process(target=recipeworker,args=(rList[chunksize * i:chunksize * (i + 1)],cList,mytime,xp_to_level,out_q))
		procs.append(p)
		p.start()

	totals = {}
	for i in range(nprocs):
		totals.update(out_q.get())

	for p in procs:
		p.join(180)
		# if thread is still alive after 180 seconds, something is wrong.  Kill the script.
		if p.is_alive():
			sys.exit(0)

	maketotals(totals,mytime,Localen)
	maketotals(totals,mytime,Localde)
	maketotals(totals,mytime,Localfr)
	maketotals(totals,mytime,Locales)
	maketotals(totals,mytime,Localcz)
	maketotals(totals,mytime,Localptbr)

	print "End: ", datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
示例#2
0
def main():
	mytime = "<span class=\"localtime\">" + datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')+u'+00:00</span>'
	print "Start: ", datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
	# Will hold level:total xp pairs (array)
	xp_to_level = [0]
	# populate the xp chart
	for i in range(1,510):
		xp_to_level.append(Globals.xpreq(i)+xp_to_level[i-1])

	cList = appendCosts()

	#TODO change the way flags are passed so it is easier to understand

	cooking_karma = join(Chef.recipes, Chef_karma.recipes)
	rList = [[(u"cooking_karma_fast.html",cooking_karma,True,False,range(0,400,25)),
			 (u"cooking_karma_fast_light.html",cooking_karma,True,False,range(0,400,25))],
			 [(u"cooking_karma.html",cooking_karma,False,False,range(0,400,25)),
			 (u"cooking_karma_light.html",cooking_karma,False,False,range(0,400,25))],
			 (u"cooking_fast.html", Chef.recipes, True, False, range(0, 400, 25)),
			 (u"cooking.html", Chef.recipes, False, False, range(0, 400, 25)),
			 (u"cooking_fast_200.html", Chef.recipes, True, False, range(0, 200, 25)),
			 (u"cooking_karma_fast_200.html",cooking_karma,True,False,range(0,200,25)),
			 (u"jewelcraft_fast.html", Jeweler.recipes, True, False, range(0, 400, 25)),
			 (u"jewelcraft.html", Jeweler.recipes, False, False, range(0, 400, 25)),
			 (u"jewelcraft_400.html", Jeweler.recipes, False, True, range(400, 500, 25)),
			 (u"jewelcraft_450.html", Jeweler.recipes, False, True, range(400, 450, 25)),
			 (u"artificing_fast.html", Artificer.recipes, True, False, range(0, 400, 25)),
			 (u"artificing.html", Artificer.recipes, False, False, range(0, 400, 25)),
			 (u"artificing_400.html", Artificer.recipes, False, True, range(400, 500, 25)),
			 (u"artificing_450.html", Artificer.recipes, False, True, range(400, 450, 25)),
			 (u"weaponcraft_fast.html", Weaponsmith.recipes, True, False, range(0, 400, 25)),
			 (u"weaponcraft.html", Weaponsmith.recipes, False, False, range(0, 400, 25)),
			 (u"weaponcraft_400.html", Weaponsmith.recipes, False, True, range(400, 500, 25)),
			 (u"weaponcraft_450.html", Weaponsmith.recipes, False, True, range(400, 450, 25)),
			 (u"huntsman_fast.html", Huntsman.recipes, True, False, range(0, 400, 25)),
			 (u"huntsman.html", Huntsman.recipes, False, False, range(0, 400, 25)),
			 (u"huntsman_400.html", Huntsman.recipes, False, True, range(400, 500, 25)),
			 (u"huntsman_450.html", Huntsman.recipes, False, True, range(400, 450, 25)),
			 (u"armorcraft_fast.html", Armorsmith.recipes, True, False, range(0, 400, 25)),
			 (u"armorcraft.html", Armorsmith.recipes, False, False, range(0, 400, 25)),
			 (u"armorcraft_400.html", Armorsmith.recipes, False, True, range(400, 500, 25)),
			 (u"armorcraft_450.html", Armorsmith.recipes, False, True, range(400, 450, 25)),
			 (u"tailor_fast.html", Tailor.recipes, True, False, range(0, 400, 25)),
			 (u"tailor.html", Tailor.recipes, False, False, range(0, 400, 25)),
			 (u"tailor_400.html", Tailor.recipes, False, True, range(400, 500, 25)),
			 (u"tailor_450.html", Tailor.recipes, False, True, range(400, 450, 25)),
			 (u"leatherworking_fast.html", Leatherworker.recipes, True, False, range(0, 400, 25)),
			 (u"leatherworking.html", Leatherworker.recipes, False, False, range(0, 400, 25)),
			 (u"leatherworking_400.html", Leatherworker.recipes, False, True, range(400, 500, 25)),
			 (u"leatherworking_450.html", Leatherworker.recipes, False, True, range(400, 450, 25)),
			 (u"scribe.html", Scribe.recipes, False, False, range(0, 400, 25))]

	p = Pool(2)
	params = [(rList[i], cList, mytime, xp_to_level) for i in range(0, len(rList))]
	procs = p.map(recipeworker, params)

	totals = {}
	for i in procs:
		totals.update(i)

	maketotals(totals, mytime, Localen)
	maketotals(totals, mytime, Localde)
	maketotals(totals, mytime, Localfr)
	maketotals(totals, mytime, Locales)
	maketotals(totals, mytime, Localcz)
	maketotals(totals, mytime, Localptbr)

	print "End: ", datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
示例#3
0
def main():
	backupkey = 'archive/' + datetime.datetime.utcnow().strftime('%Y%m%dT%H%M%S')
	mytime = "<span class=\"localtime\">" + datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S') + '+00:00</span>'
	# Will hold level:total xp pairs (array)
	xp_to_level = [0]
	# populate the xp chart
	for i in range(1, 510):
		xp_to_level.append(Globals.xpreq(i) + xp_to_level[i - 1])

	with mytimer('costs'):
		cList = appendCosts()

	# create a copy of our pricelist and update the prices for non-whitelisted items
	cList_free = deepcopy(cList)
	for item in cList_free:
		if not cList_free[item]['whitelist']:
			cList_free[item]['cost'] = sys.maxsize
		del cList[item]['whitelist']
		del cList_free[item]['whitelist']

	cooking_karma = join(Chef.recipes, Chef_karma.recipes)
	rList = [
		[("cooking_karma_fast.html", cooking_karma, True, False, list(range(0, 400, 25))),
		 ("cooking_karma_fast_light.html", cooking_karma, True, False, list(range(0, 400, 25)))],
		[("cooking_karma.html", cooking_karma, False, False, list(range(0, 400, 25))),
		 ("cooking_karma_light.html", cooking_karma, False, False, list(range(0, 400, 25)))],
		("cooking_fast.html", Chef.recipes, True, False, list(range(0, 400, 25))),
		("cooking.html", Chef.recipes, False, False, list(range(0, 400, 25))),
		("cooking_fast_200.html", Chef.recipes, True, False, list(range(0, 200, 25))),
		("cooking_karma_fast_200.html", cooking_karma, True, False, list(range(0, 200, 25))),

#		(u"cooking_karma_400.html", cooking_karma, False, False, range(400, 500, 25)),
		("cooking_karma_450.html", cooking_karma, False, False, list(range(400, 450, 25))),
#		(u"cooking_400.html", Chef.recipes, False, False, range(400, 500, 25)),
		("cooking_450.html", Chef.recipes, False, False, list(range(400, 450, 25))),

		("jewelcraft_fast.html", Jeweler.recipes, True, False, list(range(0, 400, 25))),
		("jewelcraft.html", Jeweler.recipes, False, False, list(range(0, 400, 25))),
#		(u"jewelcraft_400.html", Jeweler.recipes, False, True, range(400, 500, 25)),
#		(u"jewelcraft_450.html", Jeweler.recipes, False, True, range(400, 450, 25)),
		("artificing_fast.html", Artificer.recipes, True, False, list(range(0, 400, 25))),
		("artificing.html", Artificer.recipes, False, False, list(range(0, 400, 25))),
		("artificing_400.html", Artificer.recipes, False, True, list(range(400, 500, 25))),
		("artificing_450.html", Artificer.recipes, False, True, list(range(400, 450, 25))),
		("weaponcraft_fast.html", Weaponsmith.recipes, True, False, list(range(0, 400, 25))),
		("weaponcraft.html", Weaponsmith.recipes, False, False, list(range(0, 400, 25))),
		("weaponcraft_400.html", Weaponsmith.recipes, False, True, list(range(400, 500, 25))),
		("weaponcraft_450.html", Weaponsmith.recipes, False, True, list(range(400, 450, 25))),
		("huntsman_fast.html", Huntsman.recipes, True, False, list(range(0, 400, 25))),
		("huntsman.html", Huntsman.recipes, False, False, list(range(0, 400, 25))),
		("huntsman_400.html", Huntsman.recipes, False, True, list(range(400, 500, 25))),
		("huntsman_450.html", Huntsman.recipes, False, True, list(range(400, 450, 25))),
		("armorcraft_fast.html", Armorsmith.recipes, True, False, list(range(0, 400, 25))),
		("armorcraft.html", Armorsmith.recipes, False, False, list(range(0, 400, 25))),
		("armorcraft_400.html", Armorsmith.recipes, False, True, list(range(400, 500, 25))),
		("armorcraft_450.html", Armorsmith.recipes, False, True, list(range(400, 450, 25))),
		("tailor_fast.html", Tailor.recipes, True, False, list(range(0, 400, 25))),
		("tailor.html", Tailor.recipes, False, False, list(range(0, 400, 25))),
		("tailor_400.html", Tailor.recipes, False, True, list(range(400, 500, 25))),
		("tailor_450.html", Tailor.recipes, False, True, list(range(400, 450, 25))),
		("leatherworking_fast.html", Leatherworker.recipes, True, False, list(range(0, 400, 25))),
		("leatherworking.html", Leatherworker.recipes, False, False, list(range(0, 400, 25))),
		("leatherworking_400.html", Leatherworker.recipes, False, True, list(range(400, 500, 25))),
		("leatherworking_450.html", Leatherworker.recipes, False, True, list(range(400, 450, 25))),
	]

	p = Pool(cpu_count() - 1 if cpu_count() > 1 else 1)
	#p = Pool(1)
	# create params for the core and free guides
#	for my_list, free in [(cList, False), (cList_free, True)]:
#	from hanging_threads import start_monitoring
#	monitoring_thread = start_monitoring()
	params = []
	for i in range(0, len(rList)):
		params.append((rList[i], cList, False, mytime, xp_to_level, backupkey))
		params.append((rList[i], cList_free, True, mytime, xp_to_level, backupkey))
	# free accounts can't follow scribe guides
	params.append((("scribe.html", Scribe.recipes, False, False, list(range(0, 400, 25))), cList, False, mytime, xp_to_level, backupkey))

	procs = p.map(recipeworker, params)

	totals = {}
	totals_free = {'scribe': {0: 0, 75: 0, 150: 0, 225: 0, 300: 0, 'total': 0}}
	# this needs to be rewritten so that we can do the free and core guides in the same queue
	for i in procs:
		val = i['free']
		del i['free']
		if val:
			totals_free.update(i)
		else:
			totals.update(i)

	for lang in [Localen, Localde, Localfr, Locales, Localcz, Localptbr, Localzh]:
		maketotals(totals, mytime, lang, False)
		maketotals(totals_free, mytime, lang, True)
示例#4
0
def main():
    backupkey = 'archive/' + datetime.datetime.utcnow().strftime(
        '%Y%m%dT%H%M%S')
    mytime = "<span class=\"localtime\">" + datetime.datetime.utcnow(
    ).strftime('%Y-%m-%dT%H:%M:%S') + u'+00:00</span>'
    # Will hold level:total xp pairs (array)
    xp_to_level = [0]
    # populate the xp chart
    for i in range(1, 510):
        xp_to_level.append(Globals.xpreq(i) + xp_to_level[i - 1])

    with mytimer('costs'):
        cList = appendCosts()

    # TODO change the way flags are passed so it is easier to understand

    cooking_karma = join(Chef.recipes, Chef_karma.recipes)
    rList = [
        [(u"cooking_karma_fast.html", cooking_karma, True, False,
          range(0, 400, 25)),
         (u"cooking_karma_fast_light.html", cooking_karma, True, False,
          range(0, 400, 25))],
        [(u"cooking_karma.html", cooking_karma, False, False,
          range(0, 400, 25)),
         (u"cooking_karma_light.html", cooking_karma, False, False,
          range(0, 400, 25))],
        (u"cooking_fast.html", Chef.recipes, True, False, range(0, 400, 25)),
        (u"cooking.html", Chef.recipes, False, False, range(0, 400, 25)),
        (u"cooking_fast_200.html", Chef.recipes, True, False,
         range(0, 200, 25)),
        (u"cooking_karma_fast_200.html", cooking_karma, True, False,
         range(0, 200, 25)),

        #		(u"cooking_karma_400.html", cooking_karma, False, False, range(400, 500, 25)),
        (u"cooking_karma_450.html", cooking_karma, False, False,
         range(400, 450, 25)),
        #		(u"cooking_400.html", Chef.recipes, False, False, range(400, 500, 25)),
        (u"cooking_450.html", Chef.recipes, False, False, range(400, 450, 25)),
        (u"jewelcraft_fast.html", Jeweler.recipes, True, False,
         range(0, 400, 25)),
        (u"jewelcraft.html", Jeweler.recipes, False, False, range(0, 400, 25)),
        #		(u"jewelcraft_400.html", Jeweler.recipes, False, True, range(400, 500, 25)),
        #		(u"jewelcraft_450.html", Jeweler.recipes, False, True, range(400, 450, 25)),
        (u"artificing_fast.html", Artificer.recipes, True, False,
         range(0, 400, 25)),
        (u"artificing.html", Artificer.recipes, False, False,
         range(0, 400, 25)),
        (u"artificing_400.html", Artificer.recipes, False, True,
         range(400, 500, 25)),
        (u"artificing_450.html", Artificer.recipes, False, True,
         range(400, 450, 25)),
        (u"weaponcraft_fast.html", Weaponsmith.recipes, True, False,
         range(0, 400, 25)),
        (u"weaponcraft.html", Weaponsmith.recipes, False, False,
         range(0, 400, 25)),
        (u"weaponcraft_400.html", Weaponsmith.recipes, False, True,
         range(400, 500, 25)),
        (u"weaponcraft_450.html", Weaponsmith.recipes, False, True,
         range(400, 450, 25)),
        (u"huntsman_fast.html", Huntsman.recipes, True, False,
         range(0, 400, 25)),
        (u"huntsman.html", Huntsman.recipes, False, False, range(0, 400, 25)),
        (u"huntsman_400.html", Huntsman.recipes, False, True,
         range(400, 500, 25)),
        (u"huntsman_450.html", Huntsman.recipes, False, True,
         range(400, 450, 25)),
        (u"armorcraft_fast.html", Armorsmith.recipes, True, False,
         range(0, 400, 25)),
        (u"armorcraft.html", Armorsmith.recipes, False, False,
         range(0, 400, 25)),
        (u"armorcraft_400.html", Armorsmith.recipes, False, True,
         range(400, 500, 25)),
        (u"armorcraft_450.html", Armorsmith.recipes, False, True,
         range(400, 450, 25)),
        (u"tailor_fast.html", Tailor.recipes, True, False, range(0, 400, 25)),
        (u"tailor.html", Tailor.recipes, False, False, range(0, 400, 25)),
        (u"tailor_400.html", Tailor.recipes, False, True, range(400, 500, 25)),
        (u"tailor_450.html", Tailor.recipes, False, True, range(400, 450, 25)),
        (u"leatherworking_fast.html", Leatherworker.recipes, True, False,
         range(0, 400, 25)),
        (u"leatherworking.html", Leatherworker.recipes, False, False,
         range(0, 400, 25)),
        (u"leatherworking_400.html", Leatherworker.recipes, False, True,
         range(400, 500, 25)),
        (u"leatherworking_450.html", Leatherworker.recipes, False, True,
         range(400, 450, 25)),
        (u"scribe.html", Scribe.recipes, False, False, range(0, 400, 25)),
    ]

    p = Pool(cpu_count() - 1 if cpu_count() > 1 else 1)
    #p = Pool(1)
    params = [(rList[i], cList, mytime, xp_to_level, backupkey)
              for i in range(0, len(rList))]
    procs = p.map(recipeworker, params)

    totals = {}
    for i in procs:
        totals.update(i)

    maketotals(totals, mytime, Localen)
    maketotals(totals, mytime, Localde)
    maketotals(totals, mytime, Localfr)
    maketotals(totals, mytime, Locales)
    maketotals(totals, mytime, Localcz)
    maketotals(totals, mytime, Localptbr)
    maketotals(totals, mytime, Localzh)