diff --git a/release-tools/bld_ifw_tools_impl.py b/release-tools/bld_ifw_tools_impl.py index e1c401b4f7b20712f4b23083778b1f14a0263bc9..b02c12111445af77d8a3c5a9553179de80e59dc3 100644 --- a/release-tools/bld_ifw_tools_impl.py +++ b/release-tools/bld_ifw_tools_impl.py @@ -165,8 +165,7 @@ def prepare_qt_sources(): if not bldinstallercommon.is_content_url_valid(QT_SRC_PACKAGE_URL): print '*** Qt src package url is invalid! Abort!' sys.exit(-1) - urllib.urlcleanup() - urllib.urlretrieve(QT_SRC_PACKAGE_URL, QT_SRC_PACKAGE_URL_SAVE_AS) + bldinstallercommon.retrieve_url(QT_SRC_PACKAGE_URL, QT_SRC_PACKAGE_URL_SAVE_AS) else: print 'Found old local package, using that: ' + QT_SRC_PACKAGE_URL_SAVE_AS print 'Done' diff --git a/release-tools/bldinstallercommon.py b/release-tools/bldinstallercommon.py index 39227db49fd63d597ba696fa5abf2574845847db..9ca0e642f22c5f989828185abe849b4fb47a63f5 100644 --- a/release-tools/bldinstallercommon.py +++ b/release-tools/bldinstallercommon.py @@ -51,6 +51,7 @@ from subprocess import PIPE, STDOUT import sys import stat import tarfile +import urllib import urllib2 import zipfile import string @@ -120,6 +121,24 @@ def dlProgress(count, blockSize, totalSize): print '\n' +############################### +# function +############################### +def retrieve_url(url, savefile): + try: + savefile_tmp = savefile + '.tmp' + urllib.urlcleanup() + urllib.urlretrieve(url, savefile_tmp, reporthook=dlProgress) + os.rename(savefile_tmp, savefile) + except: + exc = sys.exc_info()[0] + print exc + try: + os.remove(savefile_tmp) + except: #swallow, do not shadow actual error + pass + raise exc + ############################### # function ############################### diff --git a/release-tools/create_installer.py b/release-tools/create_installer.py index 94ff62d359b269ad3a53ed523a86fdd356f29ea6..8a9debf357ea44171066a9d7fa35deb8dafb604a 100644 --- a/release-tools/create_installer.py +++ b/release-tools/create_installer.py @@ -663,8 +663,7 @@ def handle_archive(sdk_component, archive): print ' Downloading: ' + archive.archive_uri print ' into: ' + package_save_as_temp # start download - urllib.urlcleanup() - urllib.urlretrieve(archive.archive_uri, package_save_as_temp, reporthook=bldinstallercommon.dlProgress) + bldinstallercommon.retrieve_url(archive.archive_uri, package_save_as_temp) print ' Downloading completed' else: print ' Copying: ' + archive.archive_uri @@ -882,8 +881,7 @@ def install_ifw_tools(): print '*** Package URL is invalid: [' + package_url + ']' print '*** Abort!' sys.exit(-1) - urllib.urlcleanup() - urllib.urlretrieve(package_url, package_save_as_temp, reporthook=bldinstallercommon.dlProgress) + bldinstallercommon.retrieve_url(package_url, package_save_as_temp) if not (os.path.isfile(package_save_as_temp)): print '*** Downloading failed! Aborting!' sys.exit(-1) @@ -1040,8 +1038,7 @@ def create_mac_disk_image(): print '*** Package URL is invalid: [' + nib_archive_name + ']' print '*** Abort!' sys.exit(-1) - urllib.urlcleanup() - urllib.urlretrieve(nib_archive_name, package_save_as_temp, reporthook=bldinstallercommon.dlProgress) + bldinstallercommon.retrieve_url(nib_archive_name, package_save_as_temp) # extract contents bldinstallercommon.extract_file(package_save_as_temp, package_save_as_folder)