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.
 
 
 

36 lines
1.2 KiB

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