Browse Source

work on command line

git-svn-id: https://bucket.mit.edu/svn/nilm/nilmdb@10673 ddd99763-3ecb-0310-9145-efcb8ce7c51f
tags/bxinterval-last
Jim Paris 10 years ago
parent
commit
b4a0288a39
4 changed files with 20 additions and 7 deletions
  1. +4
    -1
      Makefile
  2. +8
    -0
      nilmdb/cmdline.py
  3. +5
    -2
      nilmdb/server.py
  4. +3
    -4
      runserver.py

+ 4
- 1
Makefile View File

@@ -1,4 +1,7 @@
all: test
all: tool

tool:
python nilmtool.py --help

lint:
pylint -f parseable nilmdb


+ 8
- 0
nilmdb/cmdline.py View File

@@ -19,12 +19,20 @@ def parse_opts(args):
version="nilmdb client script %prog " + version)
parser.add_option("-q", "--quiet", action="store_true", default=False,
dest="quiet", help="suppress unnecessary console output")

group = OptionGroup(parser, "Server")
group.add_option("-u", "--url", action="store", dest="url",
default="http://localhost:12380/",
help="NilmDB server URL (default: %default)")
parser.add_option_group(group)

group = OptionGroup(parser, "Stream Operations")
group.add_option("-l", "--list", action="store_true", default=False,
action="store", dest="url",
default="http://localhost:12380/",
help="NilmDB server URL (default: %default)")
parser.add_option_group(group)

(opt, rest) = parser.parse_args(args)

return (opt, rest)


+ 5
- 2
nilmdb/server.py View File

@@ -189,8 +189,11 @@ class Server(object):
version = "1.0"
def __init__(self, db, host = '127.0.0.1', port = 8080,
stoppable = False, embedded = True,
fast_shutdown = False, force_traceback = False):
stoppable = False, # whether /exit URL exists
embedded = True, # hide diagnostics and output, etc
fast_shutdown = False, # don't wait for clients to disconn.
force_traceback = False # include traceback in all errors
):
# Need to wrap DB object in a serializer because we'll call
# into it from separate threads.
self.embedded = embedded


+ 3
- 4
runserver.py View File

@@ -3,11 +3,10 @@
import nilmdb
import json

testdb = "tests/testdb"

# Start web app on a custom port
db = nilmdb.NilmDB(testdb)
db = nilmdb.NilmDB("db")
server = nilmdb.Server(db, host = "127.0.0.1",
port = 12381, stoppable = False, embedded = False)
port = 12380,
embedded = False)
server.start(blocking = True)
db.close()

Loading…
Cancel
Save