__init__.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  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. #
  15. import os
  16. def _load_source(name, path):
  17. try:
  18. from importlib.machinery import SourceFileLoader
  19. return SourceFileLoader(name, path).load_module()
  20. except ImportError:
  21. # importlib.machinery doesn't exists in Python 2 so we will use imp (deprecated in Python 3)
  22. import imp
  23. return imp.load_source(name, path)
  24. idf_path = os.environ['IDF_PATH']
  25. # protocomm component related python files generated from .proto files
  26. constants_pb2 = _load_source('constants_pb2', idf_path + '/components/protocomm/python/constants_pb2.py')
  27. sec0_pb2 = _load_source('sec0_pb2', idf_path + '/components/protocomm/python/sec0_pb2.py')
  28. sec1_pb2 = _load_source('sec1_pb2', idf_path + '/components/protocomm/python/sec1_pb2.py')
  29. session_pb2 = _load_source('session_pb2', idf_path + '/components/protocomm/python/session_pb2.py')
  30. # wifi_provisioning component related python files generated from .proto files
  31. wifi_constants_pb2 = _load_source('wifi_constants_pb2', idf_path + '/components/wifi_provisioning/python/wifi_constants_pb2.py')
  32. wifi_config_pb2 = _load_source('wifi_config_pb2', idf_path + '/components/wifi_provisioning/python/wifi_config_pb2.py')
  33. wifi_scan_pb2 = _load_source('wifi_scan_pb2', idf_path + '/components/wifi_provisioning/python/wifi_scan_pb2.py')
  34. # custom_provisioning component related python files generated from .proto files
  35. custom_config_pb2 = _load_source('custom_config_pb2', idf_path +
  36. '/examples/provisioning/legacy/custom_config/components/custom_provisioning/python/custom_config_pb2.py')