SleekXMPP - XEP-0009

31 views
Skip to first unread message

Heberth Vargas

unread,
Nov 1, 2019, 4:49:33 PM11/1/19
to SleekXMPP Discussion
how can i convert a dictionary of parameters to the correct type for this method


def make_iq_method_call(self, pto, pmethod, params):
 iq
= self.xmpp.makeIqSet()
 iq
.attrib['to'] = pto
 iq
.attrib['from'] = self.xmpp.boundjid.full
 iq
.enable('rpc_query')
 iq
['rpc_query']['method_call']['method_name'] = pmethod
 iq
['rpc_query']['method_call']['params'] = params
 
return iq

i try this
msg ="<params>\
        <param>\
          <value><i4>6</i4></value>\
        </param>\
      </params>"

params = ElementTree.fromstring(msg)

self.plugin['xep_0009'].make_iq_method_call(self.recipient,"miMetodo",params)

even doing that i receive this error raise TypeError because params is not a ElementTree object but that does not make sense, 
also i would like to know how to converte the dictionary python to a valid parameters for that method for the RPC plugin  

thanks 



Heberth Vargas

unread,
Nov 1, 2019, 5:59:29 PM11/1/19
to SleekXMPP Discussion
i found the reason i received  raise TypeError
is necessary to use the import like this 
from xml.etree import cElementTree as ET and not like this from xml.etree import ElementTree as ET
but i still want to know how to convert a python dictionary to valid parameters for that method for the RPC plugin  

Heberth Vargas

unread,
Nov 2, 2019, 11:31:13 AM11/2/19
to SleekXMPP Discussion
well i guess is necessary to convert the dict to String Json and send one parameter String 


El viernes, 1 de noviembre de 2019, 15:49:33 (UTC-5), Heberth Vargas escribió:
Reply all
Reply to author
Forward
0 new messages