Skip to content

Commit

Permalink
Renaming from Pachube to Cosm
Browse files Browse the repository at this point in the history
As discussed in #8
  • Loading branch information
petervizi committed May 14, 2012
1 parent 5c5adb2 commit 3c1ac38
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -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()

Expand Down
16 changes: 11 additions & 5 deletions eeml/datastream.py
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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:
Expand All @@ -79,3 +79,9 @@ def put(self):
raise Exception(msg)
resp.read()
conn.close()

class Pachube(Cosm):
"""
For backward compatibility
"""
pass
2 changes: 1 addition & 1 deletion example/read_serial.py
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion example/simple_example.py
Expand Up @@ -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())])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_eeml.py
Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 3c1ac38

Please sign in to comment.