|
|
@@ -25,7 +25,7 @@ class NilmApp(object): |
|
|
|
self.db = db |
|
|
|
|
|
|
|
version = "1.1" |
|
|
|
|
|
|
|
|
|
|
|
class Root(NilmApp): |
|
|
|
"""Root application for NILM database""" |
|
|
|
|
|
|
@@ -72,19 +72,12 @@ class Stream(NilmApp): |
|
|
|
# /stream/create?path=/newton/prep&layout=PrepData |
|
|
|
@cherrypy.expose |
|
|
|
@cherrypy.tools.json_out() |
|
|
|
def create(self, path, layout, index = None): |
|
|
|
def create(self, path, layout): |
|
|
|
"""Create a new stream in the database. Provide path |
|
|
|
and one of the nilmdb.layout.layouts keys. |
|
|
|
|
|
|
|
index: list of layout columns to be marked as PyTables indices. |
|
|
|
If index = none, the 'timestamp' column is indexed if it exists. |
|
|
|
Pass an empty list to prevent indexing. |
|
|
|
""" |
|
|
|
# Index needs to be a list, if it's not None |
|
|
|
if (index is not None) and (not isinstance(index, list)): |
|
|
|
index = [ index ] |
|
|
|
try: |
|
|
|
return self.db.stream_create(path, layout, index) |
|
|
|
return self.db.stream_create(path, layout) |
|
|
|
except Exception as e: |
|
|
|
message = sprintf("%s: %s", type(e).__name__, e.message) |
|
|
|
raise cherrypy.HTTPError("400 Bad Request", message) |
|
|
@@ -179,7 +172,7 @@ class Stream(NilmApp): |
|
|
|
result = self.db.stream_insert(path, parser) |
|
|
|
except nilmdb.nilmdb.NilmDBError as e: |
|
|
|
raise cherrypy.HTTPError("400 Bad Request", e.message) |
|
|
|
|
|
|
|
|
|
|
|
return "ok" |
|
|
|
|
|
|
|
class Exiter(object): |
|
|
@@ -201,7 +194,7 @@ class Server(object): |
|
|
|
force_traceback = False # include traceback in all errors |
|
|
|
): |
|
|
|
self.version = version |
|
|
|
|
|
|
|
|
|
|
|
# Need to wrap DB object in a serializer because we'll call |
|
|
|
# into it from separate threads. |
|
|
|
self.embedded = embedded |
|
|
|