<commit_before>#!/usr/bin/python
#
# setup-server.py
#
# This script sets up things needed to run the server:
#   - sets up the python virtualenv
#   - checks for a valid local_settings.py file
#   - runs database migrations
#   - downloads web libraries
#   - builds and collects static media files (production only)
#
# It can also be used to update things after code changes.  On production you
# should probably run this whenever you pull in new code.  On dev, run it when
# a pip module or web library dependency changes.
#

import os
import subprocess

BASE_DIR = os.path.dirname(__file__)

def setup_virtualenv():
    subprocess.check_call(['env/bin/pip', 'install', '-r',
                           'requirements.txt'])

def manage(*command):
    subprocess.check_call(['env/bin/python', 'manage.py' ] + list(command))

def production():
    mod_dict = {}
    execfile(os.path.join(BASE_DIR, 'local_settings.py'), mod_dict)
    return not mod_dict.get('DEV')

def main():
    os.chdir(BASE_DIR)
    setup_virtualenv()
    manage('migrate')
    manage('buildmedia')
    if production():
        manage('collectstatic')
        # touch wsgi.py to make apache restart the wsgi daemon
        os.utime(os.path.join(BASE_DIR, 'wsgi.py'), None)

if __name__ == '__main__':
    main()<commit_msg>Don't require user to type "yes" for setup-server<commit_after>#!/usr/bin/python
#
# setup-server.py
#
# This script sets up things needed to run the server:
#   - sets up the python virtualenv
#   - checks for a valid local_settings.py file
#   - runs database migrations
#   - downloads web libraries
#   - builds and collects static media files (production only)
#
# It can also be used to update things after code changes.  On production you
# should probably run this whenever you pull in new code.  On dev, run it when
# a pip module or web library dependency changes.
#

import os
import subprocess

BASE_DIR = os.path.dirname(__file__)

def setup_virtualenv():
    subprocess.check_call(['env/bin/pip', 'install', '-r',
                           'requirements.txt'])

def manage(*command):
    subprocess.check_call(['env/bin/python', 'manage.py' ] + list(command))

def production():
    mod_dict = {}
    execfile(os.path.join(BASE_DIR, 'local_settings.py'), mod_dict)
    return not mod_dict.get('DEV')

def main():
    os.chdir(BASE_DIR)
    setup_virtualenv()
    manage('migrate')
    manage('buildmedia')
    if production():
        manage('collectstatic', '--noinput')
        # touch wsgi.py to make apache restart the wsgi daemon
        os.utime(os.path.join(BASE_DIR, 'wsgi.py'), None)

if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.11766931517215286, 'fraction_numerical': 0.0, 'mean_word_length': 3.3344262295081966, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7171735', 'n_tokens_mistral': 825, 'n_tokens_neox': 809, 'n_words': 257}