Carolina Q.
Carolina Q.

Reputation: 43

Send a xmpp message using xmmp python library and google app engine

I'm trying to send a message using xmpp and google app engine. I'm using xmpp library for python. My code is the following:

import webapp2
import xmpp

_SERVER = 'serverdomain'

class MainPage(webapp2.RequestHandler):
    def post(self):

        msg = 'hello'

        global username 
        username = 'user'
        global passwd
        passwd = 'ssdsd'

        global xmppClient
        global to
        to='toAddress' 

        jid = xmpp.protocol.JID(username)
        xmppClient = xmpp.Client(jid.getDomain(),debug=[])
        xmppClient.connect(server=_SERVER)
        xmppClient.auth(username, passwd, 'botty')
        xmppClient.sendInitPresence()
        self.response.out.write('me conecte '+xmppClient.isConnected())
        xmppClient.send(xmppClient.Message(to, msg, type='chat'))

app = webapp2.WSGIApplication([ ('/', MainPage)], debug=True)

When I execute my test I obtain the following error

ImportError: No module named xmpp

over and over again. I put in pythonpath the .egg xmpp library and eclipse recognized it so I can use CTRL+TAB to autocomplete., that indicates me the the editor recognize the library but no the server (GAE) so maybe I need to add the library to the server and compile it. Is that a good idea? any other server suggestion? I need help please.

Thanks.

Upvotes: 1

Views: 4974

Answers (3)

Takumi
Takumi

Reputation: 67

In Debian, had the same problem. In my case, I solved it installing the python-xmpp package: apt-get install python-xmpp

I hope it help you

For package details, see here: https://packages.debian.org/sid/python/python-xmpp

Upvotes: 2

pulo71
pulo71

Reputation: 11

Looks like your import path is incomplete. Try:

from google.appengine.api import xmpp

Instead of

import xmpp

Lots more detail here

Upvotes: 1

dragonx
dragonx

Reputation: 15143

Take a look at other questions about setting up third party libraries for GAE. Note that if the xmpp library is not pure python (ie uses native code), you won't be able to use it.

https://stackoverflow.com/search?q=google-app-engine+python+third+party+libraries

Upvotes: 0

Related Questions