本文整理汇总了Python中services.managers.eve_api_manager.EveApiManager.get_corp_standings方法的典型用法代码示例。如果您正苦于以下问题:Python EveApiManager.get_corp_standings方法的具体用法?Python EveApiManager.get_corp_standings怎么用?Python EveApiManager.get_corp_standings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类services.managers.eve_api_manager.EveApiManager
的用法示例。
在下文中一共展示了EveApiManager.get_corp_standings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_corp_update
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import get_corp_standings [as 别名]
def run_corp_update():
# I am not proud of this block of code
if EveApiManager.check_if_api_server_online():
logger.debug("API server online and reachable. Proceeding with corp update.")
if settings.IS_CORP:
# Create the corp
logger.debug(
"Ensuring corp model exists for owning corp id %s due to settings.IS_CORP %s"
% (settings.CORP_ID, settings.IS_CORP)
)
ownercorpinfo = EveApiManager.get_corporation_information(settings.CORP_ID)
logger.debug("Determined ownercorp info: %s" % ownercorpinfo)
if not EveManager.check_if_corporation_exists_by_id(ownercorpinfo["id"]):
logger.debug("Owning corp id %s does not have a model. Creating." % ownercorpinfo["id"])
if ownercorpinfo["alliance"]["id"] is None:
logger.debug("Owning corp does not have an alliance. Creating model with alliance=None")
EveManager.create_corporation_info(
ownercorpinfo["id"],
ownercorpinfo["name"],
ownercorpinfo["ticker"],
ownercorpinfo["members"]["current"],
False,
None,
)
else:
alliance_info = EveApiManager.get_alliance_information(ownercorpinfo["alliance"]["id"])
logger.debug("Owning corp has an alliance, got info: %s" % alliance_info)
if not EveManager.check_if_alliance_exists_by_id(ownercorpinfo["alliance"]["id"]):
logger.debug(
"Owning corp missing alliance model. Creating for id %s" % ownercorpinfo["alliance"]["id"]
)
EveManager.create_alliance_info(
ownercorpinfo["alliance"]["id"],
alliance_info["name"],
alliance_info["ticker"],
alliance_info["executor_id"],
alliance_info["member_count"],
False,
)
alliance = EveManager.get_alliance_info_by_id(ownercorpinfo["alliance"]["id"])
logger.debug("Got alliance model %s for owning corp. Creating corp model." % alliance)
EveManager.create_corporation_info(
ownercorpinfo["id"],
ownercorpinfo["name"],
ownercorpinfo["ticker"],
ownercorpinfo["members"]["current"],
False,
alliance,
)
else:
# Updated alliance info
logger.debug("Getting info for owning alliance %s" % settings.ALLIANCE_ID)
alliance_info = EveApiManager.get_alliance_information(settings.ALLIANCE_ID)
logger.debug("Owning alliance info: %s" % alliance_info)
# Populate alliance info
if not EveManager.check_if_alliance_exists_by_id(settings.ALLIANCE_ID):
logger.debug("Missing alliance model for owning alliance. Creating with id %s" % settings.ALLIANCE_ID)
EveManager.create_alliance_info(
settings.ALLIANCE_ID,
alliance_info["name"],
alliance_info["ticker"],
alliance_info["executor_id"],
alliance_info["member_count"],
False,
)
alliance = EveManager.get_alliance_info_by_id(settings.ALLIANCE_ID)
logger.debug("Got owning alliance model %s" % alliance)
# Create the corps in the alliance
for alliance_corp in alliance_info["member_corps"]:
corpinfo = EveApiManager.get_corporation_information(alliance_corp)
logger.debug("Got corpinfo for alliance member corp: %s" % corpinfo)
if not EveManager.check_if_corporation_exists_by_id(corpinfo["id"]):
logger.debug("Alliance member corp id %s missing model - creating." % corpinfo["id"])
EveManager.create_corporation_info(
corpinfo["id"],
corpinfo["name"],
corpinfo["ticker"],
corpinfo["members"]["current"],
False,
alliance,
)
# determine what level of standings to check
# refer to https://github.com/eve-val/evelink/blob/master/evelink/parsing/contact_list.py#L43
standing_level = "alliance"
if settings.IS_CORP:
logger.debug("Switching standings check to corp level.")
standing_level = "corp"
# Create the corps in the standings
corp_standings = EveApiManager.get_corp_standings()
logger.debug("Got %s corp standings." % len(corp_standings))
if corp_standings:
for standing_id in EveApiManager.get_corp_standings()[standing_level]:
logger.debug("Processing standing id %s" % standing_id)
if int(corp_standings[standing_level][standing_id]["standing"]) >= settings.BLUE_STANDING:
logger.debug("Standing %s meets or exceeds blue threshold." % standing_id)
if EveApiManager.check_if_id_is_character(standing_id):
logger.debug("Standing id %s is a character. Not creating model.")
#.........这里部分代码省略.........
示例2: run_corp_update
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import get_corp_standings [as 别名]
def run_corp_update():
# I am not proud of this block of code
if EveApiManager.check_if_api_server_online():
if settings.IS_CORP:
# Create the corp
ownercorpinfo = EveApiManager.get_corporation_information(settings.CORP_ID)
if not EveManager.check_if_corporation_exists_by_id(ownercorpinfo['id']):
if ownercorpinfo['alliance']['id'] is None:
EveManager.create_corporation_info(ownercorpinfo['id'], ownercorpinfo['name'], ownercorpinfo['ticker'],
ownercorpinfo['members']['current'], False, None)
else:
alliance_info = EveApiManager.get_alliance_information(ownercorpinfo['alliance']['id'])
if not EveManager.check_if_alliance_exists_by_id(settings.ALLIANCE_ID):
EveManager.create_alliance_info(settings.ALLIANCE_ID, alliance_info['name'], alliance_info['ticker'],
alliance_info['executor_id'], alliance_info['member_count'], False)
alliance = EveManager.get_alliance_info_by_id(ownercorpinfo['alliance']['id'])
EveManager.create_corporation_info(ownercorpinfo['id'], ownercorpinfo['name'], ownercorpinfo['ticker'],
ownercorpinfo['members']['current'], False, alliance)
else:
# Updated alliance info
alliance_info = EveApiManager.get_alliance_information(settings.ALLIANCE_ID)
# Populate alliance info
if not EveManager.check_if_alliance_exists_by_id(settings.ALLIANCE_ID):
EveManager.create_alliance_info(settings.ALLIANCE_ID, alliance_info['name'], alliance_info['ticker'],
alliance_info['executor_id'], alliance_info['member_count'], False)
alliance = EveManager.get_alliance_info_by_id(settings.ALLIANCE_ID)
# Create the corps in the alliance
for alliance_corp in alliance_info['member_corps']:
corpinfo = EveApiManager.get_corporation_information(alliance_corp)
if not EveManager.check_if_corporation_exists_by_id(corpinfo['id']):
EveManager.create_corporation_info(corpinfo['id'], corpinfo['name'], corpinfo['ticker'],
corpinfo['members']['current'], False, alliance)
#determine what level of standings to check
#refer to https://github.com/eve-val/evelink/blob/master/evelink/parsing/contact_list.py#L43
standing_level = 'alliance'
if settings.IS_CORP:
standing_level = 'corp'
# Create the corps in the standings
corp_standings = EveApiManager.get_corp_standings()
if corp_standings:
for standing_id in EveApiManager.get_corp_standings()[standing_level]:
if int(corp_standings[standing_level][standing_id]['standing']) >= settings.BLUE_STANDING:
if EveApiManager.check_if_id_is_character(standing_id):
pass
elif EveApiManager.check_if_id_is_corp(standing_id):
corpinfo = EveApiManager.get_corporation_information(standing_id)
if not EveManager.check_if_corporation_exists_by_id(standing_id):
EveManager.create_corporation_info(corpinfo['id'], corpinfo['name'], corpinfo['ticker'],
corpinfo['members']['current'], True, None)
else:
# Alliance id create corps
blue_alliance_info = EveApiManager.get_alliance_information(standing_id)
if not EveManager.check_if_alliance_exists_by_id(standing_id):
EveManager.create_alliance_info(standing_id, blue_alliance_info['name'],
blue_alliance_info['ticker'],
blue_alliance_info['executor_id'],
blue_alliance_info['member_count'], True)
blue_alliance = EveManager.get_alliance_info_by_id(standing_id)
for blue_alliance_corp in blue_alliance_info['member_corps']:
blue_info = EveApiManager.get_corporation_information(blue_alliance_corp)
if not EveManager.check_if_corporation_exists_by_id(blue_info['id']):
EveManager.create_corporation_info(blue_info['id'], blue_info['name'],
blue_info['ticker'],
blue_info['members']['current'], True, blue_alliance)
# Update all allinace info's
for all_alliance_info in EveManager.get_all_alliance_info():
if EveApiManager.check_if_alliance_exists(all_alliance_info.alliance_id):
all_alliance_api_info = EveApiManager.get_alliance_information(all_alliance_info.alliance_id)
if (not settings.IS_CORP and all_alliance_info.alliance_id == settings.ALLIANCE_ID):
EveManager.update_alliance_info(all_alliance_api_info['id'], all_alliance_api_info['executor_id'],
all_alliance_api_info['member_count'], False)
elif standing_level in corp_standings:
if int(all_alliance_info.alliance_id) in corp_standings[standing_level]:
if int(corp_standings[standing_level][int(all_alliance_info.alliance_id)][
'standing']) >= settings.BLUE_STANDING:
EveManager.update_alliance_info(all_alliance_api_info['id'],
all_alliance_api_info['executor_id'],
all_alliance_api_info['member_count'], True)
else:
EveManager.update_alliance_info(all_alliance_api_info['id'],
all_alliance_api_info['executor_id'],
all_alliance_api_info['member_count'], False)
else:
EveManager.update_alliance_info(all_alliance_api_info['id'],
all_alliance_api_info['executor_id'],
all_alliance_api_info['member_count'], False)
else:
EveManager.update_alliance_info(all_alliance_api_info['id'],
all_alliance_api_info['executor_id'],
all_alliance_api_info['member_count'], False)
else:
#.........这里部分代码省略.........
示例3: run_corp_update
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import get_corp_standings [as 别名]
def run_corp_update():
if EveApiManager.check_if_api_server_online() is False:
logger.warn("Aborted updating corp and alliance models: API server unreachable")
return
standing_level = 'alliance'
try:
# get corp info for owning corp if required
ownercorpinfo = {}
if settings.IS_CORP:
standing_level = 'corp'
logger.debug("Getting information for owning corp with id %s" % settings.CORP_ID)
ownercorpinfo = EveApiManager.get_corporation_information(settings.CORP_ID)
if not ownercorpinfo:
logger.error("Failed to retrieve corp info for owning corp id %s - bad corp id?" % settings.CORP_ID)
return
# check if we need to update an alliance model
alliance_id = ''
if ownercorpinfo and ownercorpinfo['alliance']['id']:
alliance_id = ownercorpinfo['alliance']['id']
elif settings.IS_CORP is False:
alliance_id = settings.ALLIANCE_ID
# get and create alliance info for owning alliance if required
alliance = None
if alliance_id:
logger.debug("Getting information for owning alliance with id %s" % alliance_id)
ownerallianceinfo = EveApiManager.get_alliance_information(alliance_id)
if not ownerallianceinfo:
logger.error("Failed to retrieve corp info for owning alliance id %s - bad alliance id?" % alliance_id)
return
if EveAllianceInfo.objects.filter(alliance_id=ownerallianceinfo['id']).exists():
logger.debug("Updating existing owner alliance model with id %s" % alliance_id)
EveManager.update_alliance_info(ownerallianceinfo['id'], ownerallianceinfo['executor_id'], ownerallianceinfo['member_count'], False)
else:
populate_alliance(alliance_id)
alliance = EveAllianceInfo.objects.get(alliance_id=alliance_id)
# create corp info for owning corp if required
if ownercorpinfo:
if EveCorporationInfo.objects.filter(corporation_id=ownercorpinfo['id']).exists():
logger.debug("Updating existing owner corp model with id %s" % ownercorpinfo['id'])
EveManager.update_corporation_info(ownercorpinfo['id'], ownercorpinfo['members']['current'], alliance, False)
else:
logger.info("Creating model for owning corp with id %s" % ownercorpinfo['id'])
EveManager.create_corporation_info(ownercorpinfo['id'], ownercorpinfo['name'], ownercorpinfo['ticker'],
ownercorpinfo['members']['current'], False, alliance)
# validate and create corp models for member corps of owning alliance
if alliance:
current_corps = EveCorporationInfo.objects.filter(alliance=alliance)
for corp in current_corps:
if corp.corporation_id in ownerallianceinfo['member_corps'] is False:
logger.info("Corp %s is no longer in owning alliance %s - updating model." % (corp, alliance))
corp.alliance = None
corp.save()
for member_corp in ownerallianceinfo['member_corps']:
if EveCorporationInfo.objects.filter(corporation_id=member_corp).exists():
corp = EveCorporationInfo.objects.get(corporation_id=member_corp)
if corp.alliance == alliance is not True:
logger.info("Associating corp %s with owning alliance %s" % (corp, alliance))
corp.alliance = alliance
corp.save()
else:
corpinfo = EveApiManager.get_corporation_information(member_corp)
logger.info("Creating model for owning alliance member corp with id %s" % corpinfo['id'])
EveManager.create_corporation_info(corpinfo['id'], corpinfo['name'], corpinfo['ticker'],
corpinfo['members']['current'], False, alliance)
# update existing corp models
for corp in EveCorporationInfo.objects.all():
update_corp.delay(corp.corporation_id)
# update existing alliance models
for alliance in EveAllianceInfo.objects.all():
update_alliance.delay(alliance.alliance_id)
# create standings
standings = EveApiManager.get_corp_standings()
if standings:
standings = standings[standing_level]
for standing in standings:
if int(standings[standing]['standing']) >= settings.BLUE_STANDING:
logger.debug("Standing %s meets threshold" % standing)
if EveApiManager.check_if_id_is_alliance(standing):
logger.debug("Standing %s is an alliance" % standing)
if EveAllianceInfo.objects.filter(alliance_id=standing).exists():
alliance = EveAllianceInfo.objects.get(alliance_id=standing)
if alliance.is_blue is not True:
logger.info("Updating alliance %s as blue" % alliance)
alliance.is_blue = True
alliance.save()
else:
populate_alliance(standing, blue=True)
elif EveApiManager.check_if_id_is_corp(standing):
logger.debug("Standing %s is a corp" % standing)
if EveCorporationInfo.objects.filter(corporation_id=standing).exists():
corp = EveCorporationInfo.objects.get(corporation_id=standing)
if corp.is_blue is not True:
logger.info("Updating corp %s as blue" % corp)
#.........这里部分代码省略.........
示例4: run_corp_update
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import get_corp_standings [as 别名]
def run_corp_update():
if not EveApiManager.check_if_api_server_online():
logger.warn("Aborted updating corp and alliance models: API server unreachable")
return
# generate member corps
for corp_id in settings.STR_CORP_IDS + settings.STR_BLUE_CORP_IDS:
is_blue = True if corp_id in settings.STR_BLUE_CORP_IDS else False
try:
if EveCorporationInfo.objects.filter(corporation_id=corp_id).exists():
update_corp.apply(args=(corp_id,), kwargs={'is_blue': is_blue})
else:
EveManager.create_corporation(corp_id, is_blue=is_blue)
except ObjectNotFound:
logger.warn('Bad corp ID in settings: %s' % corp_id)
# generate member alliances
for alliance_id in settings.STR_ALLIANCE_IDS + settings.STR_BLUE_ALLIANCE_IDS:
is_blue = True if alliance_id in settings.STR_BLUE_ALLIANCE_IDS else False
try:
if EveAllianceInfo.objects.filter(alliance_id=alliance_id).exists():
logger.debug("Updating existing owner alliance model with id %s" % alliance_id)
update_alliance(alliance_id, is_blue=is_blue)
else:
EveManager.create_alliance(alliance_id, is_blue=is_blue)
EveManager.populate_alliance(alliance_id)
except ObjectNotFound:
logger.warn('Bad alliance ID in settings: %s' % alliance_id)
# update existing corp models
for corp in EveCorporationInfo.objects.exclude(
corporation_id__in=settings.STR_CORP_IDS + settings.STR_BLUE_CORP_IDS):
update_corp.delay(corp.corporation_id)
# update existing alliance models
for alliance in EveAllianceInfo.objects.exclude(
alliance_id__in=settings.STR_ALLIANCE_IDS + settings.STR_BLUE_ALLIANCE_IDS):
update_alliance.delay(alliance.alliance_id)
try:
# create standings
standings = EveApiManager.get_corp_standings()
if standings:
standings = standings[settings.STANDING_LEVEL]
for standing in standings:
if float(standings[standing]['standing']) >= settings.BLUE_STANDING:
logger.debug("Standing %s meets threshold" % standing)
if EveApiManager.check_if_id_is_alliance(standing):
logger.debug("Standing %s is an alliance" % standing)
if EveAllianceInfo.objects.filter(alliance_id=standing).exists():
alliance = EveAllianceInfo.objects.get(alliance_id=standing)
if alliance.is_blue is not True:
logger.info("Updating alliance %s as blue" % alliance)
alliance.is_blue = True
alliance.save()
else:
EveManager.create_alliance(standing, is_blue=True)
elif EveApiManager.check_if_id_is_corp(standing):
logger.debug("Standing %s is a corp" % standing)
if EveCorporationInfo.objects.filter(corporation_id=standing).exists():
corp = EveCorporationInfo.objects.get(corporation_id=standing)
if corp.is_blue is not True:
logger.info("Updating corp %s as blue" % corp)
corp.is_blue = True
corp.save()
else:
logger.info("Creating model for blue corp with id %s" % standing)
EveManager.create_corporation(standing, is_blue=True)
# update alliance standings
for alliance in EveAllianceInfo.objects.filter(is_blue=True):
if int(alliance.alliance_id) in standings:
if float(standings[int(alliance.alliance_id)]['standing']) < float(settings.BLUE_STANDING):
logger.info("Alliance %s no longer meets minimum blue standing threshold" % alliance)
alliance.is_blue = False
alliance.save()
elif alliance.alliance_id not in settings.STR_BLUE_ALLIANCE_IDS:
logger.info("Alliance %s no longer in standings" % alliance)
alliance.is_blue = False
alliance.save()
# update corp standings
for corp in EveCorporationInfo.objects.filter(is_blue=True):
if int(corp.corporation_id) in standings:
if float(standings[int(corp.corporation_id)]['standing']) < float(settings.BLUE_STANDING):
logger.info("Corp %s no longer meets minimum blue standing threshold" % corp)
corp.is_blue = False
corp.save()
elif corp.corporation_id not in settings.STR_BLUE_CORP_IDS:
if corp.alliance:
if not corp.alliance.is_blue:
logger.info("Corp %s and its alliance %s are no longer blue" % (corp, corp.alliance))
corp.is_blue = False
corp.save()
else:
logger.info("Corp %s is no longer blue" % corp)
corp.is_blue = False
corp.save()
except evelink.api.APIError as e:
logger.error("Model update failed with error code %s" % e.code)
#.........这里部分代码省略.........