

def extract_exe(fname, targetdir=None, verbose=False):
    'Extract .exe archive to a temporary directory (if targetdir\n    is None). Return the temporary directory path'
    if (targetdir is None):
        targetdir = _create_temp_dir()
    extract = '7z.exe'
    assert is_program_installed(extract), ("Required program '%s' was not found" % extract)
    bname = osp.basename(fname)
    args = ['x', ('-o%s' % targetdir), '-aos', bname]
    if verbose:
        retcode = subprocess.call(([extract] + args), cwd=osp.dirname(fname))
    else:
        p = subprocess.Popen(([extract] + args), cwd=osp.dirname(fname), stdout=subprocess.PIPE)
        p.communicate()
        p.stdout.close()
        retcode = p.returncode
    if (retcode != 0):
        raise RuntimeError(('Failed to extract %s (return code: %d)' % (fname, retcode)))
    return targetdir

dataset/ETHPy150Open winpython/winpython/winpython/utils.py extract_exe/original