check_term.py 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python
  2. #
  3. # SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
  4. # SPDX-License-Identifier: Apache-2.0
  5. from __future__ import print_function
  6. import os
  7. import sys
  8. if __name__ == '__main__':
  9. # Checks for the content of environment variable TERM to use with the Python- and curses-based menuconfig. It is
  10. # not implemented in shell so calling this script could not use some other shell environment where TERM is set
  11. # differently. Implemented here so it could be checked at one place for make and cmake as well.
  12. if sys.platform == 'win32' and 'MSYSTEM' not in os.environ:
  13. # no TERM is used in Windows command line
  14. exit(0)
  15. term = os.environ.get('TERM', None)
  16. if term is None:
  17. print('WARNING: The TERM environment variable is not defined. The curses-based menuconfig '
  18. 'will probably fail to run. Please consult the documentation of your terminal to set it up.')
  19. else:
  20. if term.endswith('256color') or term in ['alacritty']:
  21. print('TERM environment variable is set to "{}"'.format(term))
  22. else:
  23. print('WARNING: Menuconfig may fail because of the TERM environment variable is set '
  24. 'to "{}". Please consult the documentation of your terminal to set it up. '
  25. 'Some good, proved to been working setups include xterm-256color, screen-256color, '
  26. 'rxvt-unicode-256color, alacritty.'.format(term))