Browse Source

interface for dashing

Helge Jung 10 years ago
parent
commit
18fe49fd5d
1 changed files with 28 additions and 0 deletions
  1. 28 0
      dashing-interface.py

+ 28 - 0
dashing-interface.py

@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+import json
+import requests
+
+class DashingAdapter:
+	base_url = None
+
+	def __init__(self, base_url, auth_token):
+		self.base_url = base_url
+		self.auth_token = auth_token
+
+	def send(self, metric, current, previous=None, blubb=None, bla=None):
+		info = {
+			'auth_token': self.auth_token,
+			'current': int(current),
+		}
+		if not previous is None:
+			info['previous'] = previous
+
+		url = self.base_url + metric
+		r = requests.post(url, data=json.dumps(info))
+		return r
+
+if __name__ == "__main__":
+	d = DashingAdapter('http://dashing.krombel.de:3030/widgets/', 'bitnhmlj47hamrftxkiug')
+	d.send('testNumber', 42)
+