Tools: idf_tools.py prints URL before starting the download

This helps users with poor Internet connection to be able to cancel the
download and download it in another way.

Closes https://github.com/espressif/esp-idf/issues/8625
This commit is contained in:
Roland Dobai
2022-03-30 08:11:18 +02:00
parent f8dad892ff
commit c3c2b03ed4
2 changed files with 10 additions and 8 deletions

View File

@@ -365,7 +365,8 @@ def urlretrieve_ctx(url, filename, reporthook=None, data=None, context=None):
def download(url, destination): # type: (str, str) -> None def download(url, destination): # type: (str, str) -> None
info('Downloading {} to {}'.format(os.path.basename(url), destination)) info(f'Downloading {url}')
info(f'Destination: {destination}')
try: try:
ctx = None ctx = None
# For dl.espressif.com, add the ISRG x1 root certificate. # For dl.espressif.com, add the ISRG x1 root certificate.

View File

@@ -5,6 +5,7 @@
import json import json
import os import os
import re
import shutil import shutil
import sys import sys
import tempfile import tempfile
@@ -112,13 +113,13 @@ class TestUsage(unittest.TestCase):
if tool_archive_name is None: if tool_archive_name is None:
tool_archive_name = tool tool_archive_name = tool
self.assertIn('Installing %s@' % tool + tool_version, output) self.assertIn('Installing %s@' % tool + tool_version, output)
self.assertIn('Downloading %s' % tool_archive_name, output) self.assertRegex(output, re.compile(rf'Downloading \S+/{tool_archive_name}'))
def assert_tool_not_installed(self, output, tool, tool_version, tool_archive_name=None): def assert_tool_not_installed(self, output, tool, tool_version, tool_archive_name=None):
if tool_archive_name is None: if tool_archive_name is None:
tool_archive_name = tool tool_archive_name = tool
self.assertNotIn('Installing %s@' % tool + tool_version, output) self.assertNotIn('Installing %s@' % tool + tool_version, output)
self.assertNotIn('Downloading %s' % tool_archive_name, output) self.assertNotRegex(output, re.compile(rf'Downloading \S+/{tool_archive_name}'))
def run_idf_tools_with_action(self, action): def run_idf_tools_with_action(self, action):
output_stream = StringIO() output_stream = StringIO()
@@ -153,7 +154,7 @@ class TestUsage(unittest.TestCase):
self.assert_tool_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION) self.assert_tool_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE) self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE) self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output) self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done')) self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check']) output = self.run_idf_tools_with_action(['check'])
@@ -191,7 +192,7 @@ class TestUsage(unittest.TestCase):
self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION) self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION) self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE) self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output) self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done')) self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check']) output = self.run_idf_tools_with_action(['check'])
@@ -225,7 +226,7 @@ class TestUsage(unittest.TestCase):
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION) self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE) self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE) self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output) self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done')) self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check']) output = self.run_idf_tools_with_action(['check'])
@@ -258,7 +259,7 @@ class TestUsage(unittest.TestCase):
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION) self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE) self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE) self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output) self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done')) self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check']) output = self.run_idf_tools_with_action(['check'])
@@ -292,7 +293,7 @@ class TestUsage(unittest.TestCase):
self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION) self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE) self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE) self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output) self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done')) self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check']) output = self.run_idf_tools_with_action(['check'])