コード例 #1
0
def install(force=False):
    """Install python"""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'python', version)
    python_bin = os.path.join(install_dir, 'bin', 'python')

    if cuisine.file_exists(python_bin):
        if not force:
            fab.puts("Python {0} found, skipping installation".format(version))
            return
        else:
            fab.puts("Reinstalling Python {0} found".format(version))

    cuisine.package_install(['build-essential', 'libcurl4-openssl-dev'])

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Downloading python {0}".format(version))
        fab.run("wget -q '%s' -O - | tar xz" %
                PYTHON_DOWNLOAD_URL.format(version=version))
        with fab.cd('Python-{0}'.format(version)):
            fab.puts("Installing python {0}".format(version))
            fab.run("./configure --prefix=%s" % install_dir)
            fab.run("make")
            fab.sudo('make install')
    fab.run('rm -rf {0}'.format(src_dir))
コード例 #2
0
ファイル: python.py プロジェクト: pauloalem/fabix
def install_setuptools(force=False):
    """Install setuptools"""
    py_version = get_config()['version']

    easy_install_bin = _python_bin_path(py_version, 'easy_install')
    if cuisine.file_exists(easy_install_bin):
        if not force:
            fab.puts("easy_install for python {0} found, skipping installation".format(py_version))
            return
        else:
            fab.puts("Reinstalling easy_install for python {0}".format(py_version))

    major, minor = py_version.split('.')[0:2]
    version = "{0}.{1}".format(major, minor)

    python_bin = _python_bin_path(py_version)

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Downloading setuptools for python {0}".format(version))
        download_url = SETUPTOOLS_DOWNLOAD_URL.format(py_version=version)
        fab.run("wget -q '{0}' -O - | tar xz".format(download_url))
        with fab.cd('setuptools-*'):
            fab.puts("Installing setuptools for python {0}".format(version))
            fab.sudo("{0} setup.py install".format(python_bin))
    fab.sudo('rm -rf {0}'.format(src_dir))
コード例 #3
0
def install_setuptools(force=False):
    """Install setuptools"""
    py_version = get_config()['version']

    easy_install_bin = _python_bin_path(py_version, 'easy_install')
    if cuisine.file_exists(easy_install_bin):
        if not force:
            fab.puts(
                "easy_install for python {0} found, skipping installation".
                format(py_version))
            return
        else:
            fab.puts(
                "Reinstalling easy_install for python {0}".format(py_version))

    major, minor = py_version.split('.')[0:2]
    version = "{0}.{1}".format(major, minor)

    python_bin = _python_bin_path(py_version)

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Downloading setuptools for python {0}".format(version))
        download_url = SETUPTOOLS_DOWNLOAD_URL.format(py_version=version)
        fab.run("wget -q '{0}' -O - | tar xz".format(download_url))
        with fab.cd('setuptools-*'):
            fab.puts("Installing setuptools for python {0}".format(version))
            fab.sudo("{0} setup.py install".format(python_bin))
    fab.sudo('rm -rf {0}'.format(src_dir))
コード例 #4
0
ファイル: python.py プロジェクト: rcmachado/fabix
def install(force=False):
    """Install python"""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'python', version)
    python_bin = os.path.join(install_dir, 'bin', 'python')

    if cuisine.file_exists(python_bin):
        if not force:
            fab.puts("Python {0} found, skipping installation".format(version))
            return
        else:
            fab.puts("Reinstalling Python {0} found".format(version))

    cuisine.package_install(['build-essential', 'libcurl4-openssl-dev'])

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Downloading python {0}".format(version))
        fab.run("wget -q '%s' -O - | tar xz" % PYTHON_DOWNLOAD_URL.format(version=version))
        with fab.cd('Python-{0}'.format(version)):
            fab.puts("Installing python {0}".format(version))
            fab.run("./configure --prefix=%s" % install_dir)
            fab.run("make")
            fab.sudo('make install')
    fab.run('rm -rf {0}'.format(src_dir))
コード例 #5
0
def install_pip():
    """Install pip latest version."""
    py_version = get_config()['version']

    fab.puts("Installing pip for python {0}".format(py_version))
    easy_install_bin = _python_bin_path(py_version, 'easy_install')

    if not cuisine.file_exists(easy_install_bin):
        fab.puts("easy_install for version {0} not found".format(py_version))
        return

    fab.sudo('{0} pip'.format(easy_install_bin))
コード例 #6
0
ファイル: python.py プロジェクト: rcmachado/fabix
def uninstall():
    """Uninstall python"""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'python')
    if version != 'all':
        install_dir = os.path.join(install_dir, version)

    fab.puts("Removing {0}".format(install_dir))
    if fab.confirm("Are you sure?", default=False):
        fab.sudo("rm -rf '{0}'".format(install_dir))
        fab.puts("Python {0} uninstalled".format(version))
コード例 #7
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
def uninstall():
    """Uninstall nginx HTTP server"""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'nginx')
    if version != 'all':
        install_dir = os.path.join(install_dir, version)

    fab.puts("Removing {0}".format(install_dir))
    if fab.confirm("Are you sure?", default=False):
        fab.sudo("rm -rf '{0}'".format(install_dir))
        fab.puts("Nginx {0} uninstalled".format(version))
コード例 #8
0
ファイル: python.py プロジェクト: rcmachado/fabix
def install_pip():
    """Install pip latest version."""
    py_version = get_config()['version']

    fab.puts("Installing pip for python {0}".format(py_version))
    easy_install_bin = _python_bin_path(py_version, 'easy_install')

    if not cuisine.file_exists(easy_install_bin):
        fab.puts("easy_install for version {0} not found".format(py_version))
        return

    fab.sudo('{0} pip'.format(easy_install_bin))
コード例 #9
0
ファイル: python.py プロジェクト: rcmachado/fabix
def create_virtualenv():
    """Create virtualenv for project."""
    site = get_project_name()
    version = get_config()['version']

    virtualenv_dir = "{}/{}/virtualenv".format(SITES_DIR, site)
    if cuisine.dir_exists(virtualenv_dir + "/bin"):
        fab.puts("virtualenv for {0} already exists".format(site))
        return

    with cuisine.mode_sudo():
        cuisine.dir_ensure(virtualenv_dir, recursive=True)

    venv_bin = _python_bin_path(version, 'virtualenv')
    fab.sudo("{venv_bin} {virtualenv_dir}".format(venv_bin=venv_bin,
             virtualenv_dir=virtualenv_dir))
コード例 #10
0
def create_virtualenv():
    """Create virtualenv for project."""
    site = get_project_name()
    version = get_config()['version']

    virtualenv_dir = "{}/{}/virtualenv".format(SITES_DIR, site)
    if cuisine.dir_exists(virtualenv_dir + "/bin"):
        fab.puts("virtualenv for {0} already exists".format(site))
        return

    with cuisine.mode_sudo():
        cuisine.dir_ensure(virtualenv_dir, recursive=True)

    venv_bin = _python_bin_path(version, 'virtualenv')
    fab.sudo("{venv_bin} {virtualenv_dir}".format(
        venv_bin=venv_bin, virtualenv_dir=virtualenv_dir))
コード例 #11
0
ファイル: python.py プロジェクト: rcmachado/fabix
def uninstall_pypi_package(package, use_virtualenv=True):
    """Uninstall pypi package `package` on python `py_version`."""
    py_version = get_config()['version']

    fab.puts("Uninstalling pypi package {0} on python {1}".format(package, py_version))

    if use_virtualenv:
        site = get_project_name()
        pip_bin = _get_virtualenv_bin(site, 'pip')
    else:
        pip_bin = _python_bin_path(py_version, 'pip')

    if not cuisine.file_exists(pip_bin):
        fab.puts("pip for version {0} not found".format(py_version))
        return

    fab.sudo('{cmd} uninstall --yes {package}'.format(cmd=pip_bin, package=package))
コード例 #12
0
def install_pypi_package(package, use_virtualenv=True):
    """Install pypi package `package` on python `py_version`."""
    py_version = get_config()['version']

    fab.puts("Installing pypi package {0} on python {1}".format(
        package, py_version))

    if use_virtualenv:
        site = get_project_name()
        pip_bin = _get_virtualenv_bin(site, 'pip')
    else:
        pip_bin = _python_bin_path(py_version, 'pip')

    if not cuisine.file_exists(pip_bin):
        fab.puts("pip for version {0} not found".format(py_version))
        return

    fab.sudo('{cmd} install {package}'.format(cmd=pip_bin, package=package))
コード例 #13
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
def install_upstart():
    """Install nginx upstart config."""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    nginx_bin = os.path.join(install_dir, 'sbin', 'nginx')
    nginx_pid = os.path.join(install_dir, 'logs', 'nginx.pid')

    context = {
        'nginx_bin': nginx_bin,
        'nginx_pid': nginx_pid,
    }

    nginx_tpl = os.path.join(ETC_DIR, 'init', 'nginx.conf')
    tpl_content = cuisine.file_local_read(nginx_tpl)
    content = cuisine.text_template(tpl_content, context)

    with cuisine.mode_sudo():
        cuisine.file_write('/etc/init/nginx.conf', content)
コード例 #14
0
ファイル: python.py プロジェクト: rcmachado/fabix
def uninstall_setuptools():
    """Uninstall setuptools"""
    py_version = get_config()['version']

    major, minor = py_version.split('.')[0:2]
    version = "{0}.{1}".format(major, minor)

    python_bin = _python_bin_path(py_version)

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Downloading setuptools for python {0}".format(version))
        download_url = SETUPTOOLS_DOWNLOAD_URL.format(py_version=version)
        fab.run("wget -q '{0}' -O - | tar xz".format(download_url))
        with fab.cd('setuptools-*'):
            fab.puts("Uninstalling setuptools for python {0}".format(version))
            fab.sudo("{0} setup.py install --record setuptools_files.txt".format(python_bin))
            fab.sudo("cat setuptools_files.txt | xargs rm -rf")
    fab.sudo('rm -rf {0}'.format(src_dir))
コード例 #15
0
ファイル: python.py プロジェクト: rcmachado/fabix
def install_setuptools(force=False):
    """Install setuptools"""
    py_version = get_config()['version']

    pip_bin = _python_bin_path(py_version, 'pip')
    if cuisine.file_exists(pip_bin):
        if not force:
            fab.puts("pip for python {0} found, skipping installation".format(py_version))
            return
        else:
            fab.puts("Reinstalling easy_install for python {0}".format(py_version))

    python_bin = _python_bin_path(py_version)

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Installing setuptools")
        fab.run('wget {} -O - | {}'.format(SETUPTOOLS_DOWNLOAD_URL,
                                           python_bin))
    fab.sudo('rm -rf {0}'.format(src_dir))
コード例 #16
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
def put_site_conf(nginx_file, context=None):
    """Install nginx config per site."""
    version = get_config()['version']

    if not os.path.exists(nginx_file):
        fab.abort("Nginx conf {0} not found".format(nginx_file))

    site_name = os.path.basename(nginx_file)

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    conf_file = os.path.join(install_dir, 'conf', 'sites-enabled', site_name)

    if context:
        tpl_content = open(nginx_file, 'rb').read()
        content = cuisine.text_template(tpl_content, context)

        with cuisine.mode_sudo():
            cuisine.file_write(conf_file, content)
    else:
        with cuisine.mode_sudo():
            cuisine.file_upload(conf_file, nginx_file)
コード例 #17
0
def uninstall_setuptools():
    """Uninstall setuptools"""
    py_version = get_config()['version']

    major, minor = py_version.split('.')[0:2]
    version = "{0}.{1}".format(major, minor)

    python_bin = _python_bin_path(py_version)

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Downloading setuptools for python {0}".format(version))
        download_url = SETUPTOOLS_DOWNLOAD_URL.format(py_version=version)
        fab.run("wget -q '{0}' -O - | tar xz".format(download_url))
        with fab.cd('setuptools-*'):
            fab.puts("Uninstalling setuptools for python {0}".format(version))
            fab.sudo(
                "{0} setup.py install --record setuptools_files.txt".format(
                    python_bin))
            fab.sudo("cat setuptools_files.txt | xargs rm -rf")
    fab.sudo('rm -rf {0}'.format(src_dir))
コード例 #18
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
def put_conf(nginx_file):
    """Install global nginx config."""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    conf_file = os.path.join(install_dir, 'conf', 'nginx.conf')

    if not os.path.exists(nginx_file):
        fab.abort("Nginx conf {0} not found".format(nginx_file))

    nginx_pid = os.path.join(install_dir, 'logs', 'nginx.pid')

    context = {
        'nginx_user': NGINX_USER,
        'nginx_pid': nginx_pid,
    }

    tpl_content = open(nginx_file, 'rb').read()
    content = cuisine.text_template(tpl_content, context)

    with cuisine.mode_sudo():
        cuisine.file_write(conf_file, content)
コード例 #19
0
def install_setuptools(force=False):
    """Install setuptools"""
    py_version = get_config()['version']

    pip_bin = _python_bin_path(py_version, 'pip')
    if cuisine.file_exists(pip_bin):
        if not force:
            fab.puts("pip for python {0} found, skipping installation".format(
                py_version))
            return
        else:
            fab.puts(
                "Reinstalling easy_install for python {0}".format(py_version))

    python_bin = _python_bin_path(py_version)

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Installing setuptools")
        fab.run('wget {} -O - | {}'.format(SETUPTOOLS_DOWNLOAD_URL,
                                           python_bin))
    fab.sudo('rm -rf {0}'.format(src_dir))
コード例 #20
0
ファイル: project.py プロジェクト: pauloalem/fabix
def do_archive(tag='master'):
    site = fab.env.fabix['_current_project']
    project_dir = get_config()['project_dir']

    install_dir = os.path.join(INSTALL_DIR, site)
    dirs_to_create = (
        os.path.join(install_dir, 'releases'),
    )
    fab.sudo('mkdir -p {0}'.format(' '.join(dirs_to_create)))

    fab.puts("Upload project {0}".format(site))

    today = datetime.now().strftime('%Y%m%d-%H%M%S')
    commit_id = str(fab.local('git rev-parse {0}'.format(tag), True)).strip()
    current = "%s-%s" % (today, commit_id[:8])

    local_temp_dir = mkdtemp()
    archive = os.path.join(local_temp_dir, '{0}.tar.gz'.format(site))

    git_arch_cmd = "git archive --format=tar.gz -o {archive} {commit_id}:{project_dir}"
    fab.local(git_arch_cmd.format(archive=archive, commit_id=commit_id, project_dir=project_dir))

    return local_temp_dir, archive, current
コード例 #21
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
def install(force=False):
    """Install nginx HTTP server."""
    version = get_config()['version']

    cuisine.package_install(['build-essential', 'libpcre3-dev', 'zlib1g-dev'])

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    nginx_bin = os.path.join(install_dir, 'sbin', 'nginx')
    if cuisine.file_exists(nginx_bin):
        if not force:
            fab.puts("Nginx {0} found, skipping installation".format(version))
            return
        else:
            fab.puts("Reinstalling nginx {0} found".format(version))

    with cuisine.mode_sudo():
        cuisine.dir_ensure(install_dir, True)

    home_dir = os.path.join(install_dir, 'html')
    cuisine.user_ensure(NGINX_USER, None, home_dir, shell='/sbin/nologin')
    fab.sudo('passwd -l nginx')

    download_url = _DOWNLOAD_URL.format(version=version)

    src_dir = fab.run('mktemp -d')
    with fab.cd(src_dir):
        fab.puts("Downloading nginx {0}".format(version))
        fab.run("wget -q '{0}' -O - | tar xz".format(download_url))
        with fab.cd('nginx-{0}'.format(version)):
            fab.puts("Compiling nginx {0}".format(version))
            fab.run("./configure --prefix={0} --with-http_stub_status_module".format(install_dir))
            fab.run("make")
            fab.puts("Installing nginx {0}".format(version))
            fab.sudo('make install')
            with cuisine.mode_sudo():
                cuisine.dir_ensure("{0}{1}".format(install_dir, '/conf/sites-enabled'))
    fab.run("rm -rf '{0}'".format(src_dir))
コード例 #22
0
ファイル: project.py プロジェクト: vinimalavolta/fabix
def do_archive(tag='master'):
    site = fab.env.fabix['_current_project']
    project_dir = get_config()['project_dir']

    install_dir = os.path.join(INSTALL_DIR, site)
    dirs_to_create = (os.path.join(install_dir, 'releases'), )
    fab.sudo('mkdir -p {0}'.format(' '.join(dirs_to_create)))

    fab.puts("Upload project {0}".format(site))

    today = datetime.now().strftime('%Y%m%d-%H%M%S')
    commit_id = str(fab.local('git rev-parse {0}'.format(tag), True)).strip()
    current = "%s-%s" % (today, commit_id[:8])

    local_temp_dir = mkdtemp()
    archive = os.path.join(local_temp_dir, '{0}.tar.gz'.format(site))

    git_arch_cmd = "git archive --format=tar.gz -o {archive} {commit_id}:{project_dir}"
    fab.local(
        git_arch_cmd.format(archive=archive,
                            commit_id=commit_id,
                            project_dir=project_dir))

    return local_temp_dir, archive, current