Compare commits
10 Commits
nilmdb-1.9
...
nilmdb-1.9
Author | SHA1 | Date | |
---|---|---|---|
f5276e9fc8 | |||
c47f28f93a | |||
63b5f99b90 | |||
7d7b89b52f | |||
8d249273c6 | |||
abe431c663 | |||
ccf1f695af | |||
06f7390c9e | |||
6de77a08f1 | |||
8db9771c20 |
6
Makefile
6
Makefile
@@ -1,5 +1,5 @@
|
||||
# By default, run the tests.
|
||||
all: fscktest
|
||||
all: test
|
||||
|
||||
version:
|
||||
python setup.py version
|
||||
@@ -23,10 +23,6 @@ docs:
|
||||
lint:
|
||||
pylint --rcfile=.pylintrc nilmdb
|
||||
|
||||
fscktest:
|
||||
python -c "import nilmdb.fsck; nilmdb.fsck.Fsck('/home/jim/wsgi/db').check()"
|
||||
# python -c "import nilmdb.fsck; nilmdb.fsck.Fsck('/home/jim/mnt/bucket/mnt/sharon/data/db', True).check()"
|
||||
|
||||
test:
|
||||
ifeq ($(INSIDE_EMACS), t)
|
||||
# Use the slightly more flexible script
|
||||
|
@@ -9,7 +9,7 @@ import requests
|
||||
|
||||
class HTTPClient(object):
|
||||
"""Class to manage and perform HTTP requests from the client"""
|
||||
def __init__(self, baseurl = "", post_json = False):
|
||||
def __init__(self, baseurl = "", post_json = False, verify_ssl = True):
|
||||
"""If baseurl is supplied, all other functions that take
|
||||
a URL can be given a relative URL instead."""
|
||||
# Verify / clean up URL
|
||||
@@ -19,6 +19,7 @@ class HTTPClient(object):
|
||||
self.baseurl = reparsed.rstrip('/') + '/'
|
||||
|
||||
# Build Requests session object, enable SSL verification
|
||||
self.verify_ssl = verify_ssl
|
||||
self.session = requests.Session()
|
||||
self.session.verify = True
|
||||
|
||||
@@ -67,7 +68,8 @@ class HTTPClient(object):
|
||||
params = query_data,
|
||||
data = body_data,
|
||||
stream = stream,
|
||||
headers = headers)
|
||||
headers = headers,
|
||||
verify = self.verify_ssl)
|
||||
except requests.RequestException as e:
|
||||
raise ServerError(status = "502 Error", url = url,
|
||||
message = str(e.message))
|
||||
|
@@ -121,7 +121,7 @@ class Cmdline(object):
|
||||
group = self.parser.add_argument_group("General options")
|
||||
group.add_argument("-h", "--help", action='help',
|
||||
help='show this help message and exit')
|
||||
group.add_argument("-V", "--version", action="version",
|
||||
group.add_argument("-v", "--version", action="version",
|
||||
version = nilmdb.__version__)
|
||||
|
||||
group = self.parser.add_argument_group("Server")
|
||||
|
@@ -45,6 +45,8 @@ def setup(self, sub):
|
||||
help="Show raw timestamps when printing times")
|
||||
group.add_argument("-l", "--layout", action="store_true",
|
||||
help="Show layout type next to path name")
|
||||
group.add_argument("-n", "--no-decim", action="store_true",
|
||||
help="Skip paths containing \"~decim-\"")
|
||||
|
||||
return cmd
|
||||
|
||||
@@ -71,6 +73,8 @@ def cmd_list(self):
|
||||
(path, layout, int_min, int_max, rows, time) = stream[:6]
|
||||
if not fnmatch.fnmatch(path, argpath):
|
||||
continue
|
||||
if self.args.no_decim and "~decim-" in path:
|
||||
continue
|
||||
|
||||
if self.args.layout:
|
||||
printf("%s %s\n", path, layout)
|
||||
|
@@ -381,7 +381,7 @@ class Fsck(object):
|
||||
err("*** Deleting the entire interval from SQL.\n")
|
||||
err("This may leave stale data on disk. To fix that, copy all\n")
|
||||
err("data from this stream to a new stream, then remove all data\n")
|
||||
err("from and destroy %s.\n")
|
||||
err("from and destroy %s.\n", path)
|
||||
with self.sql:
|
||||
cur = self.sql.cursor()
|
||||
cur.execute("DELETE FROM ranges WHERE "
|
||||
|
@@ -10,9 +10,8 @@ def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description = 'Check database consistency',
|
||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument("-V", "--version", action="version",
|
||||
version = nilmdb.__version__)
|
||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
|
||||
version = nilmdb.__version__)
|
||||
parser.add_argument("-f", "--fix", action="store_true",
|
||||
default=False, help = 'Fix errors when possible '
|
||||
'(which may involve removing data)')
|
||||
|
@@ -10,10 +10,8 @@ def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description = 'Run the NilmDB server',
|
||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter)
|
||||
|
||||
parser.add_argument("-V", "--version", action="version",
|
||||
version = nilmdb.__version__)
|
||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
|
||||
version = nilmdb.__version__)
|
||||
|
||||
group = parser.add_argument_group("Standard options")
|
||||
group.add_argument('-a', '--address',
|
||||
|
@@ -194,6 +194,9 @@ class BulkData(object):
|
||||
if oldospath == newospath:
|
||||
raise ValueError("old and new paths are the same")
|
||||
|
||||
# Remove Table object at old path from cache
|
||||
self.getnode.cache_remove(self, oldunicodepath)
|
||||
|
||||
# Move the table to a temporary location
|
||||
tmpdir = tempfile.mkdtemp(prefix = "rename-", dir = self.root)
|
||||
tmppath = os.path.join(tmpdir, "table")
|
||||
|
@@ -74,8 +74,8 @@ class Root(NilmApp):
|
||||
dbsize = nilmdb.utils.du(path)
|
||||
return { "path": path,
|
||||
"size": dbsize,
|
||||
"other": usage.used - dbsize,
|
||||
"reserved": usage.total - usage.used - usage.free,
|
||||
"other": max(usage.used - dbsize, 0),
|
||||
"reserved": max(usage.total - usage.used - usage.free, 0),
|
||||
"free": usage.free }
|
||||
|
||||
class Stream(NilmApp):
|
||||
|
@@ -21,7 +21,8 @@ def du(path):
|
||||
errors that might occur if we encounter broken symlinks or
|
||||
files in the process of being removed."""
|
||||
try:
|
||||
size = os.path.getsize(path)
|
||||
st = os.stat(path)
|
||||
size = st.st_blocks * 512
|
||||
if os.path.isdir(path):
|
||||
for thisfile in os.listdir(path):
|
||||
filepath = os.path.join(path, thisfile)
|
||||
|
@@ -290,6 +290,7 @@ class TestCmdline(object):
|
||||
self.ok("create /newton/zzz/rawnotch uint16_9")
|
||||
self.ok("create /newton/prep float32_8")
|
||||
self.ok("create /newton/raw uint16_6")
|
||||
self.ok("create /newton/raw~decim-1234 uint16_6")
|
||||
|
||||
# Create a stream that already exists
|
||||
self.fail("create /newton/raw uint16_6")
|
||||
@@ -305,13 +306,23 @@ class TestCmdline(object):
|
||||
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
|
||||
# Verify we got those 4 streams and they're returned in
|
||||
# alphabetical order.
|
||||
self.ok("list -l")
|
||||
self.match("/newton/prep float32_8\n"
|
||||
"/newton/raw uint16_6\n"
|
||||
"/newton/raw~decim-1234 uint16_6\n"
|
||||
"/newton/zzz/rawnotch uint16_9\n")
|
||||
|
||||
# No decimated streams if -n specified
|
||||
self.ok("list -n -l")
|
||||
self.match("/newton/prep float32_8\n"
|
||||
"/newton/raw uint16_6\n"
|
||||
"/newton/zzz/rawnotch uint16_9\n")
|
||||
|
||||
# Delete that decimated stream
|
||||
self.ok("destroy /newton/raw~decim-1234")
|
||||
|
||||
# Match just one type or one path. Also check
|
||||
# that --path is optional
|
||||
self.ok("list --layout /newton/raw")
|
||||
|
Reference in New Issue
Block a user