Search code examples
djangomod-wsgiyowsup

pywhatsapp/yowsup2 not running under apache/wsgi


Pywhatsapp (wrapper for yowsup2 - an whatsapp python api) to send messages from my Django app.

from whatsapp import Client
whatsapp_client.send_message(to, message)

above code sends the message fine when I use Django's default development server. However, when I deploy the code into AWS beanstalk and trying to send the message the same code errors out. Both pywhatsapp and yowsup are installed and working okay.

When I try the above code in eb instance's shell (python manage shell) it sends the message just fine....just NOT via apache/mod_wsgi. I learned apache does not do this to avoid security exploitations. But, I have no idea how to properly fix this issue. Any help or pointers to documentation would be very much appreciated.

error I get from AWS:

[Errno 13] Permission denied: '/home/wsgi'

my wsgi file:

    import os
    from django.core.wsgi import get_wsgi_application
    from mezzanine.utils.conf import real_project_name
    os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                  "%s.settings" % real_project_name("vidhaikalam"))
    application = get_wsgi_application()

and my .ebbeanstalk/02_python.config

option_settings:


"aws:elasticbeanstalk:application:environment":
  DJANGO_SETTINGS_MODULE: "vidhaikalam.settings"
  "PYTHONPATH": "/opt/python/current/app/vidhaikalam:$PYTHONPATH"
  DJANGO_SECRET_KEY: "**********"
  DJANGO_NEVERCACHE_KEY: "*********"


"aws:elasticbeanstalk:container:python":
  WSGIPath: vidhaikalam/wsgi.py
  NumProcesses: 3
  NumThreads: 20


"aws:elasticbeanstalk:container:python:staticfiles":
  "/static/": "static/"

Trace back is here :

http://dpaste.com/0DX914S


Solution

  • thanks to Graham Dumpleton's pointer I was able to fix this issue. I simply changed Yowsup's PATH_STORAGE constant like so in my views.py

    from yowsup.common import YowConstants
    YowConstants.PATH_STORAGE = "/tmp/.yowsup"
    

    thanks a lot, Graham Dumpleton!