summaryrefslogtreecommitdiff
path: root/examples/migrate_roster.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-01-27 00:09:26 +0100
committermathieui <mathieui@mathieui.net>2021-01-27 00:09:26 +0100
commit9390794401f438e93ac39805b77bcca05d5a3e47 (patch)
tree0ae2c554b246957dc5e5cddc99469cf640fccf7c /examples/migrate_roster.py
parent70b508101896e8076228059fdd4726c2c39fa831 (diff)
downloadslixmpp-9390794401f438e93ac39805b77bcca05d5a3e47.tar.gz
slixmpp-9390794401f438e93ac39805b77bcca05d5a3e47.tar.bz2
slixmpp-9390794401f438e93ac39805b77bcca05d5a3e47.tar.xz
slixmpp-9390794401f438e93ac39805b77bcca05d5a3e47.zip
examples: updates to reflect asyncio
Diffstat (limited to 'examples/migrate_roster.py')
-rwxr-xr-xexamples/migrate_roster.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/migrate_roster.py b/examples/migrate_roster.py
index be457fb3..1fe5895a 100755
--- a/examples/migrate_roster.py
+++ b/examples/migrate_roster.py
@@ -73,21 +73,21 @@ old_xmpp = slixmpp.ClientXMPP(args.old_jid, args.old_password)
roster = []
-def on_session(event):
- roster.append(old_xmpp.get_roster())
+async def on_session(event):
+ roster.append(await old_xmpp.get_roster())
old_xmpp.disconnect()
old_xmpp.add_event_handler('session_start', on_session)
if old_xmpp.connect():
- old_xmpp.process(block=True)
+ old_xmpp.process(forever=False)
if not roster:
print('No roster to migrate')
sys.exit()
new_xmpp = slixmpp.ClientXMPP(args.new_jid, args.new_password)
-def on_session2(event):
- new_xmpp.get_roster()
+async def on_session2(event):
+ await new_xmpp.get_roster()
new_xmpp.send_presence()
logging.info(roster[0])
@@ -97,9 +97,11 @@ def on_session2(event):
for jid, item in data.items():
if item['subscription'] != 'none':
new_xmpp.send_presence(ptype='subscribe', pto=jid)
- new_xmpp.update_roster(jid,
- name = item['name'],
- groups = item['groups'])
+ await new_xmpp.update_roster(
+ jid,
+ name=item['name'],
+ groups=item['groups']
+ )
new_xmpp.disconnect()
new_xmpp.add_event_handler('session_start', on_session2)