Merge branch 'bugfix/server_down_message_v4.0' into 'release/v4.0'

tools: Produce user friendly error during install when the server is down (v4.0)

See merge request espressif/esp-idf!6958
This commit is contained in:
Angus Gratton 2019-12-12 08:12:36 +08:00
commit 0104a24a36

View File

@ -565,11 +565,16 @@ class IDFTool(object):
for retry in range(DOWNLOAD_RETRY_COUNT):
local_temp_path = local_path + '.tmp'
info('Downloading {} to {}'.format(archive_name, local_temp_path))
urlretrieve(url, local_temp_path, report_progress if not global_non_interactive else None)
sys.stdout.write("\rDone\n")
try:
urlretrieve(url, local_temp_path, report_progress if not global_non_interactive else None)
sys.stdout.write("\rDone\n")
except Exception as e:
# urlretrieve could throw different exceptions, e.g. IOError when the server is down
# Errors are ignored because the downloaded file is checked a couple of lines later.
warn('Download failure {}'.format(e))
sys.stdout.flush()
if not self.check_download_file(download_obj, local_temp_path):
warn('Failed to download file {}'.format(local_temp_path))
if not os.path.isfile(local_temp_path) or not self.check_download_file(download_obj, local_temp_path):
warn('Failed to download {} to {}'.format(url, local_temp_path))
continue
rename_with_retry(local_temp_path, local_path)
downloaded = True