本文整理汇总了Python中services.managers.eve_api_manager.EveApiManager.check_if_corp_exists方法的典型用法代码示例。如果您正苦于以下问题:Python EveApiManager.check_if_corp_exists方法的具体用法?Python EveApiManager.check_if_corp_exists怎么用?Python EveApiManager.check_if_corp_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类services.managers.eve_api_manager.EveApiManager
的用法示例。
在下文中一共展示了EveApiManager.check_if_corp_exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_corp
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_if_corp_exists [as 别名]
def update_corp(id):
corp = EveCorporationInfo.objects.get(corporation_id=id)
logger.debug("Updating corp %s" % corp)
corpinfo = EveApiManager.get_corporation_information(corp.corporation_id)
if corpinfo:
alliance = None
if EveAllianceInfo.objects.filter(alliance_id=corpinfo['alliance']['id']).exists():
alliance = EveAllianceInfo.objects.get(alliance_id=corpinfo['alliance']['id'])
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance, corp.is_blue)
elif EveApiManager.check_if_corp_exists(corp.corporation_id) is False:
logger.info("Corp %s has closed. Deleting model" % corp)
corp.delete()
示例2: run_corp_update
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_if_corp_exists [as 别名]
#.........这里部分代码省略.........
"Alliance %s does not meet blue standing threshold. Updating as non-blue."
% all_alliance_info
)
EveManager.update_alliance_info(
all_alliance_api_info["id"],
all_alliance_api_info["executor_id"],
all_alliance_api_info["member_count"],
False,
)
else:
logger.debug("Alliance %s not in standings. Updating as non-blue." % all_alliance_info)
EveManager.update_alliance_info(
all_alliance_api_info["id"],
all_alliance_api_info["executor_id"],
all_alliance_api_info["member_count"],
False,
)
else:
logger.debug("No standings found. Updating alliance %s as non-blue." % all_alliance_info)
EveManager.update_alliance_info(
all_alliance_api_info["id"],
all_alliance_api_info["executor_id"],
all_alliance_api_info["member_count"],
False,
)
else:
logger.info("Alliance %s has closed. Deleting model." % all_alliance_info)
# alliance no longer exists
all_alliance_info.delete()
# Update corp infos
for all_corp_info in EveManager.get_all_corporation_info():
logger.debug("Validating corp model %s" % all_corp_info)
if EveApiManager.check_if_corp_exists(all_corp_info.corporation_id):
alliance = None
corpinfo = EveApiManager.get_corporation_information(all_corp_info.corporation_id)
if corpinfo["alliance"]["id"] is not None:
alliance = EveManager.get_alliance_info_by_id(corpinfo["alliance"]["id"])
logger.debug("Got corpinfo %s and allianceinfo %s" % (corpinfo, alliance))
if settings.IS_CORP and all_corp_info.corporation_id == settings.CORP_ID:
logger.debug("Corp %s is owning corp. Updating." % all_corp_info)
EveManager.update_corporation_info(corpinfo["id"], corpinfo["members"]["current"], None, False)
elif int(all_corp_info.corporation_id) in corp_standings[standing_level]:
if (
int(corp_standings[standing_level][int(all_corp_info.corporation_id)]["standing"])
>= settings.BLUE_STANDING
):
logger.debug("Corp %s is blue. Updating." % all_corp_info)
EveManager.update_corporation_info(
corpinfo["id"], corpinfo["members"]["current"], None, True
)
else:
logger.debug(
"Corp %s does not meet blue standing threshold. Updating as non-blue." % all_corp_info
)
EveManager.update_corporation_info(
corpinfo["id"], corpinfo["members"]["current"], None, False
)
elif alliance is not None and all_corp_info.alliance is not None:
logger.debug(
"Corp %s not in standings - checking alliance with model %s" % (all_corp_info, alliance)
)
if (not settings.IS_CORP) and (all_corp_info.alliance.alliance_id == settings.ALLIANCE_ID):
logger.debug("Corp %s is member of owning alliance. Updating." % all_corp_info)
EveManager.update_corporation_info(
示例3: run_corp_update
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_if_corp_exists [as 别名]
#.........这里部分代码省略.........
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:
#alliance no longer exists
all_alliance_info.delete()
# Update corp infos
for all_corp_info in EveManager.get_all_corporation_info():
if EveApiManager.check_if_corp_exists(all_corp_info.corporation_id):
alliance = None
corpinfo = EveApiManager.get_corporation_information(all_corp_info.corporation_id)
if corpinfo['alliance']['id'] is not None:
alliance = EveManager.get_alliance_info_by_id(corpinfo['alliance']['id'])
if alliance is not None and all_corp_info.alliance is not None:
if (not settings.IS_CORP) and (all_corp_info.alliance.alliance_id == settings.ALLIANCE_ID):
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance, False)
elif int(alliance.alliance_id) in corp_standings[standing_level]:
if int(corp_standings[standing_level][int(alliance.alliance_id)][
'standing']) >= settings.BLUE_STANDING:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance,
True)
else:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance,
False)
else:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance,
False)
else:
if int(all_corp_info.corporation_id) in corp_standings[standing_level]:
if int(corp_standings[standing_level][int(all_corp_info.corporation_id)][
'standing']) >= settings.BLUE_STANDING:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], None, True)
else:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], None, False)
else:
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], None, False)
else:
#corp has closed
all_corp_info.delete()
# Remove irrelevent corp and alliance models
# Check the corps
for all_corp_info in EveManager.get_all_corporation_info():
if settings.IS_CORP:
if all_corp_info.corporation_id != settings.CORP_ID:
if not all_corp_info.is_blue:
all_corp_info.delete()
else:
if all_corp_info.alliance is not None:
if all_corp_info.alliance.alliance_id != settings.ALLIANCE_ID:
if not all_corp_info.is_blue:
all_corp_info.delete()
elif not all_corp_info.is_blue:
all_corp_info.delete()
# Check the alliances
for all_alliance_info in EveManager.get_all_alliance_info():
if settings.IS_CORP:
if all_alliance_info.is_blue is not True:
if ownercorpinfo['alliance']['id'] is not None:
if int(all_alliance_info.alliance_id) != ownercorpinfo['alliance']['id']:
all_alliance_info.delete()
else:
all_alliance_info.delete()
elif all_alliance_info.alliance_id != settings.ALLIANCE_ID:
if all_alliance_info.is_blue is not True:
all_alliance_info.delete()
示例4: run_corp_update
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_if_corp_exists [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'
# 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():
logger.debug("Updating corp %s" % corp)
corpinfo = EveApiManager.get_corporation_information(corp.corporation_id)
if corpinfo:
alliance = None
if EveAllianceInfo.objects.filter(alliance_id=corpinfo['alliance']['id']).exists():
alliance = EveAllianceInfo.objects.get(alliance_id=corpinfo['alliance']['id'])
EveManager.update_corporation_info(corpinfo['id'], corpinfo['members']['current'], alliance, corp.is_blue)
elif EveApiManager.check_if_corp_exists(corp.corporation_id) is False:
logger.info("Corp %s has closed. Deleting model" % corp)
corp.delete()
# update existing alliance models
for alliance in EveAllianceInfo.objects.all():
logger.debug("Updating alliance %s" % alliance)
allianceinfo = EveApiManager.get_alliance_information(alliance.alliance_id)
if allianceinfo:
EveManager.update_alliance_info(allianceinfo['id'], allianceinfo['executor_id'],
allianceinfo['member_count'], alliance.is_blue)
for corp in EveCorporationInfo.objects.filter(alliance=alliance):
if corp.corporation_id in allianceinfo['member_corps'] is False:
logger.info("Corp %s no longer in alliance %s" % (corp, alliance))
corp.alliance = None
corp.save()
populate_alliance(alliance.alliance_id, blue=alliance.is_blue)
elif EveApiManager.check_if_alliance_exists(alliance.alliance_id) is False:
logger.info("Alliance %s has closed. Deleting model" % alliance)
alliance.delete()
# create standings
#.........这里部分代码省略.........