resets.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright 2024 Google LLC
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from .. import PebbleCommander, exceptions, parsers
  15. @PebbleCommander.command()
  16. def reset(cmdr):
  17. """ Reset the device.
  18. """
  19. cmdr.send_prompt_command("reset")
  20. @PebbleCommander.command()
  21. def crash(cmdr):
  22. """ Crash the device.
  23. """
  24. cmdr.send_prompt_command("crash")
  25. @PebbleCommander.command()
  26. def factory_reset(cmdr, fast=False):
  27. """ Perform a factory reset.
  28. If `fast` is specified as true or "fast", do a fast factory reset.
  29. """
  30. if parsers.str2bool(fast, also_true=["fast"]):
  31. fast = " fast"
  32. else:
  33. fast = ""
  34. ret = cmdr.send_prompt_command("factory reset%s" % fast)
  35. if ret:
  36. raise exceptions.PromptResponseError(ret)