Jim Paris
3f436e6dfd
Misc cleanups More work on tests to get more coverage git-svn-id: https://bucket.mit.edu/svn/nilm/nilmdb@10869 ddd99763-3ecb-0310-9145-efcb8ce7c51f
33 lines
874 B
Python
Executable File
33 lines
874 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
import nilmdb
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description='Run the NILM server')
|
|
parser.add_argument('-p', '--port', help='Port number', type=int, default=12380)
|
|
parser.add_argument('-y', '--yappi', help='Run with yappi profiler',
|
|
action='store_true')
|
|
args = parser.parse_args()
|
|
|
|
# Start web app on a custom port
|
|
db = nilmdb.NilmDB("db")
|
|
server = nilmdb.Server(db, host = "127.0.0.1",
|
|
port = args.port,
|
|
embedded = False)
|
|
|
|
|
|
if args.yappi:
|
|
print "Running in yappi"
|
|
try:
|
|
import yappi
|
|
yappi.start()
|
|
server.start(blocking = True)
|
|
finally:
|
|
yappi.stop()
|
|
print "Try: yappi.print_stats(sort_type=yappi.SORTTYPE_TTOT,limit=50)"
|
|
from IPython import embed
|
|
embed()
|
|
else:
|
|
server.start(blocking = True)
|
|
db.close()
|