From 3c1ac38ac0fd7adf5b2be0a0bd3d4cd54b25af67 Mon Sep 17 00:00:00 2001 From: Peter Vizi Date: Mon, 14 May 2012 22:02:44 +0200 Subject: [PATCH] Renaming from Pachube to Cosm As discussed in #8 --- README.rst | 2 +- eeml/datastream.py | 16 +++++++++++----- example/read_serial.py | 2 +- example/simple_example.py | 2 +- tests/test_eeml.py | 4 ++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index e8fd39c..8fbdbcf 100644 --- a/README.rst +++ b/README.rst @@ -33,7 +33,7 @@ An example python script for publishing measurement data:: serial = serial.Serial('/dev/ttyUSB0', 9600) readings = serial.readline().strip().split(' ') # the readings are separated by spaces - pac = eeml.Pachube(API_URL, API_KEY) + pac = eeml.Cosm(API_URL, API_KEY) pac.update([eeml.Data(0, readings[0], unit=eeml.Celsius()), eeml.Data(1, readings[1], unit=eeml.RH())]) pac.put() diff --git a/eeml/datastream.py b/eeml/datastream.py index f4b3ef5..85923f6 100644 --- a/eeml/datastream.py +++ b/eeml/datastream.py @@ -8,17 +8,17 @@ __version__ = "0.1" __docformat__ = "restructuredtext en" __doc__ = """ -The way to handle data streams, and put it to the pachube server. +The way to handle data streams, and put it to the Cosm server. """ url_pattern = re.compile("/v[12]/feeds/\d+\.xml") -class Pachube(object): +class Cosm(object): """ - A class for manually updating a pachube data stream. + A class for manually updating a Cosm data stream. """ - host = 'api.pachube.com' + host = 'api.cosm.com' def __init__(self, url, key, env=None, loc=None, dat=[], use_https=True, timeout=10): """ @@ -67,7 +67,7 @@ def put(self): else: conn = httplib.HTTPConnection(self.host, timeout=self._http_timeout) - conn.request('PUT', self._url, etree.tostring(self._eeml.toeeml(), encoding='UTF-8'), {'X-PachubeApiKey': self._key}) + conn.request('PUT', self._url, etree.tostring(self._eeml.toeeml(), encoding='UTF-8'), {'X-ApiKey': self._key}) conn.sock.settimeout(5.0) resp = conn.getresponse() if resp.status != 200: @@ -79,3 +79,9 @@ def put(self): raise Exception(msg) resp.read() conn.close() + +class Pachube(Cosm): + """ + For backward compatibility + """ + pass diff --git a/example/read_serial.py b/example/read_serial.py index b9be079..71828cf 100644 --- a/example/read_serial.py +++ b/example/read_serial.py @@ -7,6 +7,6 @@ serial = serial.Serial('/dev/ttyUSB0', 9600) readings = serial.readline().strip().split(' ') # the readings are separated by spaces -pac = eeml.Pachube(API_URL, API_KEY) +pac = eeml.Cosm(API_URL, API_KEY) pac.update([eeml.Data(0, readings[0], unit=eeml.Celsius()), eeml.Data(1, readings[1], unit=eeml.RH())]) pac.put() diff --git a/example/simple_example.py b/example/simple_example.py index 741c989..3057ea4 100644 --- a/example/simple_example.py +++ b/example/simple_example.py @@ -10,7 +10,7 @@ API_URL = 42166 readings = [3, 4] -pac = eeml.Pachube(API_URL, API_KEY) +pac = eeml.Cosm(API_URL, API_KEY) pac.update([ eeml.Data("Temperature", readings[0], unit=eeml.Celsius()), eeml.Data("Humidity", readings[1], unit=eeml.RH())]) diff --git a/tests/test_eeml.py b/tests/test_eeml.py index b4b5f52..b1033fc 100644 --- a/tests/test_eeml.py +++ b/tests/test_eeml.py @@ -55,7 +55,7 @@ def test_good_data(self): def test_good_environment(self): env = Environment('A Room Somewhere', - 'http://www.pachube.com/feeds/1.xml', + 'http://www.cosm.com/feeds/1.xml', 'frozen', 'This is a room somewhere', 'http://www.roomsomewhere/icon.png', @@ -79,7 +79,7 @@ def test_good_environment(self): def test_good_create_doc(self): env = Environment('A Room Somewhere', - 'http://www.pachube.com/feeds/1.xml', + 'http://www.cosm.com/feeds/1.xml', 'frozen', 'This is a room somewhere', 'http://www.roomsomewhere/icon.png',