@@ -120,7 +120,7 @@ class Stream(NilmApp): | |||
"""Stream-specific operations""" | |||
# /stream/list | |||
# /stream/list?layout=PrepData | |||
# /stream/list?layout=float32_8 | |||
# /stream/list?path=/newton/prep&extent=1 | |||
@cherrypy.expose | |||
@cherrypy.tools.json_out() | |||
@@ -138,7 +138,7 @@ class Stream(NilmApp): | |||
""" | |||
return self.db.stream_list(path, layout, bool(extent)) | |||
# /stream/create?path=/newton/prep&layout=PrepData | |||
# /stream/create?path=/newton/prep&layout=float32_8 | |||
@cherrypy.expose | |||
@cherrypy.tools.json_out() | |||
@exception_to_httperror(NilmDBError, ValueError) | |||
@@ -1,5 +1,5 @@ | |||
# path: /newton/prep | |||
# layout: PrepData | |||
# layout: float32_8 | |||
# start: Fri, 23 Mar 2012 10:00:30.000000 +0000 | |||
# end: Fri, 23 Mar 2012 10:00:31.000000 +0000 | |||
1332496830.000000 251774.000000 224241.000000 5688.100098 1915.530029 9329.219727 4183.709961 1212.349976 2641.790039 | |||
@@ -1,5 +1,5 @@ | |||
# path: /newton/prep | |||
# layout: PrepData | |||
# layout: float32_8 | |||
# start: Fri, 23 Mar 2012 10:00:30.000000 +0000 | |||
# end: Fri, 23 Mar 2012 10:00:31.000000 +0000 | |||
251774.000000 224241.000000 5688.100098 1915.530029 9329.219727 4183.709961 1212.349976 2641.790039 | |||
@@ -1,5 +1,5 @@ | |||
# path: /newton/prep | |||
# layout: PrepData | |||
# layout: float32_8 | |||
# start: 1332496830.0 | |||
# end: 1332496830.999 | |||
1332496830.000000 251774.000000 224241.000000 5688.100098 1915.530029 9329.219727 4183.709961 1212.349976 2641.790039 | |||
@@ -92,9 +92,9 @@ class TestClient(object): | |||
# Bad path | |||
with assert_raises(ClientError): | |||
client.stream_create("foo/bar/baz", "PrepData") | |||
client.stream_create("foo/bar/baz", "float32_8") | |||
with assert_raises(ClientError): | |||
client.stream_create("/foo", "PrepData") | |||
client.stream_create("/foo", "float32_8") | |||
# Bad layout type | |||
with assert_raises(ClientError): | |||
client.stream_create("/newton/prep", "NoSuchLayout") | |||
@@ -109,20 +109,20 @@ class TestClient(object): | |||
client = nilmdb.Client(url = testurl) | |||
# Create three streams | |||
client.stream_create("/newton/prep", "PrepData") | |||
client.stream_create("/newton/raw", "RawData") | |||
client.stream_create("/newton/zzz/rawnotch", "RawNotchedData") | |||
client.stream_create("/newton/prep", "float32_8") | |||
client.stream_create("/newton/raw", "uint16_6") | |||
client.stream_create("/newton/zzz/rawnotch", "uint16_9") | |||
# Verify we got 3 streams | |||
eq_(client.stream_list(), [ ["/newton/prep", "PrepData"], | |||
["/newton/raw", "RawData"], | |||
["/newton/zzz/rawnotch", "RawNotchedData"] | |||
eq_(client.stream_list(), [ ["/newton/prep", "float32_8"], | |||
["/newton/raw", "uint16_6"], | |||
["/newton/zzz/rawnotch", "uint16_9"] | |||
]) | |||
# Match just one type or one path | |||
eq_(client.stream_list(layout="RawData"), | |||
[ ["/newton/raw", "RawData"] ]) | |||
eq_(client.stream_list(layout="uint16_6"), | |||
[ ["/newton/raw", "uint16_6"] ]) | |||
eq_(client.stream_list(path="/newton/raw"), | |||
[ ["/newton/raw", "RawData"] ]) | |||
[ ["/newton/raw", "uint16_6"] ]) | |||
# Try messing with resource limits to trigger errors and get | |||
# more coverage. Here, make it so we can only create files 1 | |||
@@ -131,7 +131,7 @@ class TestClient(object): | |||
limit = resource.getrlimit(resource.RLIMIT_FSIZE) | |||
resource.setrlimit(resource.RLIMIT_FSIZE, (1, limit[1])) | |||
with assert_raises(ServerError) as e: | |||
client.stream_create("/newton/hello", "RawData") | |||
client.stream_create("/newton/hello", "uint16_6") | |||
resource.setrlimit(resource.RLIMIT_FSIZE, limit) | |||
client.close() | |||
@@ -240,10 +240,10 @@ class TestCmdline(object): | |||
self.match("") | |||
# Bad paths | |||
self.fail("create foo/bar/baz PrepData") | |||
self.fail("create foo/bar/baz float32_8") | |||
self.contain("paths must start with /") | |||
self.fail("create /foo PrepData") | |||
self.fail("create /foo float32_8") | |||
self.contain("invalid path") | |||
# Bad layout type | |||
@@ -255,53 +255,53 @@ class TestCmdline(object): | |||
self.contain("no such layout") | |||
# Create a few streams | |||
self.ok("create /newton/zzz/rawnotch RawNotchedData") | |||
self.ok("create /newton/prep PrepData") | |||
self.ok("create /newton/raw RawData") | |||
self.ok("create /newton/zzz/rawnotch uint16_9") | |||
self.ok("create /newton/prep float32_8") | |||
self.ok("create /newton/raw uint16_6") | |||
# Should not be able to create a stream with another stream as | |||
# its parent | |||
self.fail("create /newton/prep/blah PrepData") | |||
self.fail("create /newton/prep/blah float32_8") | |||
self.contain("path is subdir of existing node") | |||
# Should not be able to create a stream at a location that | |||
# has other nodes as children | |||
self.fail("create /newton/zzz PrepData") | |||
self.fail("create /newton/zzz float32_8") | |||
self.contain("subdirs of this path already exist") | |||
# Verify we got those 3 streams and they're returned in | |||
# alphabetical order. | |||
self.ok("list") | |||
self.match("/newton/prep PrepData\n" | |||
"/newton/raw RawData\n" | |||
"/newton/zzz/rawnotch RawNotchedData\n") | |||
self.match("/newton/prep float32_8\n" | |||
"/newton/raw uint16_6\n" | |||
"/newton/zzz/rawnotch uint16_9\n") | |||
# Match just one type or one path. Also check | |||
# that --path is optional | |||
self.ok("list --path /newton/raw") | |||
self.match("/newton/raw RawData\n") | |||
self.match("/newton/raw uint16_6\n") | |||
self.ok("list /newton/raw") | |||
self.match("/newton/raw RawData\n") | |||
self.match("/newton/raw uint16_6\n") | |||
self.fail("list -p /newton/raw /newton/raw") | |||
self.contain("too many paths") | |||
self.ok("list --layout RawData") | |||
self.match("/newton/raw RawData\n") | |||
self.ok("list --layout uint16_6") | |||
self.match("/newton/raw uint16_6\n") | |||
# Wildcard matches | |||
self.ok("list --layout Raw*") | |||
self.match("/newton/raw RawData\n" | |||
"/newton/zzz/rawnotch RawNotchedData\n") | |||
self.ok("list --layout uint16*") | |||
self.match("/newton/raw uint16_6\n" | |||
"/newton/zzz/rawnotch uint16_9\n") | |||
self.ok("list --path *zzz* --layout Raw*") | |||
self.match("/newton/zzz/rawnotch RawNotchedData\n") | |||
self.ok("list --path *zzz* --layout uint16*") | |||
self.match("/newton/zzz/rawnotch uint16_9\n") | |||
self.ok("list *zzz* --layout Raw*") | |||
self.match("/newton/zzz/rawnotch RawNotchedData\n") | |||
self.ok("list *zzz* --layout uint16*") | |||
self.match("/newton/zzz/rawnotch uint16_9\n") | |||
self.ok("list --path *zzz* --layout Prep*") | |||
self.ok("list --path *zzz* --layout float32*") | |||
self.match("") | |||
# reversed range | |||
@@ -599,7 +599,7 @@ class TestCmdline(object): | |||
# Make sure we have the data we expect | |||
self.ok("list --detail /newton/prep") | |||
self.match("/newton/prep PrepData\n" + | |||
self.match("/newton/prep float32_8\n" + | |||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000" | |||
" -> Fri, 23 Mar 2012 10:01:59.991668 +0000 ]\n" | |||
" [ Fri, 23 Mar 2012 10:02:00.000000 +0000" | |||
@@ -634,7 +634,7 @@ class TestCmdline(object): | |||
# See the missing chunks in list output | |||
self.ok("list --detail /newton/prep") | |||
self.match("/newton/prep PrepData\n" + | |||
self.match("/newton/prep float32_8\n" + | |||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000" | |||
" -> Fri, 23 Mar 2012 10:00:05.000000 +0000 ]\n" | |||
" [ Fri, 23 Mar 2012 10:00:25.000000 +0000" | |||
@@ -648,7 +648,7 @@ class TestCmdline(object): | |||
self.ok("remove /newton/prep --start 2000-01-01 --end 2020-01-01") | |||
self.match("") # no count requested this time | |||
self.ok("list --detail /newton/prep") | |||
self.match("/newton/prep PrepData\n" + | |||
self.match("/newton/prep float32_8\n" + | |||
" (no intervals)\n") | |||
# Reinsert some data, to verify that no overlaps with deleted | |||
@@ -673,9 +673,9 @@ class TestCmdline(object): | |||
# From previous tests, we have: | |||
self.ok("list") | |||
self.match("/newton/prep PrepData\n" | |||
"/newton/raw RawData\n" | |||
"/newton/zzz/rawnotch RawNotchedData\n") | |||
self.match("/newton/prep float32_8\n" | |||
"/newton/raw uint16_6\n" | |||
"/newton/zzz/rawnotch uint16_9\n") | |||
# Notice how they're not empty | |||
self.ok("list --detail") | |||
@@ -684,15 +684,15 @@ class TestCmdline(object): | |||
# Delete some | |||
self.ok("destroy /newton/prep") | |||
self.ok("list") | |||
self.match("/newton/raw RawData\n" | |||
"/newton/zzz/rawnotch RawNotchedData\n") | |||
self.match("/newton/raw uint16_6\n" | |||
"/newton/zzz/rawnotch uint16_9\n") | |||
self.ok("destroy /newton/zzz/rawnotch") | |||
self.ok("list") | |||
self.match("/newton/raw RawData\n") | |||
self.match("/newton/raw uint16_6\n") | |||
self.ok("destroy /newton/raw") | |||
self.ok("create /newton/raw RawData") | |||
self.ok("create /newton/raw uint16_6") | |||
self.ok("destroy /newton/raw") | |||
self.ok("list") | |||
self.match("") | |||
@@ -702,7 +702,7 @@ class TestCmdline(object): | |||
"/newton/raw", "/newton/asdf/qwer" ] | |||
for path in rebuild: | |||
# Create the path | |||
self.ok("create " + path + " PrepData") | |||
self.ok("create " + path + " float32_8") | |||
self.ok("list") | |||
self.contain(path) | |||
# Make sure it was created empty | |||
@@ -788,7 +788,7 @@ class TestCmdline(object): | |||
"files_per_dir" : 3 }) | |||
# Insert data. Just for fun, insert out of order | |||
self.ok("create /newton/prep PrepData") | |||
self.ok("create /newton/prep float32_8") | |||
os.environ['TZ'] = "UTC" | |||
self.ok("insert --rate 120 /newton/prep " | |||
"tests/data/prep-20120323T1002 " | |||
@@ -799,7 +799,7 @@ class TestCmdline(object): | |||
# Make sure we have the data we expect | |||
self.ok("list --detail") | |||
self.match("/newton/prep PrepData\n" + | |||
self.match("/newton/prep float32_8\n" + | |||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000" | |||
" -> Fri, 23 Mar 2012 10:01:59.991668 +0000 ]\n" | |||
" [ Fri, 23 Mar 2012 10:02:00.000000 +0000" | |||
@@ -835,7 +835,7 @@ class TestCmdline(object): | |||
# See the missing chunks in list output | |||
self.ok("list --detail") | |||
self.match("/newton/prep PrepData\n" + | |||
self.match("/newton/prep float32_8\n" + | |||
" [ Fri, 23 Mar 2012 10:00:00.000000 +0000" | |||
" -> Fri, 23 Mar 2012 10:00:05.000000 +0000 ]\n" | |||
" [ Fri, 23 Mar 2012 10:00:25.000000 +0000" | |||
@@ -28,7 +28,7 @@ class TestLayouts(object): | |||
# Some nilmdb.layout tests. Not complete, just fills in missing | |||
# coverage. | |||
def test_layouts(self): | |||
x = nilmdb.server.layout.get_named("PrepData") | |||
x = nilmdb.server.layout.get_named("float32_8") | |||
y = nilmdb.server.layout.get_named("float32_8") | |||
eq_(x.count, y.count) | |||
eq_(x.datatype, y.datatype) | |||
@@ -37,7 +37,7 @@ class TestLayouts(object): | |||
eq_(x.datatype, y.datatype) | |||
def test_parsing(self): | |||
self.real_t_parsing("PrepData", "RawData", "RawNotchedData") | |||
self.real_t_parsing("float32_8", "uint16_6", "uint16_9") | |||
self.real_t_parsing("float32_8", "uint16_6", "uint16_9") | |||
def real_t_parsing(self, name_prep, name_raw, name_rawnotch): | |||
# invalid layouts | |||
@@ -72,7 +72,7 @@ class TestLayouts(object): | |||
eq_(parser.data, [[1234567890.0,1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8], | |||
[1234567890.1,1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8]]) | |||
# try RawData too, with clamping | |||
# try uint16_6 too, with clamping | |||
parser = Parser(name_raw) | |||
data = ( "1234567890.000000 1 2 3 4 5 6\n" + | |||
"1234567890.100000 1 2 3 4 5 6\n" ) | |||
@@ -106,7 +106,7 @@ class TestLayouts(object): | |||
"1234567890.100001 1 2 3 4 5 6\n" ) | |||
parser.parse(data) | |||
# RawData with values out of bounds | |||
# uint16_6 with values out of bounds | |||
parser = Parser(name_raw) | |||
data = ( "1234567890.000000 1 2 3 4 500000 6\n" + | |||
"1234567890.100000 1 2 3 4 5 6\n" ) | |||
@@ -122,7 +122,7 @@ class TestLayouts(object): | |||
assert(parser.max_timestamp is None) | |||
def test_formatting(self): | |||
self.real_t_formatting("PrepData", "RawData", "RawNotchedData") | |||
self.real_t_formatting("float32_8", "uint16_6", "uint16_9") | |||
self.real_t_formatting("float32_8", "uint16_6", "uint16_9") | |||
def real_t_formatting(self, name_prep, name_raw, name_rawnotch): | |||
# invalid layout | |||
@@ -156,7 +156,7 @@ class TestLayouts(object): | |||
"1234567890.100000 1.100000 2.200000 3.300000 4.400000 " + | |||
"5.500000 6.600000 7.700000 8.800000\n") | |||
# try RawData too | |||
# try uint16_6 too | |||
formatter = Formatter(name_raw) | |||
data = [ [ 1234567890.000000, 1, 2, 3, 4, 5, 6 ], | |||
[ 1234567890.100000, 1, 2, 3, 4, 5, 6 ] ] | |||
@@ -181,7 +181,7 @@ class TestLayouts(object): | |||
eq_(text, "") | |||
def test_roundtrip(self): | |||
self.real_t_roundtrip("PrepData", "RawData", "RawNotchedData") | |||
self.real_t_roundtrip("float32_8", "uint16_6", "uint16_9") | |||
self.real_t_roundtrip("float32_8", "uint16_6", "uint16_9") | |||
def real_t_roundtrip(self, name_prep, name_raw, name_rawnotch): | |||
# Verify that textual data passed into the Parser, and then | |||
@@ -53,24 +53,24 @@ class Test00Nilmdb(object): # named 00 so it runs first | |||
# Bad path | |||
with assert_raises(ValueError): | |||
db.stream_create("foo/bar/baz", "PrepData") | |||
db.stream_create("foo/bar/baz", "float32_8") | |||
with assert_raises(ValueError): | |||
db.stream_create("/foo", "PrepData") | |||
db.stream_create("/foo", "float32_8") | |||
# Bad layout type | |||
with assert_raises(ValueError): | |||
db.stream_create("/newton/prep", "NoSuchLayout") | |||
db.stream_create("/newton/prep", "PrepData") | |||
db.stream_create("/newton/raw", "RawData") | |||
db.stream_create("/newton/zzz/rawnotch", "RawNotchedData") | |||
db.stream_create("/newton/prep", "float32_8") | |||
db.stream_create("/newton/raw", "uint16_6") | |||
db.stream_create("/newton/zzz/rawnotch", "uint16_9") | |||
# Verify we got 3 streams | |||
eq_(db.stream_list(), [ ["/newton/prep", "PrepData"], | |||
["/newton/raw", "RawData"], | |||
["/newton/zzz/rawnotch", "RawNotchedData"] | |||
eq_(db.stream_list(), [ ["/newton/prep", "float32_8"], | |||
["/newton/raw", "uint16_6"], | |||
["/newton/zzz/rawnotch", "uint16_9"] | |||
]) | |||
# Match just one type or one path | |||
eq_(db.stream_list(layout="RawData"), [ ["/newton/raw", "RawData"] ]) | |||
eq_(db.stream_list(path="/newton/raw"), [ ["/newton/raw", "RawData"] ]) | |||
eq_(db.stream_list(layout="uint16_6"), [ ["/newton/raw", "uint16_6"] ]) | |||
eq_(db.stream_list(path="/newton/raw"), [ ["/newton/raw", "uint16_6"] ]) | |||
# Verify that columns were made right (pytables specific) | |||
if "h5file" in db.data.__dict__: | |||
@@ -173,13 +173,13 @@ class TestServer(object): | |||
streams = getjson("/stream/list") | |||
eq_(streams, [ | |||
['/newton/prep', 'PrepData'], | |||
['/newton/raw', 'RawData'], | |||
['/newton/zzz/rawnotch', 'RawNotchedData'], | |||
['/newton/prep', 'float32_8'], | |||
['/newton/raw', 'uint16_6'], | |||
['/newton/zzz/rawnotch', 'uint16_9'], | |||
]) | |||
streams = getjson("/stream/list?layout=RawData") | |||
eq_(streams, [['/newton/raw', 'RawData']]) | |||
streams = getjson("/stream/list?layout=uint16_6") | |||
eq_(streams, [['/newton/raw', 'uint16_6']]) | |||
streams = getjson("/stream/list?layout=NoSuchLayout") | |||
eq_(streams, []) | |||