mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/win_rename_delay' into 'master'
Tools: Use delay between rename attempts on Windows in the installer See merge request espressif/esp-idf!17047
This commit is contained in:
commit
60d7ea1f23
@ -44,6 +44,7 @@ import ssl
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
|
import time
|
||||||
from collections import OrderedDict, namedtuple
|
from collections import OrderedDict, namedtuple
|
||||||
from ssl import SSLContext # noqa: F401
|
from ssl import SSLContext # noqa: F401
|
||||||
from tarfile import TarFile # noqa: F401
|
from tarfile import TarFile # noqa: F401
|
||||||
@ -394,19 +395,19 @@ def download(url, destination): # type: (str, str) -> None
|
|||||||
# https://github.com/espressif/esp-idf/issues/4063#issuecomment-531490140
|
# https://github.com/espressif/esp-idf/issues/4063#issuecomment-531490140
|
||||||
# https://stackoverflow.com/a/43046729
|
# https://stackoverflow.com/a/43046729
|
||||||
def rename_with_retry(path_from, path_to): # type: (str, str) -> None
|
def rename_with_retry(path_from, path_to): # type: (str, str) -> None
|
||||||
if sys.platform.startswith('win'):
|
retry_count = 20 if sys.platform.startswith('win') else 1
|
||||||
retry_count = 100
|
|
||||||
else:
|
|
||||||
retry_count = 1
|
|
||||||
|
|
||||||
for retry in range(retry_count):
|
for retry in range(retry_count):
|
||||||
try:
|
try:
|
||||||
os.rename(path_from, path_to)
|
os.rename(path_from, path_to)
|
||||||
return
|
return
|
||||||
except (OSError, WindowsError): # WindowsError until Python 3.3, then OSError
|
except OSError:
|
||||||
|
msg = f'Rename {path_from} to {path_to} failed'
|
||||||
if retry == retry_count - 1:
|
if retry == retry_count - 1:
|
||||||
|
fatal(msg + '. Antivirus software might be causing this. Disabling it temporarily could solve the issue.')
|
||||||
raise
|
raise
|
||||||
warn('Rename {} to {} failed, retrying...'.format(path_from, path_to))
|
warn(msg + ', retrying...')
|
||||||
|
# Sleep before the next try in order to pass the antivirus check on Windows
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
|
||||||
def strip_container_dirs(path, levels): # type: (str, int) -> None
|
def strip_container_dirs(path, levels): # type: (str, int) -> None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user