Browse Source

Fix nilmdb-server argument parsing, logging, and profiling

It works again now.
tags/nilmdb-2.0.0
Jim Paris 1 year ago
parent
commit
ca440a42bd
2 changed files with 15 additions and 7 deletions
  1. +3
    -2
      nilmdb/scripts/nilmdb_fsck.py
  2. +12
    -5
      nilmdb/scripts/nilmdb_server.py

+ 3
- 2
nilmdb/scripts/nilmdb_fsck.py View File

@@ -10,8 +10,9 @@ def main():

parser = argparse.ArgumentParser(
description = 'Check database consistency',
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
version = nilmdb.__version__)
formatter_class = argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-v", "--version", action="version",
version = nilmdb.__version__)
parser.add_argument("-f", "--fix", action="store_true",
default=False, help = 'Fix errors when possible '
'(which may involve removing data)')


+ 12
- 5
nilmdb/scripts/nilmdb_server.py View File

@@ -4,14 +4,17 @@ import nilmdb.server
import argparse
import os
import socket
import cherrypy

def main():
"""Main entry point for the 'nilmdb-server' command line script"""

parser = argparse.ArgumentParser(
description = 'Run the NilmDB server',
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
version = nilmdb.__version__)
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',
@@ -39,6 +42,8 @@ def main():
db = nilmdb.utils.serializer_proxy(nilmdb.server.NilmDB)(args.database)

# Configure the server
if not args.quiet:
cherrypy._cpconfig.environments['embedded']['log.screen'] = True
server = nilmdb.server.Server(db,
host = args.address,
port = args.port,
@@ -64,10 +69,12 @@ def main():
server.start(blocking = True)
finally:
yappi.stop()
yappi.print_stats(sort_type = yappi.SORTTYPE_TTOT, limit = 50)
stats = yappi.get_func_stats()
stats.sort("ttot")
stats.print_all()
from IPython import embed
embed(header = "Use the yappi object to explore further, "
"quit to exit")
embed(header = "Use the `yappi` or `stats` object to explore "
"further, quit to exit")
else:
server.start(blocking = True)



Loading…
Cancel
Save