<commit_before>from fabdefs import *
from fabric import api
from fabric.operations import local
import os

python = "%s/bin/python" % env_dir
pip = "%s/bin/pip" % env_dir

def deploy():
    local("git push origin master")
    with api.cd(code_dir):
        api.run("git pull origin master")
        api.run("%s install -r %s/requirements/production.txt --quiet" % (pip, code_dir))

        with api.cd(os.path.join(code_dir, "server")):
            api.run("%s manage.py collectstatic --noinput --settings=settings.production" % python)

        api.sudo("supervisorctl restart mpr")

def update_database(url):
    """
    Update the database remotely. Expects a url to the updated xls file which can usually be foundat http://mpr.gov.za
    e.g.
    fab update_database:'http://mpr.gov.za/Publish/ViewDocument.aspx?DocumentPublicationId\=1488'
    """
    api.run("curl %s > /tmp/meds.xls" % url)
    with api.cd(code_dir):
        api.run("%s manage.py loaddata /tmp/meds.xls --settings=settings.production" % python)
    <commit_msg>Minor fabfile fixes<commit_after>from fabdefs import *
from fabric import api
from fabric.operations import local
import os

python = "%s/bin/python" % env_dir
pip = "%s/bin/pip" % env_dir
server_dir = os.path.join(code_dir, "server")

def deploy():
    local("git push origin master")
    with api.cd(code_dir):
        api.run("git pull origin master")
        api.run("%s install -r %s/requirements/production.txt --quiet" % (pip, code_dir))

        with api.cd(server_dir):
            api.run("%s manage.py collectstatic --noinput --settings=settings.production" % python)

        api.sudo("supervisorctl restart mpr")

def update_database(url):
    """
    Update the database remotely. Expects a url to the updated xls file which can usually be foundat http://mpr.gov.za
    e.g.
    fab update_database:'http://mpr.gov.za/Publish/ViewDocument.aspx?DocumentPublicationId\=1488'
    """
    api.run("curl %s > /tmp/meds.xls" % url)
    with api.cd(server_dir):
        api.run("%s manage.py loaddata /tmp/meds.xls --settings=settings.production" % python)
    
{'fraction_non_alphanumeric': 0.13640684410646386, 'fraction_numerical': 0.0038022813688212928, 'mean_word_length': 3.21, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '589413', 'n_tokens_mistral': 706, 'n_tokens_neox': 678, 'n_words': 174}