You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
1.3 KiB

  1. from nilmdb.utils.printf import *
  2. import nilmdb.client
  3. from argparse import RawDescriptionHelpFormatter as raw_form
  4. def setup(self, sub):
  5. cmd = sub.add_parser("create", help="Create a new stream",
  6. formatter_class = raw_form,
  7. description="""
  8. Create a new empty stream at the specified path and with the specified
  9. layout type.
  10. Layout types are of the format: type_count
  11. 'type' is a data type like 'float32', 'float64', 'uint16', 'int32', etc.
  12. 'count' is the number of columns of this type.
  13. For example, 'float32_8' means the data for this stream has 8 columns of
  14. 32-bit floating point values.
  15. """)
  16. cmd.set_defaults(handler = cmd_create)
  17. group = cmd.add_argument_group("Required arguments")
  18. group.add_argument("path",
  19. help="Path (in database) of new stream, e.g. /foo/bar",
  20. ).completer = self.complete.path
  21. group.add_argument("layout",
  22. help="Layout type for new stream, e.g. float32_8",
  23. ).completer = self.complete.layout
  24. return cmd
  25. def cmd_create(self):
  26. """Create new stream"""
  27. try:
  28. self.client.stream_create(self.args.path, self.args.layout)
  29. except nilmdb.client.ClientError as e:
  30. self.die("error creating stream: %s", str(e))