<commit_before>"""
Run and manage servers for local development.
"""
from __future__ import print_function
import sys
import argparse
from paver.easy import *
from .utils.cmd import django_cmd
from .utils.process import run_process, run_multi_processes


DEFAULT_PORT = {"lms": 8000, "studio": 8001}
DEFAULT_SETTINGS = 'dev'


def run_server(system, settings=None, port=None, skip_assets=False):
    """
    Start the server for the specified `system` (lms or studio).
    `settings` is the Django settings module to use; if not provided, use the default.
    `port` is the port to run the server on; if not provided, use the default port for the system.

    If `skip_assets` is True, skip the asset compilation step.
    """
    if system not in ['lms', 'studio']:
        print("System must be either lms or studio", file=sys.stderr)
        exit(1)

    if not skip_assets:
        # Local dev settings use staticfiles to serve assets, so we can skip the collecstatic step
        args = [system, '--settings={}'.format(settings), '--skip-collect', '--watch']
        call_task('pavelib.assets.update_assets', args=args)

    if port is None:
        port = DEFAULT_PORT[system]

    if settings is None:
        settings = DEFAULT_SETTINGS

    run_process(django_cmd(
        system, settings, 'runserver', '--traceback',
        '--pythonpath=.', '0.0.0.0:{}'.format(port)))


@task
@needs('pavelib.prereqs.install_prereqs')
@cmdopts([
    ("settings=", "s", "Django settings"),
    ("port=", "p", "Port"),
    ("fast", "f", "Skip updating assets")
])
def lms(options):
    """
    Run the LMS server.
    """
    settings = getattr(options, 'settings', None)
    port = getattr(options, 'port', None)
    fast = getattr(options, 'fast', False)
    run_server('lms', settings=settings, port=port, skip_assets=fast)


@task
@needs('pavelib.prereqs.install_prereqs')
@cmdopts([
    ("settings=", "s", "Django settings"),
    ("port=", "p", "Port"),
    ("fast", "f", "Skip updating assets")
])
def studio(options):
    """
    Run the Studio server.
    """
    settings = getattr(options, 'settings', None)
    port = getattr(options, 'port', None)
    fast = getattr(options, 'fast', False)
    run_server('studio', settings=settings, port=port, skip_assets=fast)


@task
@needs('pavelib.prereqs.install_prereqs')
@consume_args
def devstack(args):
    """
    Start the devstack lms or studio server
    """
    parser = argparse.ArgumentParser(prog='paver devstack')
    parser.add_argument('system', type=str, nargs=1, help="lms or studio")
    parser.add_argument('--fast', action='store_true', default=False, help="Skip updating assets")
    args = parser.parse_args(args)
    run_server(args.system[0], settings='devstack', skip_assets=args.fast)

<commit_msg>added paver task devstack_appsembler<commit_after>"""
Run and manage servers for local development.
"""
from __future__ import print_function
import sys
import argparse
from paver.easy import *
from .utils.cmd import django_cmd
from .utils.process import run_process, run_multi_processes


DEFAULT_PORT = {"lms": 8000, "studio": 8001}
DEFAULT_SETTINGS = 'dev'


def run_server(system, settings=None, port=None, skip_assets=False):
    """
    Start the server for the specified `system` (lms or studio).
    `settings` is the Django settings module to use; if not provided, use the default.
    `port` is the port to run the server on; if not provided, use the default port for the system.

    If `skip_assets` is True, skip the asset compilation step.
    """
    if system not in ['lms', 'studio']:
        print("System must be either lms or studio", file=sys.stderr)
        exit(1)

    if not skip_assets:
        # Local dev settings use staticfiles to serve assets, so we can skip the collecstatic step
        args = [system, '--settings={}'.format(settings), '--skip-collect', '--watch']
        call_task('pavelib.assets.update_assets', args=args)

    if port is None:
        port = DEFAULT_PORT[system]

    if settings is None:
        settings = DEFAULT_SETTINGS

    run_process(django_cmd(
        system, settings, 'runserver', '--traceback',
        '--pythonpath=.', '0.0.0.0:{}'.format(port)))


@task
@needs('pavelib.prereqs.install_prereqs')
@cmdopts([
    ("settings=", "s", "Django settings"),
    ("port=", "p", "Port"),
    ("fast", "f", "Skip updating assets")
])
def lms(options):
    """
    Run the LMS server.
    """
    settings = getattr(options, 'settings', None)
    port = getattr(options, 'port', None)
    fast = getattr(options, 'fast', False)
    run_server('lms', settings=settings, port=port, skip_assets=fast)


@task
@needs('pavelib.prereqs.install_prereqs')
@cmdopts([
    ("settings=", "s", "Django settings"),
    ("port=", "p", "Port"),
    ("fast", "f", "Skip updating assets")
])
def studio(options):
    """
    Run the Studio server.
    """
    settings = getattr(options, 'settings', None)
    port = getattr(options, 'port', None)
    fast = getattr(options, 'fast', False)
    run_server('studio', settings=settings, port=port, skip_assets=fast)


@task
@needs('pavelib.prereqs.install_prereqs')
@consume_args
def devstack(args):
    """
    Start the devstack lms or studio server
    """
    parser = argparse.ArgumentParser(prog='paver devstack')
    parser.add_argument('system', type=str, nargs=1, help="lms or studio")
    parser.add_argument('--fast', action='store_true', default=False, help="Skip updating assets")
    args = parser.parse_args(args)
    run_server(args.system[0], settings='devstack', skip_assets=args.fast)

@task
@needs('pavelib.prereqs.install_prereqs')
@consume_args
def devstack_appsembler(args):
    """
    Start the devstack lms or studio server
    """
    parser = argparse.ArgumentParser(prog='paver devstack_appsembler')
    parser.add_argument('system', type=str, nargs=1, help="lms or studio")
    parser.add_argument('--fast', action='store_true', default=False, help="Skip updating assets")
    args = parser.parse_args(args)
    run_server(args.system[0], settings='devstack_appsembler', skip_assets=args.fast)

{'fraction_non_alphanumeric': 0.1437725928360171, 'fraction_numerical': 0.0052579691094314825, 'mean_word_length': 3.9568403908794787, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '6494800', 'n_tokens_mistral': 1974, 'n_tokens_neox': 1929, 'n_words': 549}