diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-12 12:54:58 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-01-12 12:56:33 +0100 |
commit | 26c046e521c38bbfc3a263782a3bb74a7c1bf937 (patch) | |
tree | 53620f55a3c69c6a9067f3a213301f0e2c27fab0 /utils.py | |
parent | e3837eabc5b01d49c79dcf968fce965b5e22ac2f (diff) | |
parent | 73594da7ba14a5847e14ab871adb5b9ffe3d10dd (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.9
Change-Id: I18387b329e61646e8d68e678140b533281e359cd
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -49,6 +49,11 @@ import fnmatch import glob import itertools import popenasync +# There is no urllib.request in Python2 +try: + import urllib.request as urllib +except ImportError: + import urllib from distutils import log from distutils.errors import DistutilsOptionError @@ -748,3 +753,21 @@ def detectClang(): arch = '64' if sys.maxsize > 2**31-1 else '32' clangDir = clangDir.replace('_ARCH_', arch) return (clangDir, source) + +def download_and_extract_7z(fileurl, target): + """ Downloads 7z file from fileurl and extract to target """ + + print("Downloading fileUrl %s " % fileurl) + info = "" + try: + localfile, info = urllib.urlretrieve(fileurl) + except: + print("Error downloading %r : %r" % (fileurl, info)) + raise RuntimeError(' Error downloading ' + fileurl) + + try: + outputDir = "-o" + target + print("calling 7z x %s %s" % (localfile, outputDir)) + subprocess.call(["7z", "x", "-y", localfile, outputDir]) + except: + raise RuntimeError(' Error extracting ' + localfile) |