<commit_before>import os
import smtplib
from email.mime.text import MIMEText

from fabric.api import env, cd, run, shell_env, sudo, hosts, execute, settings, local
from fabric.colors import green

env.hosts = ['172.16.17.32']
env.user = 'root'
env.key_filename = '~/.ssh/id_di'
env.forward_agent = True


def deploy(js=False):
    if js:
        # TODO automatically figure out if produciton build needs updated
        # (we don't run webpack watch with produciton settings as that
        # generates files for intermediate states. We only want to run it
        # once before deployment)
        local('./node_modules/.bin/webpack -p --config webpack.prod.config.js')
        local('git add webpack-stats-prod.json ditto/static/dist')
        # TODO if last commit isn't pushed we could --amend and avoid
        # the extra commit
        local('git commit -m "Update production assets"')
    changes = local('git log heroku/master.. --oneline --no-color --reverse > /tmp/log; cat /tmp/log', capture=True)
    local('git push heroku master')
    for line in changes.splitlines():
        print green(line)
    with settings(warn_only=True):
        execute(email, changes)
    

def builddb():
    with cd('/srv/venv/ditto/ditto'):
        with shell_env(DJANGO_CONFIGURATION='Production', DJANGO_SETTINGS_MODULE='config.production'):
            sudo("echo 'drop database app_data;create database app_data' | ../../bin/python manage.py dbshell",
                 user="pydev")
            sudo("echo 'source /usr/lib/mongooseim//lib/ejabberd-2.1.8+mim-1.5.0/priv/mysql.sql' | ../../bin/python manage.py dbshell",
                 user="pydev")
            # Set up data for main site
            sudo(' ../../bin/python manage.py migrate',
                 user="pydev")
            sudo(' ../../bin/python manage.py runscript setup_test_data',
                 user="pydev")
    # Delete the mnesia database
    sudo('rm -rf /usr/lib/mongooseim/Mnesia*')
    # Restart chat so anything cached by the chat server is forgotten<commit_msg>Push to github as well as heroku on deploy<commit_after>import os
import smtplib
from email.mime.text import MIMEText

from fabric.api import env, cd, run, shell_env, sudo, hosts, execute, settings, local
from fabric.colors import green

env.hosts = ['172.16.17.32']
env.user = 'root'
env.key_filename = '~/.ssh/id_di'
env.forward_agent = True


def deploy(js=False):
    if js:
        # TODO automatically figure out if produciton build needs updated
        # (we don't run webpack watch with produciton settings as that
        # generates files for intermediate states. We only want to run it
        # once before deployment)
        local('./node_modules/.bin/webpack -p --config webpack.prod.config.js')
        local('git add webpack-stats-prod.json ditto/static/dist')
        # TODO if last commit isn't pushed we could --amend and avoid
        # the extra commit
        local('git commit -m "Update production assets"')
    changes = local('git log heroku/master.. --oneline --no-color --reverse > /tmp/log; cat /tmp/log', capture=True)
    local('git push origin master')
    local('git push heroku master')
    for line in changes.splitlines():
        print green(line)
    with settings(warn_only=True):
        execute(email, changes)
    

def builddb():
    with cd('/srv/venv/ditto/ditto'):
        with shell_env(DJANGO_CONFIGURATION='Production', DJANGO_SETTINGS_MODULE='config.production'):
            sudo("echo 'drop database app_data;create database app_data' | ../../bin/python manage.py dbshell",
                 user="pydev")
            sudo("echo 'source /usr/lib/mongooseim//lib/ejabberd-2.1.8+mim-1.5.0/priv/mysql.sql' | ../../bin/python manage.py dbshell",
                 user="pydev")
            # Set up data for main site
            sudo(' ../../bin/python manage.py migrate',
                 user="pydev")
            sudo(' ../../bin/python manage.py runscript setup_test_data',
                 user="pydev")
    # Delete the mnesia database
    sudo('rm -rf /usr/lib/mongooseim/Mnesia*')
    # Restart chat so anything cached by the chat server is forgotten
{'fraction_non_alphanumeric': 0.12147505422993492, 'fraction_numerical': 0.0072306579898770785, 'mean_word_length': 2.5683576956147895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '41002', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1218, 'n_words': 373}