__init__.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import logging
  2. import pebble_tool
  3. from libpebble2.communication.transports.pulse import PULSETransport
  4. from libpebble2.exceptions import PebbleError
  5. from commands import coredump
  6. from commands import install_lang
  7. from commands import test
  8. # TODO: unopened logging ports cause super noisy logs, fix this in the
  9. # pulse package then remove this
  10. logging.getLogger('pebble.pulse2.transports').setLevel(logging.ERROR)
  11. class PebbleTransportPULSE(pebble_tool.commands.base.PebbleTransportConfiguration):
  12. transport_class = PULSETransport
  13. name = 'pulse'
  14. @classmethod
  15. def _connect_args(cls, args):
  16. try:
  17. from pebble import pulse2
  18. except ImportError:
  19. raise PebbleError('pulse2 package not installed: it is required for PULSE transport')
  20. url, = super(PebbleTransportPULSE, cls)._connect_args(args)
  21. interface = pulse2.Interface.open_dbgserial(url=url)
  22. link = interface.get_link()
  23. return (link,)
  24. @classmethod
  25. def add_argument_handler(cls, parser):
  26. parser.add_argument('--pulse', type=str,
  27. help="Use this option to connect to your Pebble via"
  28. " the PULSE transport. Equivalent to PEBBLE_PULSE.")
  29. def run_tool(args=None):
  30. pebble_tool.run_tool(args)