Browse Source

Switch to versioneer-provided versions everywhere

tags/nilmdb-1.0^0
Jim Paris 9 years ago
parent
commit
1593e181a3
9 changed files with 17 additions and 24 deletions
  1. +1
    -1
      .coveragerc
  2. +1
    -1
      nilmdb/__init__.py
  3. +0
    -4
      nilmdb/client/client.py
  4. +1
    -6
      nilmdb/cmdline/cmdline.py
  5. +2
    -1
      nilmdb/cmdline/info.py
  6. +3
    -0
      nilmdb/scripts/nilmdb_server.py
  7. +5
    -7
      nilmdb/server/server.py
  8. +2
    -2
      tests/test_client.py
  9. +2
    -2
      tests/test_nilmdb.py

+ 1
- 1
.coveragerc View File

@@ -7,4 +7,4 @@
exclude_lines =
pragma: no cover
if 0:
omit = nilmdb/utils/datetime_tz*,nilmdb/scripts
omit = nilmdb/utils/datetime_tz*,nilmdb/scripts,nilmdb/_version.py

+ 1
- 1
nilmdb/__init__.py View File

@@ -3,6 +3,6 @@
from nilmdb.server import NilmDB, Server
from nilmdb.client import Client

from ._version import get_versions
from nilmdb._version import get_versions
__version__ = get_versions()['version']
del get_versions

+ 0
- 4
nilmdb/client/client.py View File

@@ -9,8 +9,6 @@ import nilmdb.client.httpclient
import time
import simplejson as json

version = "1.0"

def float_to_string(f):
"""Use repr to maintain full precision in the string output."""
return repr(float(f))
@@ -18,8 +16,6 @@ def float_to_string(f):
class Client(object):
"""Main client interface to the Nilm database."""

client_version = version

def __init__(self, url):
self.http = nilmdb.client.httpclient.HTTPClient(url)



+ 1
- 6
nilmdb/cmdline/cmdline.py View File

@@ -9,8 +9,6 @@ import re
import argparse
from argparse import ArgumentDefaultsHelpFormatter as def_form

version = "1.0"

# Valid subcommands. Defined in separate files just to break
# things up -- they're still called with Cmdline as self.
subcommands = [ "info", "create", "list", "metadata", "insert", "extract",
@@ -93,9 +91,6 @@ class Cmdline(object):
return dt.strftime("%a, %d %b %Y %H:%M:%S.%f %z")

def parser_setup(self):
version_string = sprintf("nilmtool %s, client library %s",
version, nilmdb.Client.client_version)

self.parser = JimArgumentParser(add_help = False,
formatter_class = def_form)

@@ -103,7 +98,7 @@ class Cmdline(object):
group.add_argument("-h", "--help", action='help',
help='show this help message and exit')
group.add_argument("-V", "--version", action="version",
version=version_string)
version = nilmdb.__version__)

group = self.parser.add_argument_group("Server")
group.add_argument("-u", "--url", action="store",


+ 2
- 1
nilmdb/cmdline/info.py View File

@@ -1,3 +1,4 @@
import nilmdb
from nilmdb.utils.printf import *

from argparse import ArgumentDefaultsHelpFormatter as def_form
@@ -13,7 +14,7 @@ def setup(self, sub):

def cmd_info(self):
"""Print info about the server"""
printf("Client library version: %s\n", self.client.client_version)
printf("Client version: %s\n", nilmdb.__version__)
printf("Server version: %s\n", self.client.version())
printf("Server URL: %s\n", self.client.geturl())
printf("Server database path: %s\n", self.client.dbpath())


+ 3
- 0
nilmdb/scripts/nilmdb_server.py View File

@@ -12,6 +12,9 @@ def main():
description = 'Run the NilmDB server',
formatter_class = argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument("-V", "--version", action="version",
version = nilmdb.__version__)

group = parser.add_argument_group("Standard options")
group.add_argument('-a', '--address',
help = 'Only listen on the given address',


+ 5
- 7
nilmdb/server/server.py View File

@@ -24,8 +24,6 @@ class NilmApp(object):
def __init__(self, db):
self.db = db

version = "1.2"

# Decorators
def chunked_response(func):
"""Decorator to enable chunked responses."""
@@ -82,9 +80,8 @@ def exception_to_httperror(*expected):
class Root(NilmApp):
"""Root application for NILM database"""

def __init__(self, db, sversion):
def __init__(self, db):
super(Root, self).__init__(db)
self.server_version = sversion

# /
@cherrypy.expose
@@ -100,7 +97,7 @@ class Root(NilmApp):
@cherrypy.expose
@cherrypy.tools.json_out()
def version(self):
return self.server_version
return nilmdb.__version__

# /dbpath
@cherrypy.expose
@@ -385,7 +382,8 @@ class Server(object):
fast_shutdown = False, # don't wait for clients to disconn.
force_traceback = False # include traceback in all errors
):
self.version = version
# Save server version, just for verification during tests
self.version = nilmdb.__version__

# Need to wrap DB object in a serializer because we'll call
# into it from separate threads.
@@ -425,7 +423,7 @@ class Server(object):
cherrypy._cperror._ie_friendly_error_sizes = {}

# Build up the application and mount it
root = Root(self.db, self.version)
root = Root(self.db)
root.stream = Stream(self.db)
if stoppable:
root.exit = Exiter()


+ 2
- 2
tests/test_client.py View File

@@ -67,8 +67,8 @@ class TestClient(object):
# Now use the real URL
client = nilmdb.Client(url = "http://localhost:12380/")
version = client.version()
eq_(distutils.version.StrictVersion(version),
distutils.version.StrictVersion(test_server.version))
eq_(distutils.version.LooseVersion(version),
distutils.version.LooseVersion(test_server.version))

# Bad URLs should give 404, not 500
with assert_raises(ClientError):


+ 2
- 2
tests/test_nilmdb.py View File

@@ -151,8 +151,8 @@ class TestServer(object):
eq_(e.exception.code, 404)

# Check version
eq_(distutils.version.StrictVersion(getjson("/version")),
distutils.version.StrictVersion(self.server.version))
eq_(distutils.version.LooseVersion(getjson("/version")),
distutils.version.LooseVersion(nilmdb.__version__))

def test_stream_list(self):
# Known streams that got populated by an earlier test (test_nilmdb)


Loading…
Cancel
Save