about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCyryl Płotnicki-Chudyk <cyplo@cyplo.net>2016-04-30 08:43:01 +0200
committerCyryl Płotnicki-Chudyk <cyplo@cyplo.net>2016-04-30 08:43:01 +0200
commit18dafe83b5411e76a13f5e813dae1bec71ef07a6 (patch)
tree8855ca0e86d0fc4e94fc32e9bb80f2b3b22854a1
parentf5884f6824291cda15096d84af9e346e13a41578 (diff)
Code cleanup in download() in bootstrap.py
Make download() receive less parameters and use it explicitly 2 times
in get().
-rw-r--r--src/bootstrap/bootstrap.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 6efaf16a974..7599afacc82 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -25,7 +25,8 @@ def get(url, path, verbose=False):
     temp_path = temp_file.name
     sha_file = tempfile.NamedTemporaryFile(suffix=".sha256", delete=True)
     sha_path = sha_file.name
-    download(sha_path, sha_url, temp_path, url, verbose)
+    download(sha_path, sha_url, verbose)
+    download(temp_path, url, verbose)
     verify(sha_path, temp_path, verbose)
     sha_file.close()
     print("moving " + temp_path + " to " + path)
@@ -33,17 +34,16 @@ def get(url, path, verbose=False):
     temp_file.close()
 
 
-def download(sha_path, sha_url, temp_path, url, verbose):
-    for _url, _path in ((url, temp_path), (sha_url, sha_path)):
-        print("downloading " + _url + " to " + _path)
-        # see http://serverfault.com/questions/301128/how-to-download
-        if sys.platform == 'win32':
-            run(["PowerShell.exe", "/nologo", "-Command",
-                 "(New-Object System.Net.WebClient)"
-                 ".DownloadFile('{}', '{}')".format(_url, _path)],
-                verbose=verbose)
-        else:
-            run(["curl", "-o", _path, _url], verbose=verbose)
+def download(path, url, verbose):
+    print("downloading " + url + " to " + path)
+    # see http://serverfault.com/questions/301128/how-to-download
+    if sys.platform == 'win32':
+        run(["PowerShell.exe", "/nologo", "-Command",
+             "(New-Object System.Net.WebClient)"
+             ".DownloadFile('{}', '{}')".format(url, path)],
+            verbose=verbose)
+    else:
+        run(["curl", "-o", path, url], verbose=verbose)
 
 
 def verify(sha_path, temp_path, verbose):