本文整理汇总了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)
示例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)