This is a test of website. You need to post the API keys to the python script from the command line.
Title: Python Key error - it could be versioning
In Python on a Raspberry pi model 3, I am receiving a Key error ? It could be versioning.
curl works great on the pi over wifi or AT&T LTE to the M2x cloud.
Here is the script output:
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "/home/pi/Desktop/GrovePi/Software/Python/att_IoT/m2x_example_search_devices.py", line 11, in <module>
client = M2XClient(key=os.environ['MyrealAPIKey'])
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'MyrealAPIKey'
>>>
Here is the m2x find devices example code:
#!/usr/bin/env python
# find devices for API key
# Usage:
# $ API_KEY=<YOUR MASTER API KEY> python example.py
import os
from m2x.client import M2XClient
from m2x.v2.devices import Device
client = M2XClient(key=os.environ['MyrealAPIKey'])
params = {
"visibility": "private",
"status": "enabled",
"limit": "3"
}
response = Device.search(api = client, params = params)
if len(response) > 0:
print("\nDevice Details :")
for device in response:
print("Device name: %s Device Id: %s Device Visibility: %s Device Status: %s " % (device.name, device.id, device.visibility, device.status ))
else:
print("Devices not available in this search criteria")
This is a test of website. You need to post the API keys to the python script from the command line.