aboutsummaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-01-12 12:54:58 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-01-12 12:56:33 +0100
commit26c046e521c38bbfc3a263782a3bb74a7c1bf937 (patch)
tree53620f55a3c69c6a9067f3a213301f0e2c27fab0 /utils.py
parente3837eabc5b01d49c79dcf968fce965b5e22ac2f (diff)
parent73594da7ba14a5847e14ab871adb5b9ffe3d10dd (diff)
Merge remote-tracking branch 'origin/5.6' into 5.9
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index e0cbc276a..0a70112b7 100644
--- a/utils.py
+++ b/utils.py
@@ -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)