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


Python EveAPIHandler.autoparse_shared_list方法代码示例

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


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

示例1: fetch_mailinglists

# 需要导入模块: from stationspinner.libs.eveapihandler import EveAPIHandler [as 别名]
# 或者: from stationspinner.libs.eveapihandler.EveAPIHandler import autoparse_shared_list [as 别名]
def fetch_mailinglists(apiupdate_pk):
    try:
        target, character = _get_character_auth(apiupdate_pk)
    except CharacterSheet.DoesNotExist:
        log.debug('CharacterSheet for APIUpdate {0} not indexed yet.'.format(apiupdate_pk))
        return
    except APIUpdate.DoesNotExist:
        log.warning('Target APIUpdate {0} was deleted mid-flight.'.format(apiupdate_pk))
        return

    handler = EveAPIHandler()
    auth = handler.get_authed_eveapi(target.apikey)
    try:
        api_data = auth.char.MailingLists(characterID=target.owner)
    except AuthenticationError:
        log.error('AuthenticationError for key "{0}" owned by "{1}"'.format(
            target.apikey.keyID,
            target.apikey.owner
        ))
        target.delete()
        return

    listIDs = handler.autoparse_shared_list(api_data.mailingLists,
                          MailingList,
                          ('listID',),
                          character,
                          pre_save=True)

    unsubscribed = character.mailinglist_set.exclude(listID__in=listIDs)
    for desub in unsubscribed:
        desub.owners.remove(character)

    target.updated(api_data)
开发者ID:eve-armada,项目名称:stationspinner,代码行数:35,代码来源:tasks.py

示例2: fetch_mails

# 需要导入模块: from stationspinner.libs.eveapihandler import EveAPIHandler [as 别名]
# 或者: from stationspinner.libs.eveapihandler.EveAPIHandler import autoparse_shared_list [as 别名]
def fetch_mails(apiupdate_pk):
    try:
        target, character = _get_character_auth(apiupdate_pk)
    except CharacterSheet.DoesNotExist:
        log.debug('CharacterSheet for APIUpdate {0} not indexed yet.'.format(apiupdate_pk))
        return
    except APIUpdate.DoesNotExist:
        log.warning('Target APIUpdate {0} was deleted mid-flight.'.format(apiupdate_pk))
        return

    handler = EveAPIHandler()
    auth = handler.get_authed_eveapi(target.apikey)
    try:
        api_data = auth.char.MailMessages(characterID=target.owner)
    except AuthenticationError:
        log.error('AuthenticationError for key "{0}" owned by "{1}"'.format(
            target.apikey.keyID,
            target.apikey.owner
        ))
        target.delete()
        return

    mails = handler.autoparse_shared_list(api_data.messages,
                          MailMessage,
                          ('messageID',),
                          character,
                          pre_save=True)

    unfetched_mails = MailMessage.objects.filter(
        owners__in=[character.pk],
        pk__in=mails,
        broken=False,
        raw_message=None)


    EveName.objects.populate()
    if unfetched_mails.count() > 0:
        mail_bodies = auth.char.MailBodies(characterID=target.owner,
                                               IDs=[mail.messageID for mail in unfetched_mails])

        for mail_body in mail_bodies.messages:
            try:
                mail = MailMessage.objects.get(messageID=mail_body.messageID)
                mail.raw_message = mail_body.data
                mail.populate_receivers()
                mail.save()
            except MailMessage.DoesNotExist:
                log.error('Could not fetch message body for messageID {0} belonging to character "{1}".'.format(
                    mail_body.messageID,
                    character
                ))
            #except:
            #    note.broken = True
            #    note.save()




    target.updated(api_data)
开发者ID:eve-armada,项目名称:stationspinner,代码行数:61,代码来源:tasks.py


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