check_term.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2019 Espressif Systems (Shanghai) PTE LTD
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. from __future__ import print_function
  17. import os
  18. import sys
  19. if __name__ == '__main__':
  20. # Checks for the content of environment variable TERM to use with the Python- and curses-based menuconfig. It is
  21. # not implemented in shell so calling this script could not use some other shell environment where TERM is set
  22. # differently. Implemented here so it could be checked at one place for make and cmake as well.
  23. if sys.platform == 'win32' and 'MSYSTEM' not in os.environ:
  24. # no TERM is used in Windows command line
  25. exit(0)
  26. term = os.environ.get('TERM', None)
  27. if term is None:
  28. print('WARNING: The TERM environment variable is not defined. The curses-based menuconfig '
  29. 'will probably fail to run. Please consult the documentation of your terminal to set it up.')
  30. else:
  31. if term.endswith('256color'):
  32. print('TERM environment variable is set to "{}"'.format(term))
  33. else:
  34. print('WARNING: Menuconfig may fail because of the TERM environment variable is set '
  35. 'to "{}". Please consult the documentation of your terminal to set it up. '
  36. 'Some good, proved to been working setups include xterm-256color, screen-256color, '
  37. 'rxvt-unicode-256color.'.format(term))