Advertisement
Guest User

Untitled

a guest
Feb 10th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. import output
  2. import requests
  3. import json
  4.  
  5. class Xively(output.Output):
  6.         proxies = {
  7.                 "http": "http://10.10.1.10:3128",
  8.                 "https": "http://10.10.1.10:1080"
  9.         }
  10.         requiredData = ["APIKey","FeedID"]
  11.         optionalData = []
  12.         def __init__(self,data):
  13.                 self.APIKey=data["APIKey"]
  14.                 self.FeedID=data["FeedID"]
  15.         def outputData(self,dataPoints):
  16.                 arr = []
  17.                 for i in dataPoints:
  18.                         arr.append({"id":i["name"],"current_value":i["value"]})
  19.                 a = json.dumps({"version":"1.0.0","datastreams":arr})
  20.                 z = requests.put("http://api.xively.com/v2/feeds/"+self.FeedID+".json",headers={"X-ApiKey":self.APIKey},data=a, proxies=proxies)
  21.                 print (x.text)
  22.                 return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement