Commits

Rod Morison committed e7d2d32 Draft

remove v1 legacy files

Comments (0)

Files changed (22)

django/__init__.py

Empty file removed.

django/dev.py

-from fabric.api import env
-
-# signature of custom settings
-env.settings = 'dev'
-
-# postgresql settings
-MB = 1024*1024
-env.pg_version = '9.0'
-env.pg_settings = { 'version': env.pg_version ,
-                    'root_pass': '123456',
-                    'listen_addr': '127.0.0.1',
-                    'access_net': None,
-                    # kernel/pg params for vanilla dev system
-                    'tuning': { 'kernel_shmmax': '%d' % (32*MB), 
-                                'kernel_shmall': '%d' % (2*MB),
-                                'vm_overcommit_memory': '0',
-                                'max_connections': '100',
-                                'shared_buffers': '24MB',
-                                'work_mem': '1MB',
-                                'maintenance_work_mem': '16MB',
-                                'effective_cache_size': '128MB',
-                                'random_page_cost': '4',
-                                },
-                    }
-env.pgclient_settings = { # optional client tools
-                          'version': env.pg_version ,
-                          'contrib': True,
-                          'pgadmin': True,
-                          }
-
-
-
-# rabbitmq settings
-env.rabbitmq_pass = '123456'
-
-# memcached settings
-env.memcached_ram = '100' # MB

django/fabfile.py

-"""
-Setup a django system. Can build a django wsgi webserver, a dbserver, a (rabbitmq) amqpserver; or
-build/deploy a django site for dev, stage or prod settings.
-"""
-
-from os import path
-from sys import path as syspath
-pwd = path.abspath(path.dirname(__file__))
-syspath.insert(0, path.join(pwd, '..'))
-syspath.insert(0, pwd)
-
-from fabric.api import sudo, env, require, prompt, abort
-from installers import postgresql, rabbitmq, python, memcached
-
-def test():
-    #sql = "ALTER USER postgres WITH UNENCRYPTED PASSWORD '%s';" % '123456'
-    #sudo('bash -c psql template1 <<<"%s"' % sql, user='postgres')
-    input = '''
-    foo
-    bar
-    '''
-    from textwrap import dedent
-    sudo('cat >>/tmp/test.txt <<EOF%sEOF' % dedent(input))
-
-def dev():
-    """Development site/system setup"""
-    try:
-        import dev
-    except ImportError, e:
-        abort(repr(e))
-
-def stage():
-    """Stage site/system setup"""
-    try:
-        import stage
-    except ImportError, e:
-        abort(repr(e))
-
-def prod():
-    """Production site/system setup"""
-    try:
-        import prod
-    except ImportError, e:
-        abort(repr(e))
-
-
-def webserver():
-    require('settings', provided_by=[prod, stage, dev])
-
-
-def dbserver(dbms='postgres'):
-    """Install/config database server, dbms='postgres' default"""
-    require('settings', provided_by=[prod, stage, dev])
-    if dbms.startswith('postgres'):
-        env.pg_settings['root_pass'] = prompt("postgres role password:", default=env.pg_settings['root_pass'])
-        postgresql.install_postgresql_server(**env.pg_settings)
-    else:
-        abort("dbms='%s' not implemented" % dbms)
-
-
-def dbclient(dbms='postgres'):
-    """Install database client and optional tools: contrib, pgadmin"""
-    require('settings', provided_by=[prod, stage, dev])
-    if dbms.startswith('postgres'):
-        postgresql.install_postgresql_client(**env.pgclient_settings)
-    else:
-        abort("dbms='%s' not implemented" % dbms)
-
-
-def amqpserver():
-    """Install/config rabbitmq message server"""
-    require('settings', provided_by=[prod, stage, dev])
-    prompt("rabbitmq admin password:", key='rabbitmq_pass', default=env.rabbitmq_pass)
-    rabbitmq.install_rabbitmq(env.rabbitmq_pass)
-
-def setup_devsystem():
-    require('settings', provided_by=[prod, stage, dev])
-    setup_dbserver()
-    setup_amqpserver()
-    
-def setup_djangosite():
-    require('settings', provided_by=[prod, stage, dev])
-    
-    
-def build():
-    """Build the requested system"""
-    python.install_pythontools()
-    memcached.install_memcached(env.memcached_ram)

installers/__init__.py

Empty file removed.

installers/apache.py

-'''
-Install and configure apache and apache modules
-'''
-
-from fabric.operations import sudo, put
-
-def install_apache():
-    """
-    Install the apache webserver
-    """
-    sudo("apt-get --yes install apache2 apache2-mpm-worker")
-    sudo("a2dismod autoindex")
-    sudo("service apache2 restart")
-
-def install_wsgi():
-    sudo("apt-get --yes build-dep libapache2-mod-wsgi")
-    with cd(env.src_build_dir):
-        sudo("curl %(wsgi_tarball)s | tar xzf -" % env)
-    with cd( path.join(env.src_build_dir, env.wsgi_name) ): 
-        sudo("./configure --enable-shared; make install")
-    with cd("/etc"):
-        sudo("echo 'LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so' >apache2/mods-available/wsgi.load")
-        sudo("echo '%(wsgi_conf)s' >apache2/mods-available/wsgi.conf" % env)
-        sudo("hg add apache2/mods-available/wsgi.load apache2/mods-available/wsgi.conf" % env)
-        sudo("hg commit -u %(admin_user)s -m 'Apache mod_wsgi setup'" % env)
-    sudo('a2enmod info wsgi; service apache2 restart')
-    run('wget -O - http://localhost/server-info | grep mod_wsgi; sleep 3' % env)

installers/buildbot.py

-'''
-Install (generally) newer buildbot software than the distro supports
-'''
-
-from datetime import datetime
-from textwrap import dedent
-from fabric.context_managers import prefix, cd, settings, show
-from fabric.operations import run, sudo, put
-from fabric.utils import warn, abort
-from path import path
-from python import DEFAULT_ENV_DIR, install_virtualenv
-from utils import file_exists, append_file
-
-
-def last_bot_index(default_file, key):
-    if not file_exists(default_file):
-        abort("%s: missing file, can't update default" % default_file)
-    prog = '''
-    import re
-    p = re.compile(r"^%s[A-Z]+\[(\d+)\]")
-    for s in open("%s").readlines():
-        if p.match(s): print int(p.match(s).group(1))
-    print '0'
-    ''' % (key, default_file)
-    indices = [int(i) for i in run("python -c '%s'" % dedent(prog)).split()]
-    return max(indices)
-
-def install_master(buildbot_user, env_dir=DEFAULT_ENV_DIR):
-    '''
-    Install a buildbot master in a virtualenv under a buildbot_user uid 
-    with /etc/default and /etc/init.d scripts. Setups up virtualenv and
-    virtualenv wrapper if needed.
-    '''
-
-    sudo('id %s || useradd --create-home --shell /bin/bash --user-group %s && id %s' % tuple([buildbot_user]*3))
-    user_home = path(run("ls -d ~%s" % buildbot_user))
-    workon_home = user_home / env_dir
-    buildbot_env = workon_home / 'buildbot'
-
-    if not file_exists(workon_home):
-        abort("%s virtualenvwrapper dir missing...setup virtualenv first" % workon_home)
-
-    virtualenv = "export WORKON_HOME=%s ; source /usr/local/bin/virtualenvwrapper.sh" % workon_home
-    if file_exists(buildbot_env):
-        warn("%s exists, skipping mkvirtualenv" % buildbot_env)
-    else:
-        with prefix(virtualenv):
-            sudo("mkvirtualenv buildbot", user=buildbot_user)
-    with prefix(virtualenv), prefix("workon buildbot"):
-        sudo("pip install buildbot", user=buildbot_user)
-
-    lpwd = path(__file__).dirname().abspath()
-    if file_exists('/etc/default/buildmaster'):
-        warn('/etc/default/buildmaster exists, not overwriting')
-    else:
-        put(lpwd / 'etc/default/buildmaster', '/etc/default', use_sudo=True, mirror_local_mode=True)
-        buildmaster = workon_home / 'buildbot/bin/buildbot'
-        sudo("sed 's?^MASTER_RUNNER=.*$?MASTER_RUNNER=%s?' -i /etc/default/buildmaster" % buildmaster)
-    if file_exists('/etc/init.d/buildmaster'):
-        warn('/etc/init.d/buildmaster exists, not overwriting')
-    else:
-        put(lpwd / 'etc/init.d/buildmaster', '/etc/init.d', use_sudo=True, mirror_local_mode=True)
-        sudo("update-rc.d buildmaster defaults")
-    
-def create_master(buildbot_user, master_name, env_dir=DEFAULT_ENV_DIR):
-    '''
-    Create a new buildbot master in the homedir of buildbot_user, point a /etc/default/buildmaster
-    at it, and start it up.
-    '''
-    user_home = path(run("ls -d ~%s" % buildbot_user))
-    workon_home = user_home / env_dir
-    master_home = user_home / master_name
-    virtualenv = "export WORKON_HOME=%s ; source /usr/local/bin/virtualenvwrapper.sh" % workon_home
-    
-    if file_exists(master_home):
-        abort("%s already exists, aborting create of new buildbot master" % master_home)
-    else:
-        with cd(user_home), prefix(virtualenv), prefix("workon buildbot"):
-            sudo('buildbot create-master %s' % master_name, user=buildbot_user)
-        master_default = '''
-        MASTER_ENABLED[%(index)s]=0
-        MASTER_NAME[%(index)s]="%(master_name)s"
-        MASTER_USER[%(index)s]="%(buildbot_user)s"
-        MASTER_BASEDIR[%(index)s]="%(master_home)s"
-        MASTER_OPTIONS[%(index)s]=""
-        MASTER_PREFIXCMD[%(index)s]=""
-        ''' % { 'index': last_bot_index('/etc/default/buildmaster', 'MASTER_') + 1,
-                'buildbot_user': buildbot_user,
-                'master_name': master_name,
-                'master_home': master_home,
-                }
-        append_file('/etc/default/buildmaster', dedent(master_default), "## Updated by rmsfab on " + str(datetime.now()))
-        warn('''
-        ****
-        Next step: Create/Edit %s and run "service buildmaster restart"
-        ****
-        ''' % (master_home/'master.cfg'))
-  
-
-def install_slave(buildbot_user, env_dir=DEFAULT_ENV_DIR):
-    '''
-    Install a buildbot slave in a virtualenv under a buildbot_user uid 
-    with /etc/default and /etc/init.d scripts. Setups up virtualenv and
-    virtualenv wrapper if needed.
-    '''
-
-    sudo('id %s || useradd --create-home --shell /bin/bash --user-group %s && id %s' % tuple([buildbot_user]*3))
-    user_home = path(run("ls -d ~%s" % buildbot_user))
-    workon_home = user_home / env_dir
-    buildbot_env = workon_home / 'buildbot'
-
-    virtualenv = "export WORKON_HOME=%s ; source /usr/local/bin/virtualenvwrapper.sh" % workon_home
-    if file_exists(buildbot_env):
-        warn("%s exists, skipping mkvirtualenv" % buildbot_env)
-    else:
-        with prefix(virtualenv):
-            sudo("mkvirtualenv buildbot", user=buildbot_user)
-    with prefix(virtualenv), prefix("workon buildbot"):
-        sudo('pip install buildbot-slave', user=buildbot_user)
-
-    lpwd = path(__file__).dirname().abspath()
-    if file_exists('/etc/default/buildslave'):
-        warn('/etc/default/buildslave exists, not overwriting')
-    else:
-        put(lpwd / 'etc/default/buildslave', '/etc/default', use_sudo=True, mirror_local_mode=True)
-        buildslave = workon_home / 'buildbot/bin/buildslave'
-        sudo("sed 's?^SLAVE_RUNNER=.*$?SLAVE_RUNNER=%s?' -i /etc/default/buildslave" % buildslave)
-    if file_exists('/etc/init.d/buildslave'):
-        warn('/etc/init.d/buildslave exists, not overwriting')
-    else:
-        put(lpwd / 'etc/init.d/buildslave', '/etc/init.d', use_sudo=True, mirror_local_mode=True)
-        sudo("update-rc.d buildslave defaults")
-
-
-
-def create_slave(buildbot_user, slave_name, master, password, admin_info, host_info, env_dir=DEFAULT_ENV_DIR):
-    '''
-    Create a new buildbot slave in the homedir of buildbot_user, point a /etc/default/buildslave
-    at it, and start it up.
-    '''
-    user_home = path(run("ls -d ~%s" % buildbot_user))
-    workon_home = user_home / env_dir
-    slave_home = user_home / slave_name
-    virtualenv = "export WORKON_HOME=%s ; source /usr/local/bin/virtualenvwrapper.sh" % workon_home
-    
-    if file_exists(str(slave_home)):
-        abort("%s already exists, can't create new buildbot slave" % slave_home)
-    else:
-        with cd(user_home), prefix(virtualenv), prefix("workon buildbot"):
-            sudo('buildslave create-slave %s %s %s %s' % 
-                 (slave_name, master, slave_name, password), user=buildbot_user)
-            sudo("echo '%s' >%s/info/admin" % (admin_info, slave_name), user=buildbot_user)
-            sudo("echo '%s' >%s/info/host" % (host_info, slave_name), user=buildbot_user)
-        slave_default = '''
-        SLAVE_ENABLED[%(index)s]=0
-        SLAVE_NAME[%(index)s]="%(slave_name)s"
-        SLAVE_USER[%(index)s]="%(buildbot_user)s"
-        SLAVE_BASEDIR[%(index)s]="%(slave_home)s"
-        SLAVE_OPTIONS[%(index)s]=""
-        SLAVE_PREFIXCMD[%(index)s]=""
-        ''' % { 'index': last_bot_index('/etc/default/buildslave', 'SLAVE_') + 1,
-                'buildbot_user': buildbot_user,
-                'slave_name': slave_name,
-                'slave_home': slave_home,
-                }
-        append_file('/etc/default/buildslave', dedent(slave_default), "## Updated by rmsfab on " + str(datetime.now()))
-        sudo("service buildslave restart || service buildslave start")
-        

installers/etc/default/buildmaster

-MASTER_RUNNER=/usr/bin/buildbot
-
-#MASTER_ENABLED[1]=0                    # 0-enabled, other-disabled
-#MASTER_NAME[1]="buildmaster #1"        # short name printed on start/stop
-#MASTER_USER[1]="buildbot"              # user to run master as
-#MASTER_BASEDIR[1]=""                   # basedir to master (absolute path)
-#MASTER_OPTIONS[1]=""                   # buildbot options  
-#MASTER_PREFIXCMD[1]=""                 # prefix command, i.e. nice, linux32, dchroot

installers/etc/default/buildslave

-SLAVE_RUNNER=/usr/bin/buildslave
-
-#SLAVE_ENABLED[1]=0                    # 0-enabled, other-disabled
-#SLAVE_NAME[1]="buildslave #1"         # short name printed on start/stop
-#SLAVE_USER[1]="buildbot"              # user to run slave as
-#SLAVE_BASEDIR[1]=""                   # basedir to slave (absolute path)
-#SLAVE_OPTIONS[1]=""                   # buildbot options  
-#SLAVE_PREFIXCMD[1]=""                 # prefix command, i.e. nice, linux32, dchroot

installers/etc/init.d/buildmaster

-#!/bin/bash
-
-### Maintain compatibility with chkconfig
-# chkconfig: 2345 83 17
-# description: buildmaster
-
-### BEGIN INIT INFO
-# Provides:          buildmaster
-# Required-Start:    $remote_fs
-# Required-Stop:     $remote_fs
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-### END INIT INFO
-
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-MASTER_RUNNER=/usr/bin/buildbot
-
-. /lib/lsb/init-functions
-
-# Source buildmaster configuration
-[[ -r /etc/default/buildmaster ]] && . /etc/default/buildmaster
-
-if [[ ! -x ${MASTER_RUNNER} ]]; then
-    log_failure_msg "does not exist or not an executable file: ${MASTER_RUNNER}"
-    exit 1
-fi
-
-function check_config() {
-    itemcount="${#MASTER_ENABLED[@]}
-               ${#MASTER_NAME[@]}
-               ${#MASTER_USER[@]}
-               ${#MASTER_BASEDIR[@]}
-               ${#MASTER_OPTIONS[@]}
-               ${#MASTER_PREFIXCMD[@]}" 
-
-    if [[ $(echo "$itemcount" | tr -d ' ' | sort -u | wc -l) -ne 1 ]]; then
-        log_failure_msg "MASTER_* arrays must have an equal number of elements!"
-        return 1
-    fi
-
-    errors=0
-    for i in $( seq ${#MASTER_ENABLED[@]} ); do
-        if [[ ${MASTER_ENABLED[$i]} -ne 0 ]]; then 
-            log_failure_msg "buildmaster #${i}: unknown run status"
-            errors=$(($errors+1))
-        fi
-
-        if [[ -z ${MASTER_NAME[$i]} ]]; then
-            log_failure_msg "buildmaster #${i}: no name"
-            errors=$(($errors+1))
-        fi
-
-        if [[ -z ${MASTER_USER[$i]} ]]; then
-            log_failure_msg "buildmaster #${i}: no run user specified"
-            errors=$( ($errors+1) )
-        elif ! getent passwd ${MASTER_USER[$i]} >/dev/null; then
-            log_failure_msg "buildmaster #${i}: unknown user ${MASTER_USER[$i]}"
-            errors=$(($errors+1))
-        fi
-
-        if [[ ! -d "${MASTER_BASEDIR[$i]}" ]]; then
-            log_failure_msg "buildmaster ${i}: basedir does not exist ${MASTER_BASEDIR[$i]}"
-            errors=$(($errors+1))
-        fi
-    done
-
-    [[ $errors == 0 ]]; return $?
-}
-
-check_config || exit $?
-
-function iscallable () { type $1 2>/dev/null | grep -q 'shell function'; }
-
-function master_op () {
-    op=$1 ; mi=$2
-
-    ${MASTER_PREFIXCMD[$1]} \
-    su -s /bin/sh \
-    -c "$MASTER_RUNNER $op --quiet ${MASTER_OPTIONS[$mi]} ${MASTER_BASEDIR[$mi]}" \
-    - ${MASTER_USER[$mi]}
-    return $?
-}
-
-function do_op () {
-    errors=0
-    for i in $( seq ${#MASTER_ENABLED[@]} ); do
-        [[ ${MASTER_ENABLED[$i]} -ne 0 ]] && continue
-
-        # Some rhels don't come with all the lsb goodies
-        if iscallable log_daemon_msg; then
-            log_daemon_msg "$3 \"${MASTER_NAME[$i]}\""
-            if eval $1 $2 $i; then
-                log_end_msg 0
-            else
-                log_end_msg 1
-                errors=$(($errors+1))
-            fi
-        else
-            if eval $1 $2 $i; then
-                log_success_msg "$3 \"${MASTER_NAME[$i]}\""
-            else
-                log_failure_msg "$3 \"${MASTER_NAME[$i]}\""
-                errors=$(($errors+1))
-            fi
-        fi
-    done
-    return $errors
-}
-
-case "$1" in
-    start)
-        do_op "master_op" "start" "Starting buildmaster"
-        exit $?
-        ;;
-    stop)
-        do_op "master_op" "stop" "Stopping buildmaster"
-        exit $?
-        ;;
-    reload)
-        do_op "master_op" "reload" "Reloading buildmaster"
-        exit $?
-        ;;
-    restart|force-reload)
-        do_op "master_op" "restart" "Restarting buildmaster"
-        exit $?
-        ;;
-    *)
-        echo "Usage: $0 {start|stop|restart|reload|force-reload}"
-        exit 1
-        ;;
-esac
-
-exit 0

installers/etc/init.d/buildslave

-#!/bin/bash
-
-### Maintain compatibility with chkconfig
-# chkconfig: 2345 83 17
-# description: buildslave
-
-### BEGIN INIT INFO
-# Provides:          buildslave
-# Required-Start:    $remote_fs
-# Required-Stop:     $remote_fs
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-### END INIT INFO
-
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
-SLAVE_RUNNER=/usr/bin/buildslave
-
-. /lib/lsb/init-functions
-
-# Source buildslave configuration 
-[[ -r /etc/default/buildslave ]] && . /etc/default/buildslave
-#[[ -r /etc/sysconfig/buildslave ]] && . /etc/sysconfig/buildslave
-
-# Or define/override the configuration here
-#SLAVE_ENABLED[1]=0                    # 0-enabled, other-disabled
-#SLAVE_NAME[1]="buildslave #1"         # short name printed on start/stop
-#SLAVE_USER[1]="buildbot"              # user to run slave as
-#SLAVE_BASEDIR[1]=""                   # basedir to slave (absolute path)
-#SLAVE_OPTIONS[1]=""                   # buildbot options  
-#SLAVE_PREFIXCMD[1]=""                 # prefix command, i.e. nice, linux32, dchroot
-
-if [[ ! -x ${SLAVE_RUNNER} ]]; then
-    log_failure_msg "does not exist or not an executable file: ${SLAVE_RUNNER}"
-    exit 1
-fi
-
-function check_config() {
-    itemcount="${#SLAVE_ENABLED[@]}
-               ${#SLAVE_NAME[@]}
-               ${#SLAVE_USER[@]}
-               ${#SLAVE_BASEDIR[@]}
-               ${#SLAVE_OPTIONS[@]}
-               ${#SLAVE_PREFIXCMD[@]}" 
-
-    if [[ $(echo "$itemcount" | tr -d ' ' | sort -u | wc -l) -ne 1 ]]; then
-        log_failure_msg "SLAVE_* arrays must have an equal number of elements!"
-        return 1
-    fi
-
-    errors=0
-    for i in $( seq ${#SLAVE_ENABLED[@]} ); do
-        if [[ ${SLAVE_ENABLED[$i]} -ne 0 ]]; then 
-            log_failure_msg "buildslave #${i}: unknown run status"
-            errors=$(($errors+1))
-        fi
-
-        if [[ -z ${SLAVE_NAME[$i]} ]]; then
-            log_failure_msg "buildslave #${i}: no name"
-            errors=$(($errors+1))
-        fi
-
-        if [[ -z ${SLAVE_USER[$i]} ]]; then
-            log_failure_msg "buildslave #${i}: no run user specified"
-            errors=$( ($errors+1) )
-        elif ! getent passwd ${SLAVE_USER[$i]} >/dev/null; then
-            log_failure_msg "buildslave #${i}: unknown user ${SLAVE_USER[$i]}"
-            errors=$(($errors+1))
-        fi
-
-        if [[ ! -d "${SLAVE_BASEDIR[$i]}" ]]; then
-            log_failure_msg "buildslave ${i}: basedir does not exist ${SLAVE_BASEDIR[$i]}"
-            errors=$(($errors+1))
-        fi
-    done
-
-    [[ $errors == 0 ]]; return $?
-}
-
-check_config || exit $?
-
-function iscallable () { type $1 2>/dev/null | grep -q 'shell function'; }
-
-function slave_op () {
-    op=$1 ; mi=$2
-
-    ${SLAVE_PREFIXCMD[$1]} \
-    su -s /bin/sh \
-    -c "$SLAVE_RUNNER $op --quiet ${SLAVE_OPTIONS[$mi]} ${SLAVE_BASEDIR[$mi]}" \
-    - ${SLAVE_USER[$mi]}
-    return $?
-}
-
-function do_op () {
-    errors=0
-    for i in $( seq ${#SLAVE_ENABLED[@]} ); do
-        [[ ${SLAVE_ENABLED[$i]} -ne 0 ]] && continue
-
-        # Some rhels don't come with all the lsb goodies
-        if iscallable log_daemon_msg; then
-	        log_daemon_msg "$3 \"${SLAVE_NAME[$i]}\""
-            if eval $1 $2 $i; then
-                log_end_msg 0
-            else
-                log_end_msg 1
-                errors=$(($errors+1))
-            fi
-        else
-            if eval $1 $2 $i; then
-                log_success_msg "$3 \"${SLAVE_NAME[$i]}\""
-            else
-                log_failure_msg "$3 \"${SLAVE_NAME[$i]}\""
-                errors=$(($errors+1))
-            fi
-        fi
-    done
-    return $errors
-}
-
-case "$1" in
-    start)
-        do_op "slave_op" "start" "Starting buildslave"
-        exit $?
-        ;;
-    stop)
-        do_op "slave_op" "stop" "Stopping buildslave"
-        exit $?
-        ;;
-    reload)
-        do_op "slave_op" "reload" "Reloading buildslave"
-        exit $?
-        ;;
-    restart|force-reload)
-        do_op "slave_op" "restart" "Restarting buildslave"
-        exit $?
-        ;;
-    *)
-        echo "Usage: $0 {start|stop|restart|reload|force-reload}"
-        exit 1
-        ;;
-esac
-
-exit 0

installers/fabfile.py

-
-from utils import append_file
-
-def append_file_test():
-    from textwrap import dedent
-    txt = """It's a
-    test"""
-    
-    append_file("/tmp/append_test.txt", dedent(txt), comment="# howdy pardner'")
-    append_file("/tmp/append_test.txt", dedent(txt), comment="# howdy pardner'")

installers/mail.py

-"""
-Install email servers for smtp, imap, pop, antispam, etc.
-"""
-
-from fabric.operations import run, sudo, put
-
-def postfix(with_mysql=False, with_postgres=False):
-    packages = ['postfix']
-    if with_mysql:
-        packages.append('postfix-mysql')
-    if with_postgres:
-        packages.append('postfix-pgsql')
-    sudo("apt-get install %s" % " ".join(packages))

installers/memcached.py

-
-from fabric.api import local, sudo, warn
-from fabric.context_managers import cd
-
-def install_memcached(memcached_ram=None):
-    """
-    Install the memcache daemon
-    """
-    sudo("apt-get -q --yes install memcached")
-    if memcached_ram:
-        with cd("/etc"):
-            sudo("sed 's/^-m.*$/-m %s/' -i memcached.conf" % memcached_ram)
-        sudo("service memcached restart")

installers/path.py

-""" path.py - An object representing a path to a file or directory.
-
-Authors:
- Jason Orendorff <jason.orendorff\x40gmail\x2ecom>
- Mikhail Gusarov <dottedmag@dottedmag.net>
- Others - unfortunately attribution is lost
-
-Example:
-
-from path import path
-d = path('/home/guido/bin')
-for f in d.files('*.py'):
-    f.chmod(0755)
-
-This module requires Python 2.2 or later.
-"""
-
-
-# TODO
-#   - Tree-walking functions don't avoid symlink loops.  Matt Harrison
-#     sent me a patch for this.
-#   - Bug in write_text().  It doesn't support Universal newline mode.
-#   - Better error message in listdir() when self isn't a
-#     directory. (On Windows, the error message really sucks.)
-#   - Make sure everything has a good docstring.
-#   - Add methods for regex find and replace.
-#   - guess_content_type() method?
-#   - Perhaps support arguments to touch().
-
-from __future__ import generators
-
-import sys, warnings, os, fnmatch, glob, shutil, codecs, hashlib, errno
-
-__version__ = '2.2.2.990'
-__all__ = ['path']
-
-# Platform-specific support for path.owner
-if os.name == 'nt':
-    try:
-        import win32security
-    except ImportError:
-        win32security = None
-else:
-    try:
-        import pwd
-    except ImportError:
-        pwd = None
-
-# Pre-2.3 support.  Are unicode filenames supported?
-_base = str
-_getcwd = os.getcwd
-try:
-    if os.path.supports_unicode_filenames:
-        _base = unicode
-        _getcwd = os.getcwdu
-except AttributeError:
-    pass
-
-# Pre-2.3 workaround for basestring.
-try:
-    basestring
-except NameError:
-    basestring = (str, unicode)
-
-# Universal newline support
-_textmode = 'U'
-if hasattr(__builtins__, 'file') and not hasattr(file, 'newlines'):
-    _textmode = 'r'
-
-class TreeWalkWarning(Warning):
-    pass
-
-class path(_base):
-    """ Represents a filesystem path.
-
-    For documentation on individual methods, consult their
-    counterparts in os.path.
-    """
-
-    # --- Special Python methods.
-
-    def __repr__(self):
-        return 'path(%s)' % _base.__repr__(self)
-
-    # Adding a path and a string yields a path.
-    def __add__(self, more):
-        try:
-            resultStr = _base.__add__(self, more)
-        except TypeError:  #Python bug
-            resultStr = NotImplemented
-        if resultStr is NotImplemented:
-            return resultStr
-        return self.__class__(resultStr)
-
-    def __radd__(self, other):
-        if isinstance(other, basestring):
-            return self.__class__(other.__add__(self))
-        else:
-            return NotImplemented
-
-    # The / operator joins paths.
-    def __div__(self, rel):
-        """ fp.__div__(rel) == fp / rel == fp.joinpath(rel)
-
-        Join two path components, adding a separator character if
-        needed.
-        """
-        return self.__class__(os.path.join(self, rel))
-
-    # Make the / operator work even when true division is enabled.
-    __truediv__ = __div__
-
-    def getcwd(cls):
-        """ Return the current working directory as a path object. """
-        return cls(_getcwd())
-    getcwd = classmethod(getcwd)
-
-
-    # --- Operations on path strings.
-
-    isabs = os.path.isabs
-    def abspath(self):       return self.__class__(os.path.abspath(self))
-    def normcase(self):      return self.__class__(os.path.normcase(self))
-    def normpath(self):      return self.__class__(os.path.normpath(self))
-    def realpath(self):      return self.__class__(os.path.realpath(self))
-    def expanduser(self):    return self.__class__(os.path.expanduser(self))
-    def expandvars(self):    return self.__class__(os.path.expandvars(self))
-    def dirname(self):       return self.__class__(os.path.dirname(self))
-    basename = os.path.basename
-
-    def expand(self):
-        """ Clean up a filename by calling expandvars(),
-        expanduser(), and normpath() on it.
-
-        This is commonly everything needed to clean up a filename
-        read from a configuration file, for example.
-        """
-        return self.expandvars().expanduser().normpath()
-
-    def _get_namebase(self):
-        base, ext = os.path.splitext(self.name)
-        return base
-
-    def _get_ext(self):
-        f, ext = os.path.splitext(_base(self))
-        return ext
-
-    def _get_drive(self):
-        drive, r = os.path.splitdrive(self)
-        return self.__class__(drive)
-
-    parent = property(
-        dirname, None, None,
-        """ This path's parent directory, as a new path object.
-
-        For example, path('/usr/local/lib/libpython.so').parent == path('/usr/local/lib')
-        """)
-
-    name = property(
-        basename, None, None,
-        """ The name of this file or directory without the full path.
-
-        For example, path('/usr/local/lib/libpython.so').name == 'libpython.so'
-        """)
-
-    namebase = property(
-        _get_namebase, None, None,
-        """ The same as path.name, but with one file extension stripped off.
-
-        For example, path('/home/guido/python.tar.gz').name     == 'python.tar.gz',
-        but          path('/home/guido/python.tar.gz').namebase == 'python.tar'
-        """)
-
-    ext = property(
-        _get_ext, None, None,
-        """ The file extension, for example '.py'. """)
-
-    drive = property(
-        _get_drive, None, None,
-        """ The drive specifier, for example 'C:'.
-        This is always empty on systems that don't use drive specifiers.
-        """)
-
-    def splitpath(self):
-        """ p.splitpath() -> Return (p.parent, p.name). """
-        parent, child = os.path.split(self)
-        return self.__class__(parent), child
-
-    def splitdrive(self):
-        """ p.splitdrive() -> Return (p.drive, <the rest of p>).
-
-        Split the drive specifier from this path.  If there is
-        no drive specifier, p.drive is empty, so the return value
-        is simply (path(''), p).  This is always the case on Unix.
-        """
-        drive, rel = os.path.splitdrive(self)
-        return self.__class__(drive), rel
-
-    def splitext(self):
-        """ p.splitext() -> Return (p.stripext(), p.ext).
-
-        Split the filename extension from this path and return
-        the two parts.  Either part may be empty.
-
-        The extension is everything from '.' to the end of the
-        last path segment.  This has the property that if
-        (a, b) == p.splitext(), then a + b == p.
-        """
-        filename, ext = os.path.splitext(self)
-        return self.__class__(filename), ext
-
-    def stripext(self):
-        """ p.stripext() -> Remove one file extension from the path.
-
-        For example, path('/home/guido/python.tar.gz').stripext()
-        returns path('/home/guido/python.tar').
-        """
-        return self.splitext()[0]
-
-    if hasattr(os.path, 'splitunc'):
-        def splitunc(self):
-            unc, rest = os.path.splitunc(self)
-            return self.__class__(unc), rest
-
-        def _get_uncshare(self):
-            unc, r = os.path.splitunc(self)
-            return self.__class__(unc)
-
-        uncshare = property(
-            _get_uncshare, None, None,
-            """ The UNC mount point for this path.
-            This is empty for paths on local drives. """)
-
-    def joinpath(self, *args):
-        """ Join two or more path components, adding a separator
-        character (os.sep) if needed.  Returns a new path
-        object.
-        """
-        return self.__class__(os.path.join(self, *args))
-
-    def splitall(self):
-        r""" Return a list of the path components in this path.
-
-        The first item in the list will be a path.  Its value will be
-        either os.curdir, os.pardir, empty, or the root directory of
-        this path (for example, '/' or 'C:\\').  The other items in
-        the list will be strings.
-
-        path.path.joinpath(*result) will yield the original path.
-        """
-        parts = []
-        loc = self
-        while loc != os.curdir and loc != os.pardir:
-            prev = loc
-            loc, child = prev.splitpath()
-            if loc == prev:
-                break
-            parts.append(child)
-        parts.append(loc)
-        parts.reverse()
-        return parts
-
-    def relpath(self):
-        """ Return this path as a relative path,
-        based from the current working directory.
-        """
-        cwd = self.__class__(os.getcwd())
-        return cwd.relpathto(self)
-
-    def relpathto(self, dest):
-        """ Return a relative path from self to dest.
-
-        If there is no relative path from self to dest, for example if
-        they reside on different drives in Windows, then this returns
-        dest.abspath().
-        """
-        origin = self.abspath()
-        dest = self.__class__(dest).abspath()
-
-        orig_list = origin.normcase().splitall()
-        # Don't normcase dest!  We want to preserve the case.
-        dest_list = dest.splitall()
-
-        if orig_list[0] != os.path.normcase(dest_list[0]):
-            # Can't get here from there.
-            return dest
-
-        # Find the location where the two paths start to differ.
-        i = 0
-        for start_seg, dest_seg in zip(orig_list, dest_list):
-            if start_seg != os.path.normcase(dest_seg):
-                break
-            i += 1
-
-        # Now i is the point where the two paths diverge.
-        # Need a certain number of "os.pardir"s to work up
-        # from the origin to the point of divergence.
-        segments = [os.pardir] * (len(orig_list) - i)
-        # Need to add the diverging part of dest_list.
-        segments += dest_list[i:]
-        if len(segments) == 0:
-            # If they happen to be identical, use os.curdir.
-            relpath = os.curdir
-        else:
-            relpath = os.path.join(*segments)
-        return self.__class__(relpath)
-
-    # --- Listing, searching, walking, and matching
-
-    def listdir(self, pattern=None):
-        """ D.listdir() -> List of items in this directory.
-
-        Use D.files() or D.dirs() instead if you want a listing
-        of just files or just subdirectories.
-
-        The elements of the list are path objects.
-
-        With the optional 'pattern' argument, this only lists
-        items whose names match the given pattern.
-        """
-        names = os.listdir(self)
-        if pattern is not None:
-            names = fnmatch.filter(names, pattern)
-        return [self / child for child in names]
-
-    def dirs(self, pattern=None):
-        """ D.dirs() -> List of this directory's subdirectories.
-
-        The elements of the list are path objects.
-        This does not walk recursively into subdirectories
-        (but see path.walkdirs).
-
-        With the optional 'pattern' argument, this only lists
-        directories whose names match the given pattern.  For
-        example, d.dirs('build-*').
-        """
-        return [p for p in self.listdir(pattern) if p.isdir()]
-
-    def files(self, pattern=None):
-        """ D.files() -> List of the files in this directory.
-
-        The elements of the list are path objects.
-        This does not walk into subdirectories (see path.walkfiles).
-
-        With the optional 'pattern' argument, this only lists files
-        whose names match the given pattern.  For example,
-        d.files('*.pyc').
-        """
-        
-        return [p for p in self.listdir(pattern) if p.isfile()]
-
-    def walk(self, pattern=None, errors='strict'):
-        """ D.walk() -> iterator over files and subdirs, recursively.
-
-        The iterator yields path objects naming each child item of
-        this directory and its descendants.  This requires that
-        D.isdir().
-
-        This performs a depth-first traversal of the directory tree.
-        Each directory is returned just before all its children.
-
-        The errors= keyword argument controls behavior when an
-        error occurs.  The default is 'strict', which causes an
-        exception.  The other allowed values are 'warn', which
-        reports the error via warnings.warn(), and 'ignore'.
-        """
-        if errors not in ('strict', 'warn', 'ignore'):
-            raise ValueError("invalid errors parameter")
-
-        try:
-            childList = self.listdir()
-        except Exception:
-            if errors == 'ignore':
-                return
-            elif errors == 'warn':
-                warnings.warn(
-                    "Unable to list directory '%s': %s"
-                    % (self, sys.exc_info()[1]),
-                    TreeWalkWarning)
-                return
-            else:
-                raise
-
-        for child in childList:
-            if pattern is None or child.fnmatch(pattern):
-                yield child
-            try:
-                isdir = child.isdir()
-            except Exception:
-                if errors == 'ignore':
-                    isdir = False
-                elif errors == 'warn':
-                    warnings.warn(
-                        "Unable to access '%s': %s"
-                        % (child, sys.exc_info()[1]),
-                        TreeWalkWarning)
-                    isdir = False
-                else:
-                    raise
-
-            if isdir:
-                for item in child.walk(pattern, errors):
-                    yield item
-
-    def walkdirs(self, pattern=None, errors='strict'):
-        """ D.walkdirs() -> iterator over subdirs, recursively.
-
-        With the optional 'pattern' argument, this yields only
-        directories whose names match the given pattern.  For
-        example, mydir.walkdirs('*test') yields only directories
-        with names ending in 'test'.
-
-        The errors= keyword argument controls behavior when an
-        error occurs.  The default is 'strict', which causes an
-        exception.  The other allowed values are 'warn', which
-        reports the error via warnings.warn(), and 'ignore'.
-        """
-        if errors not in ('strict', 'warn', 'ignore'):
-            raise ValueError("invalid errors parameter")
-
-        try:
-            dirs = self.dirs()
-        except Exception:
-            if errors == 'ignore':
-                return
-            elif errors == 'warn':
-                warnings.warn(
-                    "Unable to list directory '%s': %s"
-                    % (self, sys.exc_info()[1]),
-                    TreeWalkWarning)
-                return
-            else:
-                raise
-
-        for child in dirs:
-            if pattern is None or child.fnmatch(pattern):
-                yield child
-            for subsubdir in child.walkdirs(pattern, errors):
-                yield subsubdir
-
-    def walkfiles(self, pattern=None, errors='strict'):
-        """ D.walkfiles() -> iterator over files in D, recursively.
-
-        The optional argument, pattern, limits the results to files
-        with names that match the pattern.  For example,
-        mydir.walkfiles('*.tmp') yields only files with the .tmp
-        extension.
-        """
-        if errors not in ('strict', 'warn', 'ignore'):
-            raise ValueError("invalid errors parameter")
-
-        try:
-            childList = self.listdir()
-        except Exception:
-            if errors == 'ignore':
-                return
-            elif errors == 'warn':
-                warnings.warn(
-                    "Unable to list directory '%s': %s"
-                    % (self, sys.exc_info()[1]),
-                    TreeWalkWarning)
-                return
-            else:
-                raise
-
-        for child in childList:
-            try:
-                isfile = child.isfile()
-                isdir = not isfile and child.isdir()
-            except:
-                if errors == 'ignore':
-                    continue
-                elif errors == 'warn':
-                    warnings.warn(
-                        "Unable to access '%s': %s"
-                        % (self, sys.exc_info()[1]),
-                        TreeWalkWarning)
-                    continue
-                else:
-                    raise
-
-            if isfile:
-                if pattern is None or child.fnmatch(pattern):
-                    yield child
-            elif isdir:
-                for f in child.walkfiles(pattern, errors):
-                    yield f
-
-    def fnmatch(self, pattern):
-        """ Return True if self.name matches the given pattern.
-
-        pattern - A filename pattern with wildcards,
-            for example '*.py'.
-        """
-        return fnmatch.fnmatch(self.name, pattern)
-
-    def glob(self, pattern):
-        """ Return a list of path objects that match the pattern.
-
-        pattern - a path relative to this directory, with wildcards.
-
-        For example, path('/users').glob('*/bin/*') returns a list
-        of all the files users have in their bin directories.
-        """
-        cls = self.__class__
-        return [cls(s) for s in glob.glob(_base(self / pattern))]
-
-
-    # --- Reading or writing an entire file at once.
-
-    def open(self, mode='r'):
-        """ Open this file.  Return a file object. """
-        return open(self, mode)
-
-    def bytes(self):
-        """ Open this file, read all bytes, return them as a string. """
-        f = self.open('rb')
-        try:
-            return f.read()
-        finally:
-            f.close()
-
-    def write_bytes(self, bytes, append=False):
-        """ Open this file and write the given bytes to it.
-
-        Default behavior is to overwrite any existing file.
-        Call p.write_bytes(bytes, append=True) to append instead.
-        """
-        if append:
-            mode = 'ab'
-        else:
-            mode = 'wb'
-        f = self.open(mode)
-        try:
-            f.write(bytes)
-        finally:
-            f.close()
-
-    def text(self, encoding=None, errors='strict'):
-        r""" Open this file, read it in, return the content as a string.
-
-        This uses 'U' mode in Python 2.3 and later, so '\r\n' and '\r'
-        are automatically translated to '\n'.
-
-        Optional arguments:
-
-        encoding - The Unicode encoding (or character set) of
-            the file.  If present, the content of the file is
-            decoded and returned as a unicode object; otherwise
-            it is returned as an 8-bit str.
-        errors - How to handle Unicode errors; see help(str.decode)
-            for the options.  Default is 'strict'.
-        """
-        if encoding is None:
-            # 8-bit
-            f = self.open(_textmode)
-            try:
-                return f.read()
-            finally:
-                f.close()
-        else:
-            # Unicode
-            f = codecs.open(self, 'r', encoding, errors)
-            # (Note - Can't use 'U' mode here, since codecs.open
-            # doesn't support 'U' mode, even in Python 2.3.)
-            try:
-                t = f.read()
-            finally:
-                f.close()
-            return (t.replace(u'\r\n', u'\n')
-                     .replace(u'\r\x85', u'\n')
-                     .replace(u'\r', u'\n')
-                     .replace(u'\x85', u'\n')
-                     .replace(u'\u2028', u'\n'))
-
-    def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False):
-        r""" Write the given text to this file.
-
-        The default behavior is to overwrite any existing file;
-        to append instead, use the 'append=True' keyword argument.
-
-        There are two differences between path.write_text() and
-        path.write_bytes(): newline handling and Unicode handling.
-        See below.
-
-        Parameters:
-
-          - text - str/unicode - The text to be written.
-
-          - encoding - str - The Unicode encoding that will be used.
-            This is ignored if 'text' isn't a Unicode string.
-
-          - errors - str - How to handle Unicode encoding errors.
-            Default is 'strict'.  See help(unicode.encode) for the
-            options.  This is ignored if 'text' isn't a Unicode
-            string.
-
-          - linesep - keyword argument - str/unicode - The sequence of
-            characters to be used to mark end-of-line.  The default is
-            os.linesep.  You can also specify None; this means to
-            leave all newlines as they are in 'text'.
-
-          - append - keyword argument - bool - Specifies what to do if
-            the file already exists (True: append to the end of it;
-            False: overwrite it.)  The default is False.
-
-
-        --- Newline handling.
-
-        write_text() converts all standard end-of-line sequences
-        ('\n', '\r', and '\r\n') to your platform's default end-of-line
-        sequence (see os.linesep; on Windows, for example, the
-        end-of-line marker is '\r\n').
-
-        If you don't like your platform's default, you can override it
-        using the 'linesep=' keyword argument.  If you specifically want
-        write_text() to preserve the newlines as-is, use 'linesep=None'.
-
-        This applies to Unicode text the same as to 8-bit text, except
-        there are three additional standard Unicode end-of-line sequences:
-        u'\x85', u'\r\x85', and u'\u2028'.
-
-        (This is slightly different from when you open a file for
-        writing with fopen(filename, "w") in C or file(filename, 'w')
-        in Python.)
-
-
-        --- Unicode
-
-        If 'text' isn't Unicode, then apart from newline handling, the
-        bytes are written verbatim to the file.  The 'encoding' and
-        'errors' arguments are not used and must be omitted.
-
-        If 'text' is Unicode, it is first converted to bytes using the
-        specified 'encoding' (or the default encoding if 'encoding'
-        isn't specified).  The 'errors' argument applies only to this
-        conversion.
-
-        """
-        if isinstance(text, unicode):
-            if linesep is not None:
-                # Convert all standard end-of-line sequences to
-                # ordinary newline characters.
-                text = (text.replace(u'\r\n', u'\n')
-                            .replace(u'\r\x85', u'\n')
-                            .replace(u'\r', u'\n')
-                            .replace(u'\x85', u'\n')
-                            .replace(u'\u2028', u'\n'))
-                text = text.replace(u'\n', linesep)
-            if encoding is None:
-                encoding = sys.getdefaultencoding()
-            bytes = text.encode(encoding, errors)
-        else:
-            # It is an error to specify an encoding if 'text' is
-            # an 8-bit string.
-            assert encoding is None
-
-            if linesep is not None:
-                text = (text.replace('\r\n', '\n')
-                            .replace('\r', '\n'))
-                bytes = text.replace('\n', linesep)
-
-        self.write_bytes(bytes, append)
-
-    def lines(self, encoding=None, errors='strict', retain=True):
-        r""" Open this file, read all lines, return them in a list.
-
-        Optional arguments:
-            encoding - The Unicode encoding (or character set) of
-                the file.  The default is None, meaning the content
-                of the file is read as 8-bit characters and returned
-                as a list of (non-Unicode) str objects.
-            errors - How to handle Unicode errors; see help(str.decode)
-                for the options.  Default is 'strict'
-            retain - If true, retain newline characters; but all newline
-                character combinations ('\r', '\n', '\r\n') are
-                translated to '\n'.  If false, newline characters are
-                stripped off.  Default is True.
-
-        This uses 'U' mode in Python 2.3 and later.
-        """
-        if encoding is None and retain:
-            f = self.open(_textmode)
-            try:
-                return f.readlines()
-            finally:
-                f.close()
-        else:
-            return self.text(encoding, errors).splitlines(retain)
-
-    def write_lines(self, lines, encoding=None, errors='strict',
-                    linesep=os.linesep, append=False):
-        r""" Write the given lines of text to this file.
-
-        By default this overwrites any existing file at this path.
-
-        This puts a platform-specific newline sequence on every line.
-        See 'linesep' below.
-
-        lines - A list of strings.
-
-        encoding - A Unicode encoding to use.  This applies only if
-            'lines' contains any Unicode strings.
-
-        errors - How to handle errors in Unicode encoding.  This
-            also applies only to Unicode strings.
-
-        linesep - The desired line-ending.  This line-ending is
-            applied to every line.  If a line already has any
-            standard line ending ('\r', '\n', '\r\n', u'\x85',
-            u'\r\x85', u'\u2028'), that will be stripped off and
-            this will be used instead.  The default is os.linesep,
-            which is platform-dependent ('\r\n' on Windows, '\n' on
-            Unix, etc.)  Specify None to write the lines as-is,
-            like file.writelines().
-
-        Use the keyword argument append=True to append lines to the
-        file.  The default is to overwrite the file.  Warning:
-        When you use this with Unicode data, if the encoding of the
-        existing data in the file is different from the encoding
-        you specify with the encoding= parameter, the result is
-        mixed-encoding data, which can really confuse someone trying
-        to read the file later.
-        """
-        if append:
-            mode = 'ab'
-        else:
-            mode = 'wb'
-        f = self.open(mode)
-        try:
-            for line in lines:
-                isUnicode = isinstance(line, unicode)
-                if linesep is not None:
-                    # Strip off any existing line-end and add the
-                    # specified linesep string.
-                    if isUnicode:
-                        if line[-2:] in (u'\r\n', u'\x0d\x85'):
-                            line = line[:-2]
-                        elif line[-1:] in (u'\r', u'\n',
-                                           u'\x85', u'\u2028'):
-                            line = line[:-1]
-                    else:
-                        if line[-2:] == '\r\n':
-                            line = line[:-2]
-                        elif line[-1:] in ('\r', '\n'):
-                            line = line[:-1]
-                    line += linesep
-                if isUnicode:
-                    if encoding is None:
-                        encoding = sys.getdefaultencoding()
-                    line = line.encode(encoding, errors)
-                f.write(line)
-        finally:
-            f.close()
-
-    def read_md5(self):
-        """ Calculate the md5 hash for this file.
-
-        This reads through the entire file.
-        """
-        return self.read_hash('md5')
-
-    def _hash(self, hash_name):
-        f = self.open('rb')
-        try:
-            m = hashlib.new(hash_name)
-            while True:
-                d = f.read(8192)
-                if not d:
-                    break
-                m.update(d)
-            return m
-        finally:
-            f.close()
-
-    def read_hash(self, hash_name):
-        """ Calculate given hash for this file.
-
-        List of supported hashes can be obtained from hashlib package. This
-        reads the entire file.
-        """
-        return self._hash(hash_name).digest()
-
-    def read_hexhash(self, hash_name):
-        """ Calculate given hash for this file, returning hexdigest.
-
-        List of supported hashes can be obtained from hashlib package. This
-        reads the entire file.
-        """
-        return self._hash(hash_name).hexdigest()
-
-    # --- Methods for querying the filesystem.
-
-    exists = os.path.exists
-    isdir = os.path.isdir
-    isfile = os.path.isfile
-    islink = os.path.islink
-    ismount = os.path.ismount
-
-    if hasattr(os.path, 'samefile'):
-        samefile = os.path.samefile
-
-    getatime = os.path.getatime
-    atime = property(
-        getatime, None, None,
-        """ Last access time of the file. """)
-
-    getmtime = os.path.getmtime
-    mtime = property(
-        getmtime, None, None,
-        """ Last-modified time of the file. """)
-
-    if hasattr(os.path, 'getctime'):
-        getctime = os.path.getctime
-        ctime = property(
-            getctime, None, None,
-            """ Creation time of the file. """)
-
-    getsize = os.path.getsize
-    size = property(
-        getsize, None, None,
-        """ Size of the file, in bytes. """)
-
-    if hasattr(os, 'access'):
-        def access(self, mode):
-            """ Return true if current user has access to this path.
-
-            mode - One of the constants os.F_OK, os.R_OK, os.W_OK, os.X_OK
-            """
-            return os.access(self, mode)
-
-    def stat(self):
-        """ Perform a stat() system call on this path. """
-        return os.stat(self)
-
-    def lstat(self):
-        """ Like path.stat(), but do not follow symbolic links. """
-        return os.lstat(self)
-
-    def get_owner(self):
-        r""" Return the name of the owner of this file or directory.
-
-        This follows symbolic links.
-
-        On Windows, this returns a name of the form ur'DOMAIN\User Name'.
-        On Windows, a group can own a file or directory.
-        """
-        if os.name == 'nt':
-            if win32security is None:
-                raise Exception("path.owner requires win32all to be installed")
-            desc = win32security.GetFileSecurity(
-                self, win32security.OWNER_SECURITY_INFORMATION)
-            sid = desc.GetSecurityDescriptorOwner()
-            account, domain, typecode = win32security.LookupAccountSid(None, sid)
-            return domain + u'\\' + account
-        else:
-            if pwd is None:
-                raise NotImplementedError("path.owner is not implemented on this platform.")
-            st = self.stat()
-            return pwd.getpwuid(st.st_uid).pw_name
-
-    owner = property(
-        get_owner, None, None,
-        """ Name of the owner of this file or directory. """)
-
-    if hasattr(os, 'statvfs'):
-        def statvfs(self):
-            """ Perform a statvfs() system call on this path. """
-            return os.statvfs(self)
-
-    if hasattr(os, 'pathconf'):
-        def pathconf(self, name):
-            return os.pathconf(self, name)
-
-
-    # --- Modifying operations on files and directories
-
-    def utime(self, times):
-        """ Set the access and modified times of this file. """
-        os.utime(self, times)
-
-    def chmod(self, mode):
-        os.chmod(self, mode)
-
-    if hasattr(os, 'chown'):
-        def chown(self, uid, gid):
-            os.chown(self, uid, gid)
-
-    def rename(self, new):
-        os.rename(self, new)
-
-    def renames(self, new):
-        os.renames(self, new)
-
-
-    # --- Create/delete operations on directories
-
-    def mkdir(self, mode=0777):
-        os.mkdir(self, mode)
-
-    def mkdir_p(self, mode=0777):
-        try:
-            self.mkdir(mode)
-        except OSError, e:
-            if e.errno != errno.EEXIST:
-                raise
-
-    def makedirs(self, mode=0777):
-        os.makedirs(self, mode)
-
-    def makedirs_p(self, mode=0777):
-        try:
-            self.makedirs(mode)
-        except OSError, e:
-            if e.errno != errno.EEXIST:
-                raise
-
-    def rmdir(self):
-        os.rmdir(self)
-
-    def rmdir_p(self):
-        try:
-            self.rmdir()
-        except OSError, e:
-            if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST:
-                raise
-
-    def removedirs(self):
-        os.removedirs(self)
-
-    def removedirs_p(self):
-        try:
-            self.removedirs()
-        except OSError, e:
-            if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST:
-                raise
-
-    # --- Modifying operations on files
-
-    def touch(self):
-        """ Set the access/modified times of this file to the current time.
-        Create the file if it does not exist.
-        """
-        fd = os.open(self, os.O_WRONLY | os.O_CREAT, 0666)
-        os.close(fd)
-        os.utime(self, None)
-
-    def remove(self):
-        os.remove(self)
-
-    def remove_p(self):
-        try:
-            self.unlink()
-        except OSError, e:
-            if e.errno != errno.ENOENT:
-                raise
-
-    def unlink(self):
-        os.unlink(self)
-
-    def unlink_p(self):
-        self.remove_p()
-
-    # --- Links
-
-    if hasattr(os, 'link'):
-        def link(self, newpath):
-            """ Create a hard link at 'newpath', pointing to this file. """
-            os.link(self, newpath)
-
-    if hasattr(os, 'symlink'):
-        def symlink(self, newlink):
-            """ Create a symbolic link at 'newlink', pointing here. """
-            os.symlink(self, newlink)
-
-    if hasattr(os, 'readlink'):
-        def readlink(self):
-            """ Return the path to which this symbolic link points.
-
-            The result may be an absolute or a relative path.
-            """
-            return self.__class__(os.readlink(self))
-
-        def readlinkabs(self):
-            """ Return the path to which this symbolic link points.
-
-            The result is always an absolute path.
-            """
-            p = self.readlink()
-            if p.isabs():
-                return p
-            else:
-                return (self.parent / p).abspath()
-
-
-    # --- High-level functions from shutil
-
-    copyfile = shutil.copyfile
-    copymode = shutil.copymode
-    copystat = shutil.copystat
-    copy = shutil.copy
-    copy2 = shutil.copy2
-    copytree = shutil.copytree
-    if hasattr(shutil, 'move'):
-        move = shutil.move
-    rmtree = shutil.rmtree
-
-
-    # --- Special stuff from os
-
-    if hasattr(os, 'chroot'):
-        def chroot(self):
-            os.chroot(self)
-
-    if hasattr(os, 'startfile'):
-        def startfile(self):
-            os.startfile(self)
-

installers/postgresql.py

-
-from fabric.api import local, sudo, warn
-from fabric.context_managers import cd
-from datetime import datetime
-from textwrap import dedent
-
-def check_repo(version):
-    if float(version) >= 9.0:
-        sudo("add-apt-repository ppa:pitti/postgresql")
-        sudo("apt-get --yes update")
-    
-def install_postgresql_server(version, root_pass, listen_addr='127.0.0.1',
-                              access_net=None, tuning=None):
-    """
-    Install postgresql. Optionally set production tuning params (see 
-    http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
-
-    Arguments:
-    version -- string of postgresql version #, e.g., '9.0',
-    root_pass -- password for the postgres db user,
-    listen_addr -- ip addr to listen on,
-    access_net -- netmask with addr range to allow md5 login from,
-    tuning -- optional dict with kernel_shmmax, kernel_shmall, 
-              overcommit_memory, ... keys for os tuning
-    """
-    
-    # install
-    check_repo(version)
-    sudo("apt-get -q --yes install postgresql-%s" % version)
-
-    conf_dir = '/etc/postgresql/%s/main' % version
-        
-    # postgres password
-    sql = "ALTER USER postgres WITH UNENCRYPTED PASSWORD '%s';" % root_pass
-    sudo('bash -c psql template1 <<<"%s"' % sql, user='postgres')
-    
-    # listen address
-    with cd(conf_dir):
-        sed = "s/#+listen_addresses *=.*/listen_addresses = '%s'/" % listen_addr
-        sudo('sed --in-place=.orig "%s" postgresql.conf' % sed)
-
-    # access_net
-    if access_net:
-        with cd(conf_dir):
-            sudo("echo 'host    all             all             %s        md5' >>pg_hba.conf" % access_net)
-        
-    if tuning:
-        tuning['now'] = tuning.get('now', str(datetime.now()))
-        with cd("/etc/"):
-            # kernel params
-            warn("sysctl -w kernel.shmmax=%(kernel_shmmax)s ; "
-                 "sysctl -w kernel.shmall=%(kernel_shmall)s ; "
-                 "sysctl -w vm.overcommit_memory=2" % tuning)
-            conf = '''
-            #
-            # settings added by rmsfab on %(now)s
-            #
-            kernel.shmmax=%(kernel_shmmax)s
-            kernel.shmall=%(kernel_shmall)s
-            vm.overcommit_memory=2
-            
-            # end of settings added by rmsfab on %(now)s
-            ''' % tuning
-            sudo('cat >>sysctl.conf <<EOF%sEOF' % dedent(conf))
-
-        with cd(conf_dir):            
-            # postgres paramsshmall
-            conf = '''
-            ##
-            ## settings added by rmsfab on %(now)s
-            ##
-            max_connections                 = %(max_connections)s
-
-            ## memory
-            shared_buffers                  = %(shared_buffers)s
-            work_mem                        = %(work_mem)s
-            maintenance_work_mem            = %(maintenance_work_mem)s
-            
-            ## planner
-            effective_cache_size            = %(effective_cache_size)s
-            random_page_cost                = %(random_page_cost)s
-            
-            ## Logging
-            log_destination                 = 'syslog'
-            log_min_duration_statement      = 100
-            log_statement                   = 'ddl'
-            log_line_prefix                 = '%%t:%%r:%%u@%%d:[%%p]: '
-            
-            # end of settings added by rmsfab on %(now)s
-            ''' % tuning
-            sudo('cat >>postgresql.conf <<EOF%sEOF' % dedent(conf))
-
-    sudo("service postgresql restart")
-
-def install_postgresql_client(version, contrib=False, pgadmin=False):
-    # install
-    check_repo(version)
-    sudo("apt-get -q --yes install postgresql-client-%s libpq-dev" % version)
-    if contrib:
-        sudo("apt-get -q --yes install postgresql-contrib-%s" % version)
-    if pgadmin:
-        sudo("apt-get -q --yes install pgadmin3")
-        
-
-    
-    

installers/python.py

-"""
-Install and setup python virtualenv and virtualenvwrapper
-"""
-
-from os import getenv
-from datetime import datetime
-from textwrap import dedent
-from fabric.operations import sudo
-from path import path
-
-from utils import *
-
-DEFAULT_ENV_DIR = 'python-envs'
-
-def install_virtualenv(env_user, env_dir=DEFAULT_ENV_DIR):
-    """Install virtualenv and virtualenvwrapper, optionally setup for a user"""
-    sudo("pip install virtualenv virtualenvwrapper")
-    home = path(run("ls -d ~%s" % env_user))
-    env = { 'user': env_user, 'dir': home/env_dir }
-    sudo("test -e %(dir)s || mkdir -p %(dir)s && chown %(user)s:`id --group %(user)s` %(dir)s" % env)
-    sudo('export WORKON_HOME=%(dir)s ; source /usr/local/bin/virtualenvwrapper.sh' % env, user=env_user)
-    bashrc = home/".bashrc"
-    if bashrc.exists():
-        script = '''
-        export WORKON_HOME=%(dir)s
-        source /usr/local/bin/virtualenvwrapper.sh
-        ''' % env
-        append_file(bashrc, dedent(script), "## Updated by rmsfab on " + str(datetime.now()))
-    

installers/rabbitmq.py

-
-import re
-from os import readlink
-from fabric.api import local, sudo, warn, cd
-
-def install_rabbitmq(admin_pass):
-    sudo("add-apt-repository 'deb http://www.rabbitmq.com/debian/ testing main'")
-    sudo("curl http://www.rabbitmq.com/rabbitmq-signing-key-public.asc | "
-         "apt-key add -")
-    sudo("apt-get -q --yes update")
-    sudo("apt-get -q --yes install rabbitmq-server")
-    sudo("rabbitmqctl delete_user guest")
-    sudo("rabbitmqctl add_user admin %s" % admin_pass)
-    sudo("rabbitmqctl set_admin admin")
-    
-    try:
-        version = re.compile('\d(?:.\d)+').findall(readlink('/usr/lib/rabbitmq/bin/rabbitmq-server'))[0]
-    except Exception, e:
-        warn(repr(e) + ": Not installing rabbitmq management plugins")
-    else:
-        plugins = [ p % version for p in [ 'mochiweb-%s.ez', 
-                                           'amqp_client-%s.ez', 
-                                           'rabbitmq-mochiweb-%s.ez',
-                                           'rabbitmq-management-%s.ez', 
-                                           'webmachine-%s.ez', 
-                                           'rabbitmq-management-agent-%s.ez' ]]
-        with cd("/usr/lib/rabbitmq/lib/rabbitmq_server-%s/plugins" % version):
-            for plugin in plugins:
-                sudo("wget http://www.rabbitmq.com/releases/plugins/v%s/%s" % (version, plugin))
-                 
-    sudo("service rabbitmq-server restart")
-    

installers/scm.py

-
-from textwrap import dedent
-from datetime import datetime
-from fabric.api import local, sudo
-from utils import *
-
-def install_hg(tortoise=False):
-    """
-    Install mercurial stuff
-    """
-    # make sure we get the *latest* hg and tortoisehg
-    lsb = lsb_release()
-    if float(lsb['DISTRIB_RELEASE']) >= 10.0:
-        sudo("add-apt-repository ppa:tortoisehg-ppa/releases")
-        sudo("add-apt-repository ppa:mercurial-ppa/releases")
-    else:
-        sudo("cat <<<'%s' >>/etc/apt/sources.list" %
-             dedent("""
-             ## added by rmsfab on %(now)s
-             deb http://ppa.launchpad.net/mercurial-ppa/releases/ubuntu %(codename)s main 
-             deb-src http://ppa.launchpad.net/mercurial-ppa/releases/ubuntu %(codename)s main 
-             deb http://ppa.launchpad.net/tortoisehg-ppa/releases/ubuntu %(codename)s main 
-             deb-src http://ppa.launchpad.net/tortoisehg-ppa/releases/ubuntu %(codename)s main 
-             """ % {'now': datetime.now(), 'codename': lsb['DISTRIB_CODENAME']}))
-        sudo("apt-key adv --keyserver keyserver.ubuntu.com --recv-key D5056DDE")
-        sudo("apt-key adv --keyserver keyserver.ubuntu.com --recv-key 323293EE")
-    sudo("apt-get update")
-    sudo("apt-get -q --yes install mercurial")
-    sudo("pip install hg-git")
-
-    if tortoise:
-        sudo("apt-get -q --yes install tortoisehg tortoisehg-nautilus meld kdiff3")
-        
-def install_svn():
-    sudo("apt-get -q --yes install subversion")
-
-def install_git(gitk=True):
-    lsb = lsb_release()
-    if int(float(lsb['DISTRIB_RELEASE'])) == 10:
-        sudo("apt-get -q --yes install git-core")
-    else:
-        sudo("apt-get -q --yes install git")
-    if gitk:
-        sudo("apt-get -q --yes install gitk")
-

installers/utils.py

-
-from fabric.api import env, sudo, run
-from fabric.operations import put, get
-from fabric.context_managers import settings, hide
-from fabric.utils import warn, abort
-from os import system, remove
-from tempfile import NamedTemporaryFile
-
-
-def lsb_release():
-    """Return the /etc/lsb-release file as a dict"""
-    f = NamedTemporaryFile(delete=True)
-    f.close()
-    get('/etc/lsb-release', f.name)
-    return dict([ kv.strip().split('=') for kv in file(f.name).readlines() ])
-    
-
-def append_file(file_name, lines, comment="", dup_check=True, lf="\n"):
-    """
-    Append lines to a file. If dup_check, make sure those 
-    lines aren't already in the file
-    """
-
-    assert isinstance(lines, str) and isinstance(comment, str) and isinstance(lf, str)
-
-    if dup_check and find_remote(file_name, lines) > -1:
-        warn("'''%s''' already in %s, skipping" % (lines, file_name))
-    else:
-        f = NamedTemporaryFile(delete=False)
-        f.write(lf + comment + lf + lines + lf)
-        f.close()
-        remote = f.name + '-remote'
-        p = put(f.name, remote)
-        if p.succeeded:
-            sudo("cat %s" % remote)
-            sudo("cat %s >>%s && echo rm %s" % (remote, file_name, remote))
-        else:
-            abort("%s: unable to append text '''%s'''" % (file_name, lines))
-
-def find_remote(file_name, text):
-    """
-    Find text in a remote file
-    """
-    index = run('''python -c 'print open("%s").read().find("""%s""")' ''' % (file_name, text))
-    if index.failed:
-        return -1
-    return int(index)
-
-def file_exists(file_name):
-    """
-    Check if a remote file exists
-    """
-    with settings(
-        hide('warnings', 'running', 'stdout', 'stderr'),
-        warn_only=True
-    ):
-        return run('ls %s' % file_name).succeeded

installers/vm.py

-
-import re
-from datetime import datetime
-from fabric.operations import sudo, run
-from fabric.context_managers import cd
-from fabric.utils import warn
-from utils import lsb_release, append_file
-
-DEFAULT_VBOX_VERSION = '4.1'
-DEFAULT_VBOX_ALTINSTALLER = 'http://download.virtualbox.org/virtualbox/4.1.0/VirtualBox-4.1.0-73009-Linux_amd64.run'
-
-def install_virtualbox(version=DEFAULT_VBOX_VERSION):
-    apt_line = "deb http://download.virtualbox.org/virtualbox/debian %s contrib non-free" % lsb_release()['DISTRIB_CODENAME']
-    now = str(datetime.now())
-    append_file("/etc/apt/sources.list", apt_line, "## Updated by rmsfab on " + now)
-    sudo('curl http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc | sudo apt-key add -')
-    sudo('apt-get -q --yes install dkms')
-    sudo('apt-get update && sudo apt-get -q --yes install virtualbox-%s' % version)
-    sudo('usermod -G vboxusers -a $USER')
-
-
-def install_virtualbox_server(altinstaller_url=DEFAULT_VBOX_ALTINSTALLER, vbox_user = 'vbox'):
-    sudo('apt-get -q --yes install dkms')
-    with cd('/tmp'):
-        pattern = re.compile(r"(.+)/([^\d]+([\d.-]+)-[A-Za-z].*)")
-        (url, filename, build) = pattern.match(altinstaller_url).groups()
-        run('wget %s' % altinstaller_url)
-        sudo('sh %s install' % filename)
-        ext_filename = "Oracle_VM_VirtualBox_Extension_Pack-%s.vbox-extpack" % build
-        run('wget %s/%s' % (url, ext_filename))
-        sudo('vboxmanage extpack install %s' % ext_filename)
-        run('rm -f %s %s' % (filename, ext_filename))
-    sudo('useradd --create-home --user-group --groups vboxusers %s' % vbox_user)
-
-def install_phpvirtualbox():
-    warn('not yet implemented')
-    # with cd('/tmp'):
-    #     run('wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt` -O phpvirtualbox-latest.zip')
-    # with cd('/var/www'):
-        
-    

ubdev/fabfile.py

-"""
-Fabs for an Ubuntu dev system
-"""
-
-from os import path
-from sys import path as syspath
-pwd = path.abspath(path.dirname(__file__))
-syspath.insert(0, path.join(pwd, '..'))
-syspath.insert(0, pwd)
-
-from fabric.api import run, sudo, env, require, prompt, abort
-from fabric.context_managers import cd, settings
-from installers import scm, vm, utils, python
-
-def local():
-    """Use localhost as target"""
-    env.hosts = ['localhost']
-
-def virtualbox():
-    """Install the virtualbox vm server"""
-    vm.install_virtualbox()
-
-def scmtools():
-    """Install various scm related stuff, inc tortoise hg"""
-    scm.install_hg(tortoise=True)
-    scm.install_git()
-    scm.install_svn()
-
-def wing():
-    """The Wing python IDE"""
-    pkg = { 'url': "http://wingware.com/pub/wingide/4.0.2",
-            'deb': "wingide4.0_4.0.2-1_amd64.deb", }
-    with cd('/tmp'):
-        run("ls %(deb)s >& /dev/null || wget -nv %(url)s/%(deb)s" % pkg)
-        with settings(warn_only=True):
-            sudo("dpkg -i %(deb)s" % pkg)
-        # fix deps left behind by wing package
-        sudo("apt-get -q --yes -f install")
-
-def pythontools(user=None):
-    """virtualenv, virtualenvwrapper"""
-    from os import getenv
-    user = user or prompt("Virtualenvwrapper user: ", default=getenv('USER'))
-    python.install_virtualenv(user)
-
-def misc():
-    """Emacs and other simple/misc packages"""
-    packages = ( 'curl', 'emacs', 'emacs-goodies-el', )
-    for p in packages:
-        sudo('sudo apt-get -q --yes install %s' % p)
-
-def all():
-    """Setup whole enchilada except vbox for Ubuntu dev host"""
-    misc()
-    scmtools()
-    wing() 

ubsrv/fabfile.py

-"""
-Fabs for various functions/services on an Ubuntu server system
-"""
-
-from os import path
-from sys import path as syspath
-pwd = path.abspath(path.dirname(__file__))
-syspath.insert(0, path.join(pwd, '..'))
-syspath.insert(0, pwd)
-
-from fabric.api import run, sudo, env, require, prompt, abort
-from installers import scm, vm, utils, python, buildbot, mail
-
-def local():
-    """Use localhost as target"""
-    env.hosts = ['localhost']
-
-def virtualbox():
-    """Install the virtualbox vm server"""
-    vm.install_virtualbox_server()
-
-def scmtools():
-    """Install scm related stuff: hg, bit svn"""
-    scm.install_hg(tortoise=False)
-    scm.install_git(gitk=False)
-    scm.install_svn()
-