|
- import nilmdb.client
- from nilmdb.utils.printf import *
- from nilmdb.utils import human_size
-
- from argparse import ArgumentDefaultsHelpFormatter as def_form
-
- def setup(self, sub):
- cmd = sub.add_parser("info", help="Server information",
- formatter_class = def_form,
- description="""
- List information about the server, like
- version.
- """)
- cmd.set_defaults(handler = cmd_info)
- return cmd
-
- def cmd_info(self):
- """Print info about the server"""
- printf("Client version: %s\n", nilmdb.__version__)
- printf("Server version: %s\n", self.client.version())
- printf("Server URL: %s\n", self.client.geturl())
- dbinfo = self.client.dbinfo()
- printf("Server database path: %s\n", dbinfo["path"])
- printf("Server database size: %s\n", human_size(dbinfo["size"]))
- printf("Server database free space: %s\n", human_size(dbinfo["free"]))
|