aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/bootstrap.py
diff options
context:
space:
mode:
authorLearning <liangyongning@gmail.com>2019-01-19 22:27:16 +0800
committerLearning <liangyongning@gmail.com>2019-01-21 23:21:48 +0800
commit9c1683bcef9cb09e76c542bc0cc9340eed8cd47a (patch)
tree1a6c6b21103133cfac2892df8631ab5db40ef593 /python/servo/bootstrap.py
parent7256d123ff9620ff1acc494888989c43b176ecee (diff)
downloadservo-9c1683bcef9cb09e76c542bc0cc9340eed8cd47a.tar.gz
servo-9c1683bcef9cb09e76c542bc0cc9340eed8cd47a.zip
Fix BadZipfile error while install msvc dependencies
Diffstat (limited to 'python/servo/bootstrap.py')
-rw-r--r--python/servo/bootstrap.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/python/servo/bootstrap.py b/python/servo/bootstrap.py
index 4f9744a7c17..1c49ab67185 100644
--- a/python/servo/bootstrap.py
+++ b/python/servo/bootstrap.py
@@ -12,6 +12,7 @@ import platform
import shutil
import subprocess
from subprocess import PIPE
+from zipfile import BadZipfile
import servo.packages as packages
from servo.util import extract, download_file, host_triple
@@ -300,6 +301,21 @@ def windows_msvc(context, force=False):
return True
return False
+ def prepare_file(zip_path, full_spec):
+ if not os.path.isfile(zip_path):
+ zip_url = "{}{}.zip".format(deps_url, full_spec)
+ download_file(full_spec, zip_url, zip_path)
+
+ print("Extracting {}...".format(full_spec), end='')
+ try:
+ extract(zip_path, deps_dir)
+ except BadZipfile:
+ print("\nError: %s.zip is not a valid zip file, redownload..." % full_spec)
+ os.remove(zip_path)
+ prepare_file(zip_path, full_spec)
+ else:
+ print("done")
+
to_install = {}
for package in packages.WINDOWS_MSVC:
# Don't install CMake if it already exists in PATH
@@ -321,13 +337,7 @@ def windows_msvc(context, force=False):
os.makedirs(parent_dir)
zip_path = package_dir(package) + ".zip"
- if not os.path.isfile(zip_path):
- zip_url = "{}{}.zip".format(deps_url, full_spec)
- download_file(full_spec, zip_url, zip_path)
-
- print("Extracting {}...".format(full_spec), end='')
- extract(zip_path, deps_dir)
- print("done")
+ prepare_file(zip_path, full_spec)
extracted_path = os.path.join(deps_dir, full_spec)
os.rename(extracted_path, package_dir(package))