<commit_before>from fabric.api import local, lcd, run, cd, settings
import os


def update_repository(commit_args, directory="."):

    with lcd(directory):
        # with settings(warn_only=True):
        if local("git status --porcelain", capture=True):
            local("git add . ")
            local("git commit {}".format(commit_args))
            local("git push origin master")


def prepare(commit_args=""):

    # TODO: add testing
    update_repository(commit_args, directory="../swc_blog")

    local('python3 manage.py test')
    update_repository(commit_args)


def stage(project_dir, commit_args=""):
    prepare(commit_args)

    with settings(warn_only=True):
        if run("test -d {}".format(project_dir)).failed:
            run("sudo mkdir {}".format(project_dir))
            run("sudo git clone https://github.com/e9wikner/swc_site.git {}".format(
                project_dir))
            run("sudo chown -R http {}".format(project_dir))
            run("sudo chgrp -R http {}".format(project_dir))

    # Install blog app
    run("sudo pip install --upgrade git+https://github.com/e9wikner/swc_blog")

    with cd(project_dir):
        run("sudo git pull")
        run("sudo python3 manage.py makemigrations")
        run("sudo python3 manage.py migrate")


def deploy():
    prepare()

    with lcd('/path/to/my/prod/area/'):

        # With git...
        local('git pull /my/path/to/dev/area/')

        # With both
        local('python manage.py migrate myapp')
        local('python manage.py test myapp')
        local('/my/command/to/restart/webserver')<commit_msg>Fixed<commit_after>from fabric.api import local, lcd, run, cd, settings
import os


def update_repository(commit_args, directory="."):

    with lcd(directory):
        # with settings(warn_only=True):
        if local("git status --porcelain", capture=True):
            local("git add . ")
            local("git commit {}".format(commit_args))
            local("git push origin master")


def prepare(commit_args=""):

    # TODO: add testing
    update_repository(commit_args, directory="../swc_blog")

    local('python3 manage.py test')

    update_repository(commit_args)


def stage(project_dir, commit_args=""):
    prepare(commit_args)

    with settings(warn_only=True):
        if run("test -d {}".format(project_dir)).failed:
            run("sudo mkdir {}".format(project_dir))
            run("sudo git clone https://github.com/e9wikner/swc_site.git {}".format(
                project_dir))
            run("sudo chown -R http {}".format(project_dir))
            run("sudo chgrp -R http {}".format(project_dir))

    # Install blog app
    run("sudo pip install --upgrade git+https://github.com/e9wikner/swc_blog")

    with cd(project_dir):
        run("sudo git pull")
        run("sudo python3 manage.py makemigrations "
            "--settings=swc_site.settings.staging")
        run("sudo python3 manage.py migrate "
            "--settings=swc_site.settings.staging")


def deploy():
    prepare()

    with lcd('/path/to/my/prod/area/'):

        # With git...
        local('git pull /my/path/to/dev/area/')

        # With both
        local('python manage.py migrate myapp')
        local('python manage.py test myapp')
        local('/my/command/to/restart/webserver')
{'fraction_non_alphanumeric': 0.14134061267819228, 'fraction_numerical': 0.003033060357901122, 'mean_word_length': 2.624175824175824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, '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': '1811291', 'n_tokens_mistral': 1026, 'n_tokens_neox': 974, 'n_words': 227}