1#!/usr/bin/env python 2# 3# SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton, 4# Espressif Systems (Shanghai) CO LTD, other contributors as noted. 5# 6# SPDX-License-Identifier: GPL-2.0-or-later 7 8# This executable script is a thin wrapper around the main functionality 9# in the espsecure Python package 10 11# When updating this script, please also update esptool.py and espefuse.py 12 13import contextlib 14import os 15import sys 16 17if os.name != "nt": 18 # Linux/macOS: remove current script directory to avoid importing this file 19 # as a module; we want to import the installed espsecure module instead 20 with contextlib.suppress(ValueError): 21 executable_dir = os.path.dirname(sys.executable) 22 sys.path = [ 23 path 24 for path in sys.path 25 if not path.endswith(("/bin", "/sbin")) and path != executable_dir 26 ] 27 28 # Linux/macOS: delete imported module entry to force Python to load 29 # the module from scratch; this enables importing espsecure module in 30 # other Python scripts 31 with contextlib.suppress(KeyError): 32 del sys.modules["espsecure"] 33 34import espsecure 35 36if __name__ == "__main__": 37 espsecure._main() 38