本文整理汇总了Python中services.managers.eve_api_manager.EveApiManager.check_api_is_full方法的典型用法代码示例。如果您正苦于以下问题:Python EveApiManager.check_api_is_full方法的具体用法?Python EveApiManager.check_api_is_full怎么用?Python EveApiManager.check_api_is_full使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类services.managers.eve_api_manager.EveApiManager
的用法示例。
在下文中一共展示了EveApiManager.check_api_is_full方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def clean(self):
if EveManager.check_if_api_key_pair_exist(self.cleaned_data['api_id']):
raise forms.ValidationError(u'API key already exist')
check_blue = False
try:
check_blue = self.cleaned_data['is_blue']
except:
pass
if check_blue:
if settings.BLUE_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
raise forms.ValidationError(u'API not of type account')
if not EveApiManager.check_blue_api_is_full(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
raise forms.ValidationError(u'API supplied is too restricted. Minimum access mask is ' + str(settings.BLUE_API_MASK))
else:
if settings.MEMBER_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
raise forms.ValidationError(u'API not of type account')
if not EveApiManager.check_api_is_full(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
raise forms.ValidationError(u'API supplied is too restricted. Minimum access mask is ' + str(settings.MEMBER_API_MASK))
return self.cleaned_data
示例2: refresh_api
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def refresh_api(api_key_pair):
logger.debug("Running update on api key %s" % api_key_pair.api_id)
user = api_key_pair.user
if EveApiManager.api_key_is_valid(api_key_pair.api_id, api_key_pair.api_key):
#check to ensure API key meets min spec
logger.info("Determined api key %s is still active." % api_key_pair.api_id)
still_valid = True
state = determine_membership_by_user(user)
if state == "BLUE":
if settings.BLUE_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for blue user %s is no longer type account as requred." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s is not account-wide as required." % api_key_pair.api_id, level="danger")
if not EveApiManager.check_blue_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for blue user %s no longer meets minimum access mask as required." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s does not meet access mask requirements." % api_key_pair.api_id, level="danger")
elif state == "MEMBER":
if settings.MEMBER_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for user %s is no longer type account as required." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s is not account-wide as required." % api_key_pair.api_id, level="danger")
if not EveApiManager.check_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for user %s no longer meets minimum access mask as required." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s does not meet access mask requirements." % api_key_pair.api_id, level="danger")
if not still_valid:
logger.debug("API key %s has failed validation; it and its characters will be deleted." % api_key_pair.api_id)
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
notify(user, "API Key Deleted", message="Your API key ID %s has failed validation. It and its associated characters have been deleted." % api_key_pair.api_id, level="danger")
else:
logger.info("Determined api key %s still meets requirements." % api_key_pair.api_id)
# Update characters
characters = EveApiManager.get_characters_from_api(api_key_pair.api_id, api_key_pair.api_key)
EveManager.update_characters_from_list(characters)
new_character = False
for char in characters.result:
# Ensure we have a model for all characters on key
if not EveManager.check_if_character_exist(characters.result[char]['name']):
new_character = True
logger.debug("API key %s has a new character on the account: %s" % (api_key_pair.api_id, characters.result[char]['name']))
if new_character:
logger.debug("Creating new character %s from api key %s" % (characters.result[char]['name'], api_key_pair.api_id))
EveManager.create_characters_from_list(characters, user, api_key_pair.api_id)
current_chars = EveCharacter.objects.filter(api_id=api_key_pair.api_id)
for c in current_chars:
if not int(c.character_id) in characters.result:
logger.info("Character %s no longer found on API ID %s" % (c, api_key_pair.api_id))
c.delete()
else:
logger.debug("API key %s is no longer valid; it and its characters will be deleted." % api_key_pair.api_id)
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
notify(user, "API Key Deleted", message="Your API key ID %s is invalid. It and its associated characters have been deleted." % api_key_pair.api_id, level="danger")
示例3: clean
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def clean(self):
if EveManager.check_if_api_key_pair_exist(self.cleaned_data['api_id']):
raise forms.ValidationError(u'API key already exist')
check_blue = False
try:
check_blue = self.cleaned_data['is_blue']
except:
pass
if not check_blue:
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
raise forms.ValidationError(u'API not of type account')
if not EveApiManager.check_api_is_full(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
raise forms.ValidationError(u'API supplied is not a full api key')
return self.cleaned_data
示例4: clean
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def clean(self):
if EveManager.check_if_api_key_pair_exist(self.cleaned_data['api_id']):
logger.debug("UpdateKeyForm failed cleaning as API id %s already exists." % self.cleaned_data['api_id'])
raise forms.ValidationError(u'API key already exist')
check_blue = False
try:
check_blue = self.cleaned_data['is_blue']
except:
pass
if check_blue:
if settings.BLUE_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
logger.debug("UpdateKeyForm failed cleaning as API id %s does not meet blue api key account requirement." % self.cleaned_data['api_id'])
raise forms.ValidationError(u'API not of type account')
if not EveApiManager.check_blue_api_is_full(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
logger.debug("UpdateKeyForm failed cleaning as API id %s does not meet minimum blue api access mask requirement." % self.cleaned_data['api_id'])
raise forms.ValidationError(u'API supplied is too restricted. Minimum access mask is ' + str(settings.BLUE_API_MASK))
else:
if settings.MEMBER_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
logger.debug("UpdateKeyForm failed cleaning as API id %s does not meet member api key account requirement." % self.cleaned_data['api_id'])
raise forms.ValidationError(u'API not of type account')
if not EveApiManager.check_api_is_full(self.cleaned_data['api_id'],
self.cleaned_data['api_key']):
logger.debug("UpdateKeyForm failed cleaning as API id %s does not meet minimum member api access mask requirement." % self.cleaned_data['api_id'])
raise forms.ValidationError(u'API supplied is too restricted. Minimum access mask is ' + str(settings.MEMBER_API_MASK))
return self.cleaned_data
示例5: run_api_refresh
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def run_api_refresh():
users = User.objects.all()
logger.debug("Running api refresh on %s users." % len(users))
for user in users:
# Check if the api server is online
logger.debug("Running api refresh for user %s" % user)
if EveApiManager.check_if_api_server_online():
api_key_pairs = EveManager.get_api_key_pairs(user.id)
logger.debug("User %s has api key pairs %s" % (user, api_key_pairs))
if api_key_pairs:
authserviceinfo, c = AuthServicesInfo.objects.get_or_create(user=user)
logger.debug("User %s has api keys. Proceeding to refresh." % user)
for api_key_pair in api_key_pairs:
logger.debug("Running update on api key %s" % api_key_pair.api_id)
if EveApiManager.api_key_is_valid(api_key_pair.api_id, api_key_pair.api_key):
# check to ensure API key meets min spec
logger.info("Determined api key %s is still active." % api_key_pair.api_id)
still_valid = True
state = determine_membership_by_user(user)
if state == "BLUE":
if settings.BLUE_API_ACCOUNT:
type = EveApiManager.check_api_is_type_account(
api_key_pair.api_id, api_key_pair.api_key
)
if type == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info(
"API key %s incurred an error checking if type account. Error count is now %s"
% (api_key_pair.api_id, api_key_pair.error_count)
)
still_valid = None
elif type == False:
logger.info(
"Determined api key %s for blue user %s is no longer type account as requred."
% (api_key_pair.api_id, user)
)
still_valid = False
full = EveApiManager.check_blue_api_is_full(api_key_pair.api_id, api_key_pair.api_key)
if full == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info(
"API key %s incurred an error checking if meets mask requirements. Error count is now %s"
% (api_key_pair.api_id, api_key_pair.error_count)
)
still_valid = None
elif full == False:
logger.info(
"Determined api key %s for blue user %s no longer meets minimum access mask as required."
% (api_key_pair.api_id, user)
)
still_valid = False
elif state == "MEMBER":
if settings.MEMBER_API_ACCOUNT:
type = EveApiManager.check_api_is_type_account(
api_key_pair.api_id, api_key_pair.api_key
)
if type == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info(
"API key %s incurred an error checking if type account. Error count is now %s"
% (api_key_pair.api_id, api_key_pair.error_count)
)
still_valid = None
elif type == False:
logger.info(
"Determined api key %s for user %s is no longer type account as required."
% (api_key_pair.api_id, user)
)
still_valid = False
full = EveApiManager.check_api_is_full(api_key_pair.api_id, api_key_pair.api_key)
if full == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info(
"API key %s incurred an error checking if meets mask requirements. Error count is now %s"
% (api_key_pair.api_id, api_key_pair.error_count)
)
still_valid = None
elif full == False:
logger.info(
"Determined api key %s for user %s no longer meets minimum access mask as required."
% (api_key_pair.api_id, user)
)
still_valid = False
if still_valid == None:
if api_key_pair.error_count >= 3:
logger.info(
"API key %s has incurred 3 or more errors. Assuming invalid." % api_key_pair.api_id
)
still_valid = False
if still_valid == False:
logger.debug(
"API key %s has failed validation; it and its characters will be deleted."
% api_key_pair.api_id
)
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
#.........这里部分代码省略.........
示例6: run_api_refresh
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def run_api_refresh():
users = User.objects.all()
logger.debug("Running api refresh on %s users." % len(users))
for user in users:
# Check if the api server is online
logger.debug("Running api refresh for user %s" % user)
if EveApiManager.check_if_api_server_online():
api_key_pairs = EveManager.get_api_key_pairs(user.id)
logger.debug("User %s has api key pairs %s" % (user, api_key_pairs))
if api_key_pairs:
valid_key = False
authserviceinfo = AuthServicesInfo.objects.get(user=user)
logger.debug("User %s has api keys. Proceeding to refresh." % user)
if authserviceinfo.main_char_id:
if authserviceinfo.main_char_id != "":
#preserve old corp ID for corp change test on members
oldcorp_id = 0
if EveManager.get_character_by_id(authserviceinfo.main_char_id):
oldcorp_id = EveCharacter.objects.get(character_id=authserviceinfo.main_char_id).corporation_id
logger.debug("Determined user %s current main corp id %s" % (user, oldcorp_id))
for api_key_pair in api_key_pairs:
logger.debug("Running update on api key %s" % api_key_pair.api_id)
if EveApiManager.api_key_is_valid(api_key_pair.api_id, api_key_pair.api_key):
#check to ensure API key meets min spec
logger.info("Determined api key %s is still active." % api_key_pair.api_id)
still_valid = True
if authserviceinfo.is_blue:
if settings.BLUE_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for blue user %s is no longer type account as requred." % (api_key_pair.api_id, user))
still_valid = False
if not EveApiManager.check_blue_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for blue user %s no longer meets minimum access mask as required." % (api_key_pair.api_id, user))
still_valid = False
else:
if settings.MEMBER_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for user %s is no longer type account as required." % (api_key_pair.api_id, user))
still_valid = False
if not EveApiManager.check_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
logger.info("Determined api key %s for user %s no longer meets minimum access mask as required." % (api_key_pair.api_id, user))
still_valid = False
if still_valid is not True:
logger.debug("API key %s has failed validation; it and its characters will be deleted." % api_key_pair.api_id)
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
else:
logger.info("Determined api key %s still meets requirements." % api_key_pair.api_id)
# Update characters
characters = EveApiManager.get_characters_from_api(api_key_pair.api_id,
api_key_pair.api_key)
EveManager.update_characters_from_list(characters)
new_character = False
for char in characters.result:
# Ensure we have a model for all characters on key
if not EveManager.check_if_character_exist(characters.result[char]['name']):
new_character = True
logger.debug("API key %s has a new character on the account: %s" % (api_key_pair.api_id, characters.result[char]['name']))
if new_character:
logger.debug("Creating new character %s from api key %s" % (characters.result[char]['name'], api_key_pair.api_id))
EveManager.create_characters_from_list(characters, user, api_key_pair.api_key)
valid_key = True
else:
logger.debug("API key %s is no longer active; it and its characters will be deleted." % api_key_pair.api_id)
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
if valid_key:
# Check our main character
character = EveManager.get_character_by_id(authserviceinfo.main_char_id)
logger.debug("User %s has valid api key, checking main character %s" % (user, character))
if character is not None and EveManager.check_if_corporation_exists_by_id(character.corporation_id):
corp = EveManager.get_corporation_info_by_id(character.corporation_id)
main_corp_id = EveManager.get_charater_corporation_id_by_id(authserviceinfo.main_char_id)
main_alliance_id = EveManager.get_charater_alliance_id_by_id(authserviceinfo.main_char_id)
logger.debug("User %s main character %s has corp %s with alliance id %s" % (user, character, corp, main_alliance_id))
if (settings.IS_CORP and main_corp_id == settings.CORP_ID) or (not settings.IS_CORP and main_alliance_id == settings.ALLIANCE_ID):
logger.debug("User %s corp or alliance meets membership requirements. Ensuring has required permissions and groups." % user)
if not check_if_user_has_permission(user, "member"):
#transition from none or blue to member
if check_if_user_has_permission(user, "blue_member"):
#strip blue status
logger.debug("Removing user %s blue permission and group to prepare for member transition." % user)
remove_member_permission(user, "blue_member")
remove_user_from_group(user, settings.DEFAULT_BLUE_GROUP)
AuthServicesInfoManager.update_is_blue(False, user)
#add to auth group
add_member_permission(user, "member")
add_user_to_group(user, settings.DEFAULT_AUTH_GROUP)
#add to required corp group
add_user_to_group(user, generate_corp_group_name(character.corporation_name))
logger.info("User %s transitioned to full member during api refresh." % user)
elif corp.corporation_id != oldcorp_id:
#changed corps, both corps auth'd, need to change group assignment
logger.debug("User %s main character changed corp from id %s to %s, both meet membership requirements. Updating corp group." % (user, oldcorp_id, corp.corporation_id))
oldcorp = EveCorporationInfo.objects.get(corporation_id=oldcorp_id)
remove_user_from_group(user, generate_corp_group_name(oldcorp.corporation_name))
add_user_to_group(user, generate_corp_group_name(character.corporation_name))
#reset services to force new mumble names and group assignments
#.........这里部分代码省略.........
示例7: refresh_api
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def refresh_api(api_key_pair):
logger.debug("Running update on api key %s" % api_key_pair.api_id)
user = api_key_pair.user
if EveApiManager.api_key_is_valid(api_key_pair.api_id, api_key_pair.api_key):
#check to ensure API key meets min spec
logger.info("Determined api key %s is still active." % api_key_pair.api_id)
still_valid = True
state = determine_membership_by_user(user)
if state == "BLUE":
if settings.BLUE_API_ACCOUNT:
type = EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key)
if type == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info("API key %s incurred an error checking if type account. Error count is now %s" % (api_key_pair.api_id, api_key_pair.error_count))
still_valid = None
elif type == False:
logger.info("Determined api key %s for blue user %s is no longer type account as requred." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s is not account-wide as required." % api_key_pair.api_id, level="danger")
full = EveApiManager.check_blue_api_is_full(api_key_pair.api_id, api_key_pair.api_key)
if full == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info("API key %s incurred an error checking if meets mask requirements. Error count is now %s" % (api_key_pair.api_id, api_key_pair.error_count))
still_valid = None
elif full == False:
logger.info("Determined api key %s for blue user %s no longer meets minimum access mask as required." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s does not meet access mask requirements." % api_key_pair.api_id, level="danger")
elif state == "MEMBER":
if settings.MEMBER_API_ACCOUNT:
type = EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key)
if type == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info("API key %s incurred an error checking if type account. Error count is now %s" % (api_key_pair.api_id, api_key_pair.error_count))
still_valid = None
elif type == False:
logger.info("Determined api key %s for user %s is no longer type account as required." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s is not account-wide as required." % api_key_pair.api_id, level="danger")
full = EveApiManager.check_api_is_full(api_key_pair.api_id, api_key_pair.api_key)
if full == None:
api_key_pair.error_count += 1
api_key_pair.save()
logger.info("API key %s incurred an error checking if meets mask requirements. Error count is now %s" % (api_key_pair.api_id, api_key_pair.error_count))
still_valid = None
elif full == False:
logger.info("Determined api key %s for user %s no longer meets minimum access mask as required." % (api_key_pair.api_id, user))
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s does not meet access mask requirements." % api_key_pair.api_id, level="danger")
if still_valid == None:
if api_key_pair.error_count >= 3:
logger.info("API key %s has incurred 3 or more errors. Assuming invalid." % api_key_pair.api_id)
still_valid = False
notify(user, "API Failed Validation", message="Your API key ID %s has accumulated too many errors during refresh and is assumed to be invalid." % api_key_pair.api_id, level="danger")
if still_valid == False:
logger.debug("API key %s has failed validation; it and its characters will be deleted." % api_key_pair.api_id)
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
notify(user, "API Key Deleted", message="Your API key ID %s has failed validation. It and its associated characters have been deleted." % api_key_pair.api_id, level="danger")
elif still_valid == True:
if api_key_pair.error_count != 0:
logger.info("Clearing error count for api %s as it passed validation" % api_key_pair.api_id)
api_key_pair.error_count = 0
api_key_pair.save()
logger.info("Determined api key %s still meets requirements." % api_key_pair.api_id)
# Update characters
characters = EveApiManager.get_characters_from_api(api_key_pair.api_id, api_key_pair.api_key)
EveManager.update_characters_from_list(characters)
new_character = False
for char in characters.result:
# Ensure we have a model for all characters on key
if not EveManager.check_if_character_exist(characters.result[char]['name']):
new_character = True
logger.debug("API key %s has a new character on the account: %s" % (api_key_pair.api_id, characters.result[char]['name']))
if new_character:
logger.debug("Creating new character %s from api key %s" % (characters.result[char]['name'], api_key_pair.api_id))
EveManager.create_characters_from_list(characters, user, api_key_pair.api_key)
else:
logger.debug("API key %s is no longer valid; it and its characters will be deleted." % api_key_pair.api_id)
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
notify(user, "API Key Deleted", message="Your API key ID %s is invalid. It and its associated characters have been deleted." % api_key_pair.api_id, level="danger")
示例8: run_api_refresh
# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import check_api_is_full [as 别名]
def run_api_refresh():
users = User.objects.all()
for user in users:
# Check if the api server is online
if EveApiManager.check_if_api_server_online():
api_key_pairs = EveManager.get_api_key_pairs(user.id)
if api_key_pairs:
valid_key = False
authserviceinfo = AuthServicesInfo.objects.get(user=user)
print 'Running update on user: ' + user.username
if authserviceinfo.main_char_id:
if authserviceinfo.main_char_id != "":
#preserve old corp ID for corp change test on members
oldcorp_id = 0
if EveManager.get_character_by_id(authserviceinfo.main_char_id):
oldcorp_id = EveCharacter.objects.get(character_id=authserviceinfo.main_char_id).corporation_id
for api_key_pair in api_key_pairs:
print 'Running on ' + api_key_pair.api_id + ':' + api_key_pair.api_key
if EveApiManager.api_key_is_valid(api_key_pair.api_id, api_key_pair.api_key):
#check to ensure API key meets min spec
still_valid = True
if authserviceinfo.is_blue:
if settings.BLUE_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
still_valid = False
if not EveApiManager.check_blue_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
still_valid = False
else:
if settings.MEMBER_API_ACCOUNT:
if not EveApiManager.check_api_is_type_account(api_key_pair.api_id, api_key_pair.api_key):
still_valid = False
if not EveApiManager.check_api_is_full(api_key_pair.api_id, api_key_pair.api_key):
still_valid = False
if still_valid is not True:
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
else:
# Update characters
characters = EveApiManager.get_characters_from_api(api_key_pair.api_id,
api_key_pair.api_key)
EveManager.update_characters_from_list(characters)
new_character = False
for char in characters.result:
# Ensure we have a model for all characters on key
if not EveManager.check_if_character_exist(characters.result[char]['name']):
new_character = True
if new_character:
EveManager.create_characters_from_list(characters, user, api_key_pair.api_key)
valid_key = True
else:
EveManager.delete_characters_by_api_id(api_key_pair.api_id, user.id)
EveManager.delete_api_key_pair(api_key_pair.api_id, user.id)
if valid_key:
# Check our main character
character = EveManager.get_character_by_id(authserviceinfo.main_char_id)
if character is not None and EveManager.check_if_corporation_exists_by_id(character.corporation_id):
corp = EveManager.get_corporation_info_by_id(character.corporation_id)
main_corp_id = EveManager.get_charater_corporation_id_by_id(authserviceinfo.main_char_id)
main_alliance_id = EveManager.get_charater_alliance_id_by_id(authserviceinfo.main_char_id)
if (settings.IS_CORP and main_corp_id == settings.CORP_ID) or (not settings.IS_CORP and main_alliance_id == settings.ALLIANCE_ID):
if not check_if_user_has_permission(user, "member"):
#transition from none or blue to member
if check_if_user_has_permission(user, "blue_member"):
#strip blue status
remove_member_permission(user, "blue_member")
remove_user_from_group(user, settings.DEFAULT_BLUE_GROUP)
AuthServicesInfoManager.update_is_blue(False, user)
#add to auth group
add_member_permission(user, "member")
add_user_to_group(user, settings.DEFAULT_AUTH_GROUP)
#add to required corp group
add_user_to_group(user, generate_corp_group_name(character.corporation_name))
elif corp.corporation_id != oldcorp_id:
#changed corps, both corps auth'd, need to change group assignment
oldcorp = EveCorporationInfo.objects.get(corporation_id=oldcorp_id)
remove_user_from_group(user, generate_corp_group_name(oldcorp.corporation_name))
add_user_to_group(user, generate_corp_group_name(character.corporation_name))
#reset services to force new mumble names and group assignments
deactivate_services(user)
elif corp is not None:
if corp.is_blue is not True:
if check_if_user_has_permission(user, "member"):
#transition from member to nobody
disable_alliance_member(user, authserviceinfo.main_char_id)
elif check_if_user_has_permission(user, "blue_member"):
#transition from blue to nobody
disable_blue_member(user)
else:
#stay nobody, make sure no services
deactivate_services(user)
else:
if check_if_user_has_permission(user, "member"):
#remove auth member to prepare for member to blue transition
disable_alliance_member(user, authserviceinfo.main_char_id)
if not check_if_user_has_permission(user, "blue_member"):
#perform nobody to blue transition
add_member_permission(user, "blue_member")
#.........这里部分代码省略.........