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.

61 lines
2.0 KiB

  1. """QMK Python Doctor
  2. Check up for QMK environment.
  3. """
  4. import os
  5. import platform
  6. import shutil
  7. import subprocess
  8. from glob import glob
  9. from milc import cli
  10. @cli.entrypoint('Basic QMK environment checks')
  11. def main(cli):
  12. """Basic QMK environment checks.
  13. This is currently very simple, it just checks that all the expected binaries are on your system.
  14. TODO(unclaimed):
  15. * [ ] Compile a trivial program with each compiler
  16. * [ ] Check for udev entries on linux
  17. """
  18. binaries = ['dfu-programmer', 'avrdude', 'dfu-util', 'avr-gcc', 'arm-none-eabi-gcc']
  19. binaries += glob('bin/qmk-*')
  20. cli.log.info('QMK Doctor is checking your environment')
  21. ok = True
  22. for binary in binaries:
  23. res = shutil.which(binary)
  24. if res is None:
  25. cli.log.error("{fg_red}QMK can't find %s in your path", binary)
  26. ok = False
  27. else:
  28. try:
  29. subprocess.run([binary, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5, check=True)
  30. except subprocess.CalledProcessError:
  31. cli.log.error("{fg_red}Can't run `%s --version`", binary)
  32. ok = False
  33. OS = platform.system()
  34. if OS == "Darwin":
  35. cli.log.info("Detected {fg_cyan}macOS")
  36. elif OS == "Linux":
  37. cli.log.info("Detected {fg_cyan}linux")
  38. if shutil.which('systemctl'):
  39. test = 'systemctl list-unit-files | grep enabled | grep -i ModemManager'
  40. if os.system(test) == 0:
  41. cli.log.warn("{bg_yellow}Detected modem manager. Please disable it if you are using Pro Micros")
  42. else:
  43. cli.log.warn("Can't find systemctl to check for ModemManager.")
  44. else:
  45. cli.log.info("Assuming {fg_cyan}Windows")
  46. if ok:
  47. cli.log.info('{fg_green}QMK is ready to go')
  48. else:
  49. cli.log.info('{fg_yellow}Problems detected, please fix these problems before proceeding.')
  50. # FIXME(skullydazed): Link to a document about troubleshooting, or discord or something