当前位置: 首页>>代码示例>>Python>>正文


Python EveApiManager.validate_member_api方法代码示例

本文整理汇总了Python中services.managers.eve_api_manager.EveApiManager.validate_member_api方法的典型用法代码示例。如果您正苦于以下问题:Python EveApiManager.validate_member_api方法的具体用法?Python EveApiManager.validate_member_api怎么用?Python EveApiManager.validate_member_api使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在services.managers.eve_api_manager.EveApiManager的用法示例。


在下文中一共展示了EveApiManager.validate_member_api方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: clean

# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import validate_member_api [as 别名]
    def clean(self):
        super(UpdateKeyForm, self).clean()

        if 'api_id' in self.cleaned_data and 'api_key' in self.cleaned_data:
            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')
            if EveApiManager.api_key_is_valid(self.cleaned_data['api_id'], self.cleaned_data['api_key']) is False:
                raise forms.ValidationError(u'API key is invalid')
            chars = EveApiManager.get_characters_from_api(self.cleaned_data['api_id'], self.cleaned_data['api_key']).result
            states = []
            states.append(self.user_state)
            for char in chars:
                evechar = EveCharacter()
                evechar.character_name = chars[char]['name']
                evechar.corporation_id = chars[char]['corp']['id']
                evechar.alliance_id = chars[char]['alliance']['id']
                state = determine_membership_by_character(evechar)
                logger.debug("API ID %s character %s has state %s" % (self.cleaned_data['api_id'], evechar, state))
                states.append(state)

            if 'MEMBER' in states:
                if EveApiManager.validate_member_api(self.cleaned_data['api_id'], self.cleaned_data['api_key']) is False:
                    raise forms.ValidationError(u'API must meet member requirements')
            if 'BLUE' in states:
                if EveApiManager.validate_blue_api(self.cleaned_data['api_id'], self.cleaned_data['api_key']) is False:
                    raise forms.ValidationError(u'API must meet blue requirements')
        return self.cleaned_data
开发者ID:Aelonius,项目名称:allianceauth,代码行数:30,代码来源:forms.py

示例2: clean

# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import validate_member_api [as 别名]
    def clean(self):
        super(UpdateKeyForm, self).clean()

        if "api_id" in self.cleaned_data and "api_key" in self.cleaned_data:
            try:
                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")
                if EveApiManager.api_key_is_valid(self.cleaned_data["api_id"], self.cleaned_data["api_key"]) is False:
                    raise forms.ValidationError(u"API key is invalid")
                chars = EveApiManager.get_characters_from_api(
                    self.cleaned_data["api_id"], self.cleaned_data["api_key"]
                ).result
                states = []
                states.append(self.user_state)
                for char in chars:
                    evechar = EveCharacter()
                    evechar.character_name = chars[char]["name"]
                    evechar.corporation_id = chars[char]["corp"]["id"]
                    evechar.alliance_id = chars[char]["alliance"]["id"]
                    state = determine_membership_by_character(evechar)
                    logger.debug("API ID %s character %s has state %s" % (self.cleaned_data["api_id"], evechar, state))
                    states.append(state)

                if "MEMBER" in states:
                    if (
                        EveApiManager.validate_member_api(self.cleaned_data["api_id"], self.cleaned_data["api_key"])
                        is False
                    ):
                        raise forms.ValidationError(u"API must meet member requirements")
                if "BLUE" in states:
                    if (
                        EveApiManager.validate_blue_api(self.cleaned_data["api_id"], self.cleaned_data["api_key"])
                        is False
                    ):
                        raise forms.ValidationError(u"API must meet blue requirements")
                return self.cleaned_data
            except evelink.api.APIError as e:
                logger.debug("Got error code %s while validating API %s" % (e.code, self.cleaned_data["api_id"]))
                if int(e.code) in [221, 222]:
                    raise forms.ValidationError("API key failed validation")
                else:
                    raise forms.ValidationError("Failed to reach API servers")
开发者ID:Ydmir,项目名称:allianceauth,代码行数:47,代码来源:forms.py

示例3: clean

# 需要导入模块: from services.managers.eve_api_manager import EveApiManager [as 别名]
# 或者: from services.managers.eve_api_manager.EveApiManager import validate_member_api [as 别名]
    def clean(self):
        super(UpdateKeyForm, self).clean()

        if 'api_id' in self.cleaned_data and 'api_key' in self.cleaned_data:
            try:
                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')
                if EveApiManager.api_key_is_valid(self.cleaned_data['api_id'], self.cleaned_data['api_key']) is False:
                    raise forms.ValidationError(u'API key is invalid')
                if (settings.REJECT_OLD_APIS and
                    EveManager.check_if_api_key_pair_is_new(self.cleaned_data['api_id'], settings.REJECT_OLD_APIS_MARGIN) is False):
                    raise forms.ValidationError(u'API key is too old. Please create a new key')
                chars = EveApiManager.get_characters_from_api(self.cleaned_data['api_id'], self.cleaned_data['api_key']).result
                states = []
                states.append(self.user_state)
                for char in chars:
                    evechar = EveCharacter()
                    evechar.character_name = chars[char]['name']
                    evechar.corporation_id = chars[char]['corp']['id']
                    evechar.alliance_id = chars[char]['alliance']['id']
                    state = determine_membership_by_character(evechar)
                    logger.debug("API ID %s character %s has state %s" % (self.cleaned_data['api_id'], evechar, state))
                    states.append(state)

                if 'MEMBER' in states:
                    if EveApiManager.validate_member_api(self.cleaned_data['api_id'], self.cleaned_data['api_key']) is False:
                        raise forms.ValidationError(u'API must meet member requirements')
                if 'BLUE' in states:
                    if EveApiManager.validate_blue_api(self.cleaned_data['api_id'], self.cleaned_data['api_key']) is False:
                        raise forms.ValidationError(u'API must meet blue requirements')
                if 'BLUE_10' in states:
                    if EveApiManager.validate_blue_api(self.cleaned_data['api_id'], self.cleaned_data['api_key']) is False:
                        raise forms.ValidationError(u'API must meet blue requirements')
                return self.cleaned_data
            except evelink.api.APIError as e:
                logger.debug("Got error code %s while validating API %s" % (e.code, self.cleaned_data['api_id']))
                if int(e.code) in [221, 222]:
                    raise forms.ValidationError("API key failed validation")
                else:
                    raise forms.ValidationError("Failed to reach API servers")
开发者ID:RichterSR,项目名称:allianceauth,代码行数:43,代码来源:forms.py


注:本文中的services.managers.eve_api_manager.EveApiManager.validate_member_api方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。