Dina
Dina

Reputation: 9

passing from sleekxmpp to slixmpp AttributeError: '_asyncio.Future' object has no attribute 'find_all'

I'm using slixmpp i had these already done in sleekxmpp and trying to pass to slixmpp

for i in results.find_all('.//{jabber:x:data}value'): AttributeError: '_asyncio.Future' object has no attribute 'find_all'

#Create iq Stanza
resp = self.Iq()
resp['type'] = 'set'
resp['to'] = 'search.michaela-pc'
resp['from'] =  self.jid 
resp['id'] = 'search_result'
#Service discovery stanza for getting all users
resp.append(ET.fromstring("<query xmlns='jabber:iq:search'>\
                         <x xmlns='jabber:x:data' type='submit'>\
                            <field type='hidden' var='FORM_TYPE'>\
                                <value>jabber:iq:search</value>\
                            </field>\
                            <field var='Username'>\
                                <value>1</value>\
                            </field>\
                            <field var='search'>\
                                <value>*</value>\
                            </field>\
                        </x>\
                    </query>"))
try:
    results = resp.send()
    # Extract info from recived stanza
    for i in results.find_all('.//{jabber:x:data}value'): 
        if ((i.text != None) and ("@" in i.text)):
            print(i.text)
except IqError as e:
    print("Could not get users")
except IqTimeout:
    print("Server did no respond")

Upvotes: -1

Views: 861

Answers (1)

Dunedan
Dunedan

Reputation: 8435

With Slixmpp Iq.send() doesn't block anymore, but returns a Future.

To make it blocking, you need to yield from the Future like this:

results = yield from resp.send()
for i in results.find_all('.//{jabber:x:data}value'): 
    if ((i.text != None) and ("@" in i.text)):
        print(i.text)

Upvotes: 0

Related Questions