本文整理匯總了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)