diff --git a/nilmdb/client.py b/nilmdb/client.py index 78a5720..efed506 100644 --- a/nilmdb/client.py +++ b/nilmdb/client.py @@ -7,7 +7,7 @@ import time import sys import re import os -import json +import simplejson as json import urlparse import urllib import pycurl @@ -233,7 +233,7 @@ class Client(object): "path": path } if start is not None: - params["start"] = repr(start) # keep full precision + params["start"] = repr(start) # use repr to keep precision if end is not None: params["end"] = repr(end) @@ -249,15 +249,16 @@ class Client(object): def stream_extract(self, path, start = None, end = None, bare = False): """ - Return a generator that yields chunks of ascii-formatted data - from the stream. Multiple requests are made to the server if - the results get truncated. + Extract data from a stream. Returns a generator that yields + chunks of ASCII-formatted data that matches the database + layout for the given path. Multiple requests are made to the + server if shorter requests get truncated. """ params = { "path": path } if start is not None: - params["start"] = repr(start) # keep full precision + params["start"] = repr(start) # use repr to keep precision if end is not None: params["end"] = repr(end) params["bare"] = bare diff --git a/nilmdb/cmdline/extract.py b/nilmdb/cmdline/extract.py index e362584..71644b8 100644 --- a/nilmdb/cmdline/extract.py +++ b/nilmdb/cmdline/extract.py @@ -39,8 +39,6 @@ def cmd_extract(self): printf("# start: %s\n", self.time_string(self.args.start)) printf("# end: %s\n", self.time_string(self.args.end)) - return 0 - printed = False for data in self.client.stream_extract(self.args.path, self.args.start, diff --git a/nilmdb/server.py b/nilmdb/server.py index a2547ac..1e0bdd5 100644 --- a/nilmdb/server.py +++ b/nilmdb/server.py @@ -11,7 +11,7 @@ import cherrypy import sys import time import os -import json +import simplejson as json try: import cherrypy diff --git a/runserver.py b/runserver.py index f7e7232..aafc5e8 100755 --- a/runserver.py +++ b/runserver.py @@ -1,7 +1,6 @@ #!/usr/bin/python import nilmdb -import json import argparse parser = argparse.ArgumentParser(description='Run the NILM server') diff --git a/tests/test_client.py b/tests/test_client.py index fed08e6..8c2f001 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,7 +6,6 @@ import datetime_tz from nose.tools import * from nose.tools import assert_raises -import json import itertools import distutils.version import os diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index ef5c780..6ca5c52 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -4,7 +4,6 @@ import nilmdb.cmdline from nose.tools import * from nose.tools import assert_raises -import json import itertools import datetime_tz import os @@ -352,10 +351,13 @@ class TestCmdline(object): eq_(self.captured.count('\n'), 11) def test_cmdline_8_extract(self): + # nonexistent stream self.fail("extract /no/such/foo --start 2000-01-01 --end 2020-01-01") + self.contain("Error getting stream info") - self.ok("extract -a /newton/prep --start 2000-01-01 --end 2020-01-01") - self.dump() + # full dump + # self.ok("extract -a /newton/prep --start 2000-01-01 --end 2020-01-01") + # self.dump() def test_cmdline_9_truncated(self): # Test truncated responses by overriding the nilmdb response_size diff --git a/tests/test_layout.py b/tests/test_layout.py index 114ba2b..bdb1129 100644 --- a/tests/test_layout.py +++ b/tests/test_layout.py @@ -3,7 +3,6 @@ import nilmdb from nose.tools import * from nose.tools import assert_raises import distutils.version -import json import itertools import os import shutil diff --git a/tests/test_nilmdb.py b/tests/test_nilmdb.py index 8db93d5..b7a1c7d 100644 --- a/tests/test_nilmdb.py +++ b/tests/test_nilmdb.py @@ -3,8 +3,8 @@ import nilmdb from nose.tools import * from nose.tools import assert_raises import distutils.version -import json -import itertools +import simplejson as json +import itertools import os import shutil import sys