import contextlib
import os
import shutil
import subprocess
import sys
import tarfile

def get(url, path, quiet=False):
    # see http://serverfault.com/questions/301128/how-to-download
    if sys.platform == 'win32':
        run(["PowerShell.exe", "/nologo", "-Command",
             "(New-Object System.Net.WebClient).DownloadFile('" + url +
                "', '" + path + "')"], quiet=quiet)
    else:
        run(["curl", "-o", path, url], quiet=quiet)

def unpack(tarball, dst, quiet=False):
    if quiet:
        print("extracting " + tarball)
    fname = os.path.basename(tarball).replace(".tar.gz", "")
    with contextlib.closing(tarfile.open(tarball)) as tar:
        for p in tar.getnames():
            name = p.replace(fname + "/", "", 1)
            fp = os.path.join(dst, name)
            if not quiet:
                print("extracting " + p)
            tar.extract(p, dst)
            tp = os.path.join(dst, p)
            if os.path.isdir(tp) and os.path.exists(fp):
                continue
            shutil.move(tp, fp)
    shutil.rmtree(os.path.join(dst, fname))

def run(args):
    print("running: " + ' '.join(args))
    ret = subprocess.call(args)
    if ret != 0:
        raise Exception("failed to fetch url: " + url)

@@ -1099,99 +1099,580 @@
 args
-):%0A    print(%22running: %22 + ' '.join(args))%0A    ret = subprocess.call(args)%0A    if ret != 0:
+, quiet=False):%0A    if not quiet:%0A        print(%22running: %22 + ' '.join(args))%0A    sys.stdout.flush()%0A    # Use Popen here instead of call() as it apparently allows powershell on%0A    # Windows to not lock up waiting for input presumably.%0A    ret = subprocess.Popen(args,%0A                           stdin = subprocess.PIPE,%0A                           stdout = subprocess.PIPE,%0A                           stderr = subprocess.PIPE)%0A    out, err = ret.communicate()%0A    code = ret.wait()%0A    if code != 0:%0A        print(%22stdout: %5Cn%5Cn%22 + out)%0A        print(%22stderr: %5Cn%5Cn%22 + err)
 %0A   
@@ -1716,15 +1716,7 @@
  url
-: %22 + url
+%22
 )%0A

Use Popen instead of call to spawn processes