diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Tools/Scripts/webkitpy/common/system/autoinstall.py | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Tools/Scripts/webkitpy/common/system/autoinstall.py')
-rw-r--r--[-rwxr-xr-x] | Tools/Scripts/webkitpy/common/system/autoinstall.py | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/Tools/Scripts/webkitpy/common/system/autoinstall.py b/Tools/Scripts/webkitpy/common/system/autoinstall.py index 9d1f8cb2f..2e15887bb 100755..100644 --- a/Tools/Scripts/webkitpy/common/system/autoinstall.py +++ b/Tools/Scripts/webkitpy/common/system/autoinstall.py @@ -35,10 +35,11 @@ import codecs import logging import os import shutil +import stat import sys import tarfile import tempfile -import urllib +import urllib2 import urlparse import zipfile @@ -173,7 +174,7 @@ class AutoInstaller(object): return scratch_dir def _url_downloaded_path(self, target_name): - return os.path.join(self._target_dir, ".%s.url" % target_name) + return os.path.join(self._target_dir, ".%s.url" % target_name.replace('/', '_')) def _is_downloaded(self, target_name, url): version_path = self._url_downloaded_path(target_name) @@ -283,17 +284,27 @@ class AutoInstaller(object): return new_path def _download_to_stream(self, url, stream): - try: - netstream = urllib.urlopen(url) - except IOError, err: - # Append existing Error message to new Error. - message = ('Could not download Python modules from URL "%s".\n' - " Make sure you are connected to the internet.\n" - " You must be connected to the internet when " - "downloading needed modules for the first time.\n" - " --> Inner message: %s" - % (url, err)) - raise IOError(message) + failures = 0 + while True: + try: + netstream = urllib2.urlopen(url) + break + except IOError, err: + # Try multiple times + if failures < 5: + _log.warning("Failed to download %s, %s retrying" % ( + url, err)) + failures += 1 + continue + + # Append existing Error message to new Error. + message = ('Could not download Python modules from URL "%s".\n' + " Make sure you are connected to the internet.\n" + " You must be connected to the internet when " + "downloading needed modules for the first time.\n" + " --> Inner message: %s" + % (url, err)) + raise IOError(message) code = 200 if hasattr(netstream, "getcode"): code = netstream.getcode() @@ -319,8 +330,7 @@ class AutoInstaller(object): return target_path - def _install(self, scratch_dir, package_name, target_path, url, - url_subpath): + def _install(self, scratch_dir, package_name, target_path, url, url_subpath, files_to_remove): """Install a python package from an URL. This internal method overwrites the target path if the target @@ -335,6 +345,13 @@ class AutoInstaller(object): else: source_path = os.path.join(path, url_subpath) + for filename in files_to_remove: + path = os.path.join(source_path, filename.replace('/', os.sep)) + if os.path.exists(path): + # Pre-emptively change the permissions to #0777 to try and work around win32 permissions issues. + os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) + os.remove(path) + if os.path.exists(target_path): if os.path.isdir(target_path): shutil.rmtree(target_path, ignore_errors=True) @@ -354,7 +371,7 @@ class AutoInstaller(object): self._record_url_downloaded(package_name, url) def install(self, url, should_refresh=False, target_name=None, - url_subpath=None): + url_subpath=None, files_to_remove=None): """Install a python package from an URL. Args: @@ -382,10 +399,11 @@ class AutoInstaller(object): url_subpath = os.path.normpath(url_subpath) target_name = os.path.basename(url_subpath) - target_path = os.path.join(self._target_dir, target_name) + target_path = os.path.join(self._target_dir, target_name.replace('/', os.sep)) if not should_refresh and self._is_downloaded(target_name, url): return False + files_to_remove = files_to_remove or [] package_name = target_name.replace(os.sep, '.') _log.info("Auto-installing package: %s" % package_name) @@ -399,7 +417,8 @@ class AutoInstaller(object): target_path=target_path, scratch_dir=scratch_dir, url=url, - url_subpath=url_subpath) + url_subpath=url_subpath, + files_to_remove=files_to_remove) except Exception, err: # Append existing Error message to new Error. message = ("Error auto-installing the %s package to:\n" |