Skip to content

Commit

Permalink
Updating examples with correct package names
Browse files Browse the repository at this point in the history
  • Loading branch information
petervizi committed Jan 31, 2013
1 parent aba41d3 commit 33a842a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Example
An example python script for publishing measurement data::

import eeml
import eeml.datastream
import eeml.unit
import serial

# parameters
Expand All @@ -36,8 +38,8 @@ 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.Cosm(API_URL, API_KEY)
pac.update([eeml.Data(0, readings[0], unit=eeml.Celsius()), eeml.Data(1, readings[1], unit=eeml.RH())])
pac = eeml.datastream.Cosm(API_URL, API_KEY)
pac.update([eeml.Data(0, readings[0], unit=eeml.unit.Celsius()), eeml.Data(1, readings[1], unit=eeml.unit.RH())])
pac.put()

Other examples can be found in the example folder.
Expand Down
6 changes: 4 additions & 2 deletions example/exception_example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import eeml
import eeml.datastream
import eeml.unit
import serial
from eeml import CosmError

Expand All @@ -11,10 +13,10 @@
readings = serial.readline().strip().split(' ') # the readings are separated by spaces

# open up your cosm feed
pac = eeml.Cosm(API_URL, API_KEY)
pac = eeml.datastream.Cosm(API_URL, API_KEY)

# prepare the emml payload
pac.update([eeml.Data(0, readings[0], unit=eeml.Celsius()), eeml.Data(1, readings[1], unit=eeml.RH())])
pac.update([eeml.Data(0, readings[0], unit=eeml.unit.Celsius()), eeml.Data(1, readings[1], unit=eeml.unit.RH())])

# attempt to send the data to Cosm. Attempt to handle exceptions, such that the script continues running.
# You could optionally place some retry logic around the pac.put() command.
Expand Down
8 changes: 6 additions & 2 deletions example/read_serial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import eeml
import eeml.datastream
import eeml.unit
import serial

# parameters
Expand All @@ -7,6 +9,8 @@

serial = serial.Serial('/dev/ttyUSB0', 9600)
readings = serial.readline().strip().split(' ') # the readings are separated by spaces
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 = eeml.datastream.Cosm(API_URL, API_KEY)
pac.update([eeml.Data(0, readings[0], unit=eeml.unit.Celsius()), eeml.Data(1, readings[1], unit=eeml.unit.RH())])
print(pac.geteeml())
pac.put()

10 changes: 5 additions & 5 deletions example/simple_example.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import eeml
import eeml.datastream
import eeml.unit
import serial
import datetime

a = datetime.tzinfo()

# parameters
API_KEY = 'YOUR_API_KEY'
# API_URL = '/v2/feeds/42166.xml'
API_URL = 42166

readings = [3, 4]
pac = eeml.Cosm(API_URL, API_KEY)
pac = eeml.datastream.Cosm(API_URL, API_KEY)
at = datetime.datetime(2012, 9, 12, 11, 0, 0)

pac.update([
eeml.Data("Temperature", readings[0], unit=eeml.Celsius(), at=at),
eeml.Data("Humidity", readings[1], unit=eeml.RH())])
eeml.Data(0, readings[0], tags=('Temperature',), unit=eeml.unit.Celsius(), at=at),
eeml.Data(1, readings[1], tags=('Humidity',), unit=eeml.unit.RH())])
pac.put()
print(pac.geteeml())

0 comments on commit 33a842a

Please sign in to comment.