Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import output
- import requests
- import json
- class Xively(output.Output):
- proxies = {
- "http": "http://10.10.1.10:3128",
- "https": "http://10.10.1.10:1080"
- }
- requiredData = ["APIKey","FeedID"]
- optionalData = []
- def __init__(self,data):
- self.APIKey=data["APIKey"]
- self.FeedID=data["FeedID"]
- def outputData(self,dataPoints):
- arr = []
- for i in dataPoints:
- arr.append({"id":i["name"],"current_value":i["value"]})
- a = json.dumps({"version":"1.0.0","datastreams":arr})
- try:
- z = requests.put("http://api.xively.com/v2/feeds/"+self.FeedID+".json",headers={"X-ApiKey":self.APIKey},data=a, proxies=proxies)
- if z.text!="":
- print "Xively Error: " + z.text
- return False
- except Exception:
- return False
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement