diff options
author | mathieui <mathieui@mathieui.net> | 2021-01-27 00:20:31 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-01-27 00:20:31 +0100 |
commit | 370abb1d983bf1aabff523d4bbc5c9b89a2becb8 (patch) | |
tree | 0d191cd7f9f47101fa2fb835760651bf5dee736e /examples | |
parent | 70b508101896e8076228059fdd4726c2c39fa831 (diff) | |
parent | 51866f0d46a932f2b720bc876eb4bef50cfb277d (diff) | |
download | slixmpp-370abb1d983bf1aabff523d4bbc5c9b89a2becb8.tar.gz slixmpp-370abb1d983bf1aabff523d4bbc5c9b89a2becb8.tar.bz2 slixmpp-370abb1d983bf1aabff523d4bbc5c9b89a2becb8.tar.xz slixmpp-370abb1d983bf1aabff523d4bbc5c9b89a2becb8.zip |
Merge branch 'block-threaded-examples-docs' into 'master'
Remove the remaining block and threaded from examples
See merge request poezio/slixmpp!105
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/IoT_TestDevice.py | 4 | ||||
-rwxr-xr-x | examples/migrate_roster.py | 18 |
2 files changed, 12 insertions, 10 deletions
diff --git a/examples/IoT_TestDevice.py b/examples/IoT_TestDevice.py index b9546017..d8e8fd06 100755 --- a/examples/IoT_TestDevice.py +++ b/examples/IoT_TestDevice.py @@ -168,13 +168,13 @@ if __name__ == '__main__': xmpp.beClientOrServer(server=True) while not(xmpp.testForRelease()): xmpp.connect() - xmpp.process(block=True) + xmpp.process(forever=False) logging.debug("lost connection") if args.sensorjid: logging.debug("will try to call another device for data") xmpp.beClientOrServer(server=False,clientJID=args.sensorjid) xmpp.connect() - xmpp.process(block=True) + xmpp.process(forever=False) logging.debug("ready ending") else: 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) |