Switch from @asyncio.coroutine to async def everywhere.

This commit is contained in:
Emmanuel Gil Peyrot 2018-07-02 01:55:34 +02:00
parent 29b10b6c2b
commit 5483cd40ee

View file

@ -382,8 +382,7 @@ class HandlerCore:
else: else:
self.core.refresh_window() self.core.refresh_window()
@asyncio.coroutine async def on_0084_avatar(self, msg):
def on_0084_avatar(self, msg):
jid = msg['from'].bare jid = msg['from'].bare
contact = roster[jid] contact = roster[jid]
if not contact: if not contact:
@ -408,7 +407,7 @@ class HandlerCore:
# If we didnt have any, query the data instead. # If we didnt have any, query the data instead.
if not info['url']: if not info['url']:
try: try:
result = yield from self.core.xmpp[ result = await self.core.xmpp[
'xep_0084'].retrieve_avatar( 'xep_0084'].retrieve_avatar(
jid, avatar_hash, timeout=60) jid, avatar_hash, timeout=60)
avatar = result['pubsub']['items']['item']['avatar_data'][ avatar = result['pubsub']['items']['item']['avatar_data'][
@ -432,8 +431,7 @@ class HandlerCore:
exc_info=True) exc_info=True)
return return
@asyncio.coroutine async def on_vcard_avatar(self, pres):
def on_vcard_avatar(self, pres):
jid = pres['from'].bare jid = pres['from'].bare
contact = roster[jid] contact = roster[jid]
if not contact: if not contact:
@ -450,7 +448,7 @@ class HandlerCore:
# If we didnt have any, query the vCard instead. # If we didnt have any, query the vCard instead.
try: try:
result = yield from self.core.xmpp['xep_0054'].get_vcard( result = await self.core.xmpp['xep_0054'].get_vcard(
jid, cached=True, timeout=60) jid, cached=True, timeout=60)
avatar = result['vcard_temp']['PHOTO'] avatar = result['vcard_temp']['PHOTO']
binval = avatar['BINVAL'] binval = avatar['BINVAL']
@ -1140,8 +1138,7 @@ class HandlerCore:
self.core.information("Connection to remote server failed: %s" % self.core.information("Connection to remote server failed: %s" %
(error, ), 'Error') (error, ), 'Error')
@asyncio.coroutine async def on_disconnected(self, event):
def on_disconnected(self, event):
""" """
When we are disconnected from remote server When we are disconnected from remote server
""" """
@ -1162,7 +1159,7 @@ class HandlerCore:
and self.core.last_stream_error[1]['condition'] in ( and self.core.last_stream_error[1]['condition'] in (
'conflict', 'host-unknown')): 'conflict', 'host-unknown')):
return return
yield from asyncio.sleep(1) await asyncio.sleep(1)
self.core.information("Auto-reconnecting.", 'Info') self.core.information("Auto-reconnecting.", 'Info')
self.core.xmpp.start() self.core.xmpp.start()