<commit_before>from __future__ import with_statement
from fabric.api import run, env
from fabric.operations import local, put, sudo
from fabric.context_managers import cd

env.www_root = "/var/www/bitovod.com"
env.cache_dir = "%(www_root)s/hnbestof/var/cached-reports/" % env

def stage():
    env.user = 'user'
    env.hosts = ['stage.bitovod.com']

def prod():
    pass

def status():
    run('uname -a; uptime')

def setup():
    with cd(env.www_root):
        run('mkdir -p %(cache_dir)s' % env)
        sudo('chown :www-data %(cache_dir)s' % env)
        sudo('chmod g+w %(cache_dir)s' % env)
    <commit_msg>updated fabfile<commit_after>from __future__ import with_statement
from fabric.api import run, env, settings
from fabric.operations import local, put, sudo
from fabric.context_managers import cd, hide

env.www_root = "/var/www/bitovod.com"
env.project_root = "%(www_root)s/hnbestof" % env
env.cache_dir = "%(project_root)s/var/cached-reports/" % env
env.nginx_conf = "/etc/nginx/applications/rootdomain_50_hnbestof"
env.superv_conf = "/etc/supervisord.d/hnbestof.conf"
env.prune_cache = "%(www_root)s/prune_cache.sh" % env


def stage():
    env.user = 'user'
    env.hosts = ['stage.bitovod.com']


def prod():
    pass


def status():
    run('uname -a; uptime')


def setup():
    with cd(env.www_root):
        run('git clone git://github.com/pdfcrowd/hnbestof.git')
        run('mkdir -p %(cache_dir)s' % env)
        sudo('chown :www-data %(cache_dir)s' % env)
        run('chmod g+w %(cache_dir)s' % env)
    with cd(env.project_root):
        run('[ ! -f config.json ] && cp config.json.in config.json')
    setup_cron()


def setup_cron():
    with settings(hide('warnings'), warn_only=True):
        run('crontab -l > /tmp/mycron || touch /tmp/mycron')
        result = run('grep "%(prune_cache)s" /tmp/mycron' % env)
    if result.failed:
        run('echo "@hourly %(prune_cache)s" >> /tmp/mycron' % env)
        run('crontab /tmp/mycron')
        run('rm /tmp/mycron')


def publish():
    with cd(env.project_root):
        run('git pull origin master')
        run('npm install')   # 'npm bundle' removed in npm 1.0
        sudo('sed "s|PROJECT_DIR|`pwd`|g" conf/hnbestof.supervisor.conf | sudo tee %(superv_conf)s > /dev/null' % env)
        sudo('rm -f %(nginx_conf)s' % env)
        sudo('ln -s `pwd`/conf/hnbestof.nginx.conf %(nginx_conf)s' % env)
        sudo('kill -HUP `cat /var/run/nginx.pid`')
        sudo('supervisorctl update')
        sudo('supervisorctl restart hnbestof')

    
{'fraction_non_alphanumeric': 0.15946053153510512, 'fraction_numerical': 0.0015866719555731853, 'mean_word_length': 3.2103505843071787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 11, 'xml': 0}, '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': '2421924', 'n_tokens_mistral': 975, 'n_tokens_neox': 940, 'n_words': 201}