Search code examples
pythonopenshiftsimplejson

Simplejson Error on Openshift


I've been using an external Python package rapportive.py locally and it works great. Now I'm trying to use it on OpenShift. I was able to install the package successfully via requirements.txt & I can import it, but whenever I try to use it, I get a JSONDecodeError:

Python 2.7.5 (default, Aug 16 2013, 05:57:04) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> from rapportive import rapportive
>>> profile = rapportive.request("test@test.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/openshift/537830065973ca131b00036b/app-root/runtime/dependencies/python/virtenv/src/rapportive/rapportive/rapportive.py", line 83, in request
    response = requests.get(status_url).json()
  File "/var/lib/openshift/537830065973ca131b00036b/python/virtenv/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/models.py", line 763, in json
    return json.loads(self.text, **kwargs)
  File "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/simplejson/__init__.py", line 453, in loads
    return _default_decoder.decode(s)
  File "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 429, in decode
    obj, end = self.raw_decode(s)
  File "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 451, in raw_decode
    raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

I'm not sure if this an OpenShift problem, or if I'm missing something really simple. But either way, I could some help. Thanks!


Solution

  • Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/var/lib/openshift/537830065973ca131b00036b/app-root/runtime/dependencies/python/virtenv/src/rapportive/rapportive/rapportive.py", line 83, in request
        response = requests.get(status_url).json()
    

    This portion of the stack trace indicates the line in rapportive.py that is failing, which then suggests that requests.get() is not returning a valid response that can be converted in a JSON object. Is this the exact same code that you tested locally, with the same test user?

    Try running the following code on OpenShift and see if any errors are thrown:

    import requests
    STATUS_URL = 'https://rapportive.com/login_status?user_email=test@test.com'
    response = requests.get(STATUS_URL)
    

    If that code works without error, then it should be possible to then run response.json without error. This should at least point you in the right direction as what the problem is.