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.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. group.add_argument("layout",
  21. help="Layout type for new stream, e.g. float32_8")
  22. return cmd
  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))