|
- from nilmdb.utils.printf import *
- import nilmdb.client
-
- from argparse import ArgumentDefaultsHelpFormatter as def_form
-
- def setup(self, sub):
- cmd = sub.add_parser("destroy", help="Delete a stream and all data",
- formatter_class = def_form,
- description="""
- Destroy the stream at the specified path.
- The stream must be empty. All metadata
- related to the stream is permanently deleted.
- """)
- cmd.set_defaults(handler = cmd_destroy)
- group = cmd.add_argument_group("Options")
- group.add_argument("-R", "--remove", action="store_true",
- help="Remove all data before destroying stream")
- group = cmd.add_argument_group("Required arguments")
- group.add_argument("path",
- help="Path of the stream to delete, e.g. /foo/bar",
- ).completer = self.complete.path
- return cmd
-
- def cmd_destroy(self):
- """Destroy stream"""
- if self.args.remove:
- try:
- count = self.client.stream_remove(self.args.path)
- except nilmdb.client.ClientError as e:
- self.die("error removing data: %s", str(e))
- try:
- self.client.stream_destroy(self.args.path)
- except nilmdb.client.ClientError as e:
- self.die("error destroying stream: %s", str(e))
|