0

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

gowthaman
  • 3
  • 2
  • How is your apache/mod_wsgi setup? – masnun Aug 16 '16 at 06:43
  • The library you are using is likely trying to write files to the home directory of the account and it looks like that isn't writable, or perhaps you haven't configured some path correctly. You shouldn't rely on relative paths under mod_wsgi as the working directory for a process isn't usually going to be where your code is. BTW, you would be better of showing the full Python traceback with where exactly in code it failed and what the code at that line was. It was likely within that function you show and not that actual line of code. – Graham Dumpleton Aug 16 '16 at 06:55
  • here is my traceback http://dpaste.com/0DX914S – gowthaman Aug 16 '16 at 07:08

1 Answers1

0

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!

gowthaman
  • 3
  • 2