Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error pushing values #15

Open
sibero80 opened this issue Nov 10, 2017 · 1 comment
Open

Error pushing values #15

sibero80 opened this issue Nov 10, 2017 · 1 comment

Comments

@sibero80
Copy link

I have this very simple test script:

from ubidots import ApiClient
import subprocess, re, math, time

# Create an ApiClient object

api = ApiClient(token='####################')

# Get a Ubidots Variable

variable = api.get_variable('####################')

# Here is where you usually put the code to capture the data, either through yo$

count = 1

while(1):

    # Write the value to your variable in Ubidots
    count += 1
    aqi = 30
    print (count)
    print (aqi)
    response = variable.save_value({"value": aqi})
    #print(response)
    time.sleep(4)

But after 40 - 60 seconds of pushing data, I get this exception:

Traceback (most recent call last):
  File "ubi3.py", line 26, in <module>
    response = variable.save_value({"value": aqi})
  File "/usr/local/lib/python3.4/dist-packages/ubidots/apiclient.py", line 148, in wrapped_f
    return fn(self, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/ubidots/apiclient.py", line 306, in save_value
    return self.bridge.post('variables/' + self.id + '/values', data).json()
  File "/usr/local/lib/python3.4/dist-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)
@jotathebest
Copy link

This error is related with a downtime server, I believe that you should capture it inside a try - except

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants