Esempio n. 1
0
def install_involucro(involucro_context=None, to_path=None):
    install_path = os.path.abspath(involucro_context.involucro_bin)
    involucro_context.involucro_bin = install_path
    download_cmd = " ".join(
        commands.download_command(involucro_link(),
                                  to=install_path,
                                  quote_url=True))
    full_cmd = "%s && chmod +x %s" % (download_cmd, install_path)
    return involucro_context.shell_exec(full_cmd)
Esempio n. 2
0
def install_involucro(involucro_context):
    install_path = os.path.abspath(involucro_context.involucro_bin)
    involucro_context.involucro_bin = install_path
    download_cmd = commands.download_command(involucro_link(), to=install_path)
    exit_code = involucro_context.shell_exec(download_cmd)
    if exit_code:
        return exit_code
    try:
        os.chmod(install_path, os.stat(install_path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
        return 0
    except Exception:
        log.exception("Failed to make file '%s' executable", install_path)
        return 1
Esempio n. 3
0
def untar_to(url, tar_args=None, path=None, dest_dir=None):
    if tar_args:
        assert not (path and dest_dir)
        if dest_dir:
            if not os.path.exists(dest_dir):
                os.makedirs(dest_dir)
            tar_args[0:0] = ['-C', dest_dir]
        if path:
            tar_args.insert(0, '-O')

        download_cmd = download_command(url)
        download_p = commands.shell_process(download_cmd,
                                            stdout=subprocess.PIPE)
        untar_cmd = ['tar'] + tar_args
        if path:
            with open(path, 'wb') as fh:
                shell(untar_cmd, stdin=download_p.stdout, stdout=fh)
        else:
            shell(untar_cmd, stdin=download_p.stdout)
        download_p.wait()
    else:
        cmd = download_command(url, to=path)
        shell(cmd)