From 173e6aab3e7bda0de7c2c2eedfa7d1e98a29c896 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Tue, 18 Sep 2018 14:43:23 +0200 Subject: [PATCH] tools: Make kconfig_new Python3-compatible and enable Python3 in idf.py --- .gitlab-ci.yml | 2 +- tools/ci/executable-list.txt | 3 --- tools/idf.py | 4 +++- tools/kconfig_new/confgen.py | 1 + tools/kconfig_new/gen_kconfig_doc.py | 1 + tools/kconfig_new/test/test_confserver.py | 10 ++++++---- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f6d863d0..2a943956f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -389,7 +389,7 @@ test_confserver: <<: *host_test_template script: - cd tools/kconfig_new/test - - ./test_confserver.py + - ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh ./test_confserver.py test_build_system: <<: *host_test_template diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 24e22f4b2..89c03a120 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -43,9 +43,6 @@ tools/kconfig/lxdialog/check-lxdialog.sh tools/kconfig/mconf tools/kconfig/merge_config.sh tools/kconfig/streamline_config.pl -tools/kconfig_new/confgen.py -tools/kconfig_new/confserver.py -tools/kconfig_new/test/test_confserver.py tools/mass_mfg/mfg_gen.py tools/test_idf_monitor/run_test_idf_monitor.py tools/unit-test-app/unit_test.py diff --git a/tools/idf.py b/tools/idf.py index d68834a45..1d2f128ec 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -430,7 +430,9 @@ def get_default_serial_port(): def main(): if sys.version_info[0] != 2 or sys.version_info[1] != 7: - raise FatalError("ESP-IDF currently only supports Python 2.7, and this is Python %d.%d.%d. Search for 'Setting the Python Interpreter' in the ESP-IDF docs for some tips to handle this." % sys.version_info[:3]) + print("Note: You are using Python %d.%d.%d. Python 3 support is new, please report any problems " + "you encounter. Search for 'Setting the Python Interpreter' in the ESP-IDF docs if you want to use " + "Python 2.7." % sys.version_info[:3]) parser = argparse.ArgumentParser(description='ESP-IDF build management tool') parser.add_argument('-p', '--port', help="Serial port", diff --git a/tools/kconfig_new/confgen.py b/tools/kconfig_new/confgen.py index 416c28d88..0d88b8489 100755 --- a/tools/kconfig_new/confgen.py +++ b/tools/kconfig_new/confgen.py @@ -20,6 +20,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function import argparse import sys import os diff --git a/tools/kconfig_new/gen_kconfig_doc.py b/tools/kconfig_new/gen_kconfig_doc.py index e5e6968f1..b43106ff3 100644 --- a/tools/kconfig_new/gen_kconfig_doc.py +++ b/tools/kconfig_new/gen_kconfig_doc.py @@ -20,6 +20,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function import os import kconfiglib diff --git a/tools/kconfig_new/test/test_confserver.py b/tools/kconfig_new/test/test_confserver.py index 3ce25158b..222cc4543 100755 --- a/tools/kconfig_new/test/test_confserver.py +++ b/tools/kconfig_new/test/test_confserver.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import print_function import os import sys import threading @@ -6,6 +7,7 @@ import time import json import argparse import shutil +import tempfile import pexpect @@ -45,10 +47,10 @@ def main(): parser.add_argument('--logfile', type=argparse.FileType('w'), help='Optional session log of the interactions with confserver.py') args = parser.parse_args() - # set up temporary file to use as sdkconfig copy - temp_sdkconfig_path = os.tmpnam() try: - with open(temp_sdkconfig_path, "w") as temp_sdkconfig: + # set up temporary file to use as sdkconfig copy + with tempfile.NamedTemporaryFile(mode="w", delete=False) as temp_sdkconfig: + temp_sdkconfig_path = os.path.join(tempfile.gettempdir(), temp_sdkconfig.name) with open("sdkconfig") as orig: temp_sdkconfig.write(orig.read()) @@ -61,7 +63,7 @@ def main(): def expect_json(): # run p.expect() to expect a json object back, and return it as parsed JSON p.expect("{.+}\r\n") - return json.loads(p.match.group(0).strip()) + return json.loads(p.match.group(0).strip().decode()) p.expect("Server running.+\r\n") initial = expect_json()