<commit_before>import os

from fabric.api import *
import fabtools
from fabtools import require

cwd = os.getcwd()
all_users = ['docs', 'eric', 'syncer']
checkout_users = ['docs', 'syncer']
required_dirs =['checkouts', 'etc', 'run', 'log']

def all():
    install_packages()
    users()
    checkout()
    setup_env()

def install_packages():
    env.user = 'root'
    sudo('apt-get update')
    sudo('apt-get install -y git-core python-setuptools python-dev postgresql-client libpq-dev subversion graphviz curl sqlite libxml2-dev libxslt-dev vim')
    sudo ('easy_install pip')
    sudo ('pip install -U virtualenv mercurial')

    # Prod Packages
    sudo('apt-get install -y redis-server memcached')

def users():
    env.user = 'root'
    for user in all_users:
        home = '/home/%s' % user
        if not fabtools.user.exists(user):
            sudo('adduser --gecos "" -q --disabled-password %s' % user)

        if not fabtools.files.is_file('%s/.ssh/authorized_keys' % home):
            sudo('mkdir -p %s/.ssh' % home)
            put('keys/*.pub', '%s/.ssh/authorized_keys' % home, mode=700)
            sudo('chown -R %s:%s %s' % (user, user, home))
            sudo('chmod -R 700 %s' % home)

def checkout(user):
    if user:
        users = [user]
    else:
        users = checkout_users
    for user in users:
        env.user = user
        home = '/home/%s' % user
        for dir in required_dirs:
            run('mkdir -p %s/%s' % (home, dir))
        if not fabtools.files.is_dir('%s/checkouts/readthedocs.org' % home):
            with cd('%s/checkouts/' % home):
                run('git clone git://github.com/rtfd/readthedocs.org.git')
        if not fabtools.files.is_file('%s/bin/python' % home):
            run('virtualenv %s' % home)
        run('%s/bin/pip install -U -r %s/checkouts/readthedocs.org/deploy_requirements.txt' % (home, home))

def setup_env(user):
    if user:
        users = [user]
    else:
        users = checkout_users
    for user in users:
        env.user = user
        home = '/home/%s' % user
        put('files/bash_profile', '%s/.bash_profile' % home)
        put('files/%s_supervisord.conf' % user, '%s/etc/supervisord.conf' % home)
        run('%s/bin/pip install -U supervisor ipython gunicorn' % home)<commit_msg>Add synced to proper group.<commit_after>import os

from fabric.api import *
import fabtools
from fabtools import require

cwd = os.getcwd()
all_users = ['docs', 'eric', 'syncer']
checkout_users = ['docs', 'syncer']
required_dirs =['checkouts', 'etc', 'run', 'log']

def all():
    install_packages()
    users()
    checkout()
    setup_env()

def install_packages():
    env.user = 'root'
    sudo('apt-get update')
    sudo('apt-get install -y git-core python-setuptools python-dev postgresql-client libpq-dev subversion graphviz curl sqlite libxml2-dev libxslt-dev vim')
    sudo ('easy_install pip')
    sudo ('pip install -U virtualenv mercurial')

    # Prod Packages
    sudo('apt-get install -y redis-server memcached')

def users():
    env.user = 'root'
    for user in all_users:
        home = '/home/%s' % user
        if not fabtools.user.exists(user):
            sudo('adduser --gecos "" -q --disabled-password %s' % user)

        if not fabtools.files.is_file('%s/.ssh/authorized_keys' % home):
            sudo('mkdir -p %s/.ssh' % home)
            put('keys/*.pub', '%s/.ssh/authorized_keys' % home, mode=700)
            sudo('chown -R %s:%s %s' % (user, user, home))
            sudo('chmod -R 700 %s' % home)
    sudo('mkdir /var/build')
    sudo('chmod 777 /var/build')
    # Syncer > Docs
    sudo('adduser syncer docs')


def checkout(user):
    if user:
        users = [user]
    else:
        users = checkout_users
    for user in users:
        env.user = user
        home = '/home/%s' % user
        for dir in required_dirs:
            run('mkdir -p %s/%s' % (home, dir))
        if not fabtools.files.is_dir('%s/checkouts/readthedocs.org' % home):
            with cd('%s/checkouts/' % home):
                run('git clone git://github.com/rtfd/readthedocs.org.git')
        if not fabtools.files.is_file('%s/bin/python' % home):
            run('virtualenv %s' % home)
        run('%s/bin/pip install -U -r %s/checkouts/readthedocs.org/deploy_requirements.txt' % (home, home))

def setup_env(user):
    if user:
        users = [user]
    else:
        users = checkout_users
    for user in users:
        env.user = user
        home = '/home/%s' % user
        put('files/bash_profile', '%s/.bash_profile' % home)
        put('files/%s_supervisord.conf' % user, '%s/etc/supervisord.conf' % home)
        run('%s/bin/pip install -U supervisor ipython gunicorn' % home)
{'fraction_non_alphanumeric': 0.15114048177360903, 'fraction_numerical': 0.0036239607759539546, 'mean_word_length': 2.4525386313465782, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3179216', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1570, 'n_words': 403}