This repository was archived by the owner on Aug 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
This repository was archived by the owner on Aug 4, 2020. It is now read-only.
TypeError: 'dict' object is not callable when accessing api.feeds.get() #38
Copy link
Copy link
Open
Description
Hi all,
I'm running Python 2.7.3 on my new BeagleBone Black rev. C.; the code I'm trying to use to connect, following the rPI documentation (https://xively.com/dev/tutorials/pi/), but I've been hitting a number of random problems as I've gone along. This is the code I'm using (most of the error catching has been removed so that I can get the full stack traces when it yaks) :
#!/usr/bin/python
import serial
import datetime
import requests
import xively
FEED_ID = 'my_feed_id'
API_KEY = 'my_key'
device = '/dev/ttyO4' #this will have to be changed to the serial port you are using
try:
print "Trying...",device
arduino = serial.Serial(port=device,\
baudrate=115200,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
timeout=None)
except:
print "Failed to connect on",device
print "Connected to ",device
print "Initializing xively API client"
api = xively.XivelyAPIClient(API_KEY)
def get_datastream(feed,sensorNum):
try:
datastream = feed.datastreams.get(sensorNum)
return datastream
except:
datastream = feed.datastreams.create(sensorNum)
return datastream
while True:
line = arduino.readline()
print(line)
pieces = line.split(",") #split the data by the tab
feed = api.feeds.get(FEED_ID)
datastream = get_datastream(feed,str(pieces[0]))
datastream.max_value = None
datastream.min_value = None
datastream.current_value = str(pieces[2])
datastream.at = datetime.datetime.utcnow()
datastream.update()
line = ""
When I run the code, this is the output (and error) that I'm getting:
# python datalogger.nocatch
Trying... /dev/ttyO4
Connected to /dev/ttyO4
Initializing xively API client
25,t,77.00
Traceback (most recent call last):
File "datalogger.nocatch", line 51, in <module>
feed = api.feeds.get(FEED_ID)
File "/usr/local/lib/python2.7/dist-packages/xively/managers.py", line 265, in get
data = response.json()
TypeError: 'dict' object is not callable
I'm a total noob when it comes to Python, so the fix for this may be totally obvious to someone who's well-versed, but it seems that there may be a bug in the managers.py file. How should I go about addressing this?
Metadata
Metadata
Assignees
Labels
No labels