def install_requirements(context):
    """Install the local package requirements"""

    if context.obj.get("target_dir", None) is None:
        raise NotInPackageError(context.command.name)

    if not is_venv_disabled():
        params = [
            "./venv/bin/pip",
            "install",
            "-r",
            "requirements.txt",
            "--upgrade",
        ]
    else:
        params = ["pip", "install", "-r", "requirements.txt", "--upgrade"]
    echo("\nRUN: {0}".format(" ".join(params)), fg="green", reverse=True)
    subprocess.call(params, cwd=context.obj["target_dir"])

    if not is_venv_disabled():
        params = ["./venv/bin/buildout", "bootstrap"]
    else:
        params = ["buildout", "bootstrap"]
    echo("\nRUN: {0}".format(" ".join(params)), fg="green", reverse=True)
    subprocess.call(params, cwd=context.obj["target_dir"])
Beispiel #2
0
def install_requirements(context):
    """Install the local package requirements"""

    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = ['./bin/pip', 'install', '-r', 'requirements.txt', '--upgrade']
    echo('\nRUN: {0}'.format(' '.join(params)), fg='green', reverse=True)
    subprocess.call(params, cwd=context.obj['target_dir'])
Beispiel #3
0
def run_debug(context):
    """Run the Plone client in debug mode"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = ['./bin/instance', 'debug']
    echo('\nRUN: {0}'.format(' '.join(params)), fg='green', reverse=True)
    echo('INFO: You can stop it by pressing CTRL + c\n')
    subprocess.call(params, cwd=context.obj['target_dir'])
def run_debug(context):
    """Run the Plone client in debug mode"""
    if context.obj.get("target_dir", None) is None:
        raise NotInPackageError(context.command.name)
    params = ["./bin/instance", "debug"]
    echo("\nRUN: {0}".format(" ".join(params)), fg="green", reverse=True)
    echo("INFO: You can stop it by pressing CTRL + c\n")
    subprocess.call(params, cwd=context.obj["target_dir"])
Beispiel #5
0
def run_buildout(context, clean):
    """Run the package buildout"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = ['./bin/buildout']
    if clean:
        params.append('-n')
    echo('\nRUN: {0}'.format(' '.join(params)), fg='green', reverse=True)
    subprocess.call(params, cwd=context.obj['target_dir'])
Beispiel #6
0
def run_serve(context):
    """Run the Plone client in foreground mode"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = ['./bin/instance', 'fg']
    echo('\nRUN: {0}'.format(' '.join(params)), fg='green', reverse=True)
    echo('\nINFO: Open this in a Web Browser: http://localhost:8080')
    echo('INFO: You can stop it by pressing CTRL + c\n')
    subprocess.call(params, cwd=context.obj['target_dir'])
def run_serve(context):
    """Run the Plone client in foreground mode (bin/instance fg)"""
    if context.obj.get("target_dir", None) is None:
        raise NotInPackageError(context.command.name)
    params = ["./bin/instance", "fg"]
    echo("\nRUN: {0}".format(" ".join(params)), fg="green", reverse=True)
    echo("\nINFO: Open this in a Web Browser: http://localhost:8080")
    echo("INFO: You can stop it by pressing CTRL + c\n")
    subprocess.call(params, cwd=context.obj["target_dir"])
Beispiel #8
0
def create_virtualenv(context, clean, python):
    """Create/update the local virtual environment for the Plone package"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    python = python or context.obj.get('python')
    params = ['virtualenv', '.', '-p', python]
    if clean:
        params.append('--clear')
    echo('\nRUN: {0}'.format(' '.join(params)), fg='green', reverse=True)
    subprocess.call(params, cwd=context.obj['target_dir'])
Beispiel #9
0
def build(context, clean):
    """Bootstrap and build the package"""
    target_dir = context.obj.get('target_dir', None)
    if target_dir is None:
        raise NotInPackageError(context.command.name)
    if clean:
        context.invoke(create_virtualenv, clean=True)
    else:
        context.invoke(create_virtualenv)
    context.invoke(install_requirements)
    context.forward(run_buildout)
Beispiel #10
0
 def add(context, template):
     """Add features to your existing Plone package"""
     if context.obj.get('target_dir', None) is None:
         raise NotInPackageError(context.command.name)
     bobtemplate = reg.resolve_template_name(template)
     if bobtemplate is None:
         raise NoSuchValue(context.command.name,
                           template,
                           possibilities=reg.get_templates())
     echo('\nRUN: mrbob {0}'.format(bobtemplate), fg='green', reverse=True)
     subprocess.call(['mrbob', bobtemplate])
Beispiel #11
0
def build(context, clean, python=None):
    """Bootstrap and build the package"""
    target_dir = context.obj.get('target_dir', None)
    python = python or context.obj.get('python')
    if target_dir is None:
        raise NotInPackageError(context.command.name)
    if clean:
        context.invoke(create_virtualenv, clean=True, python=python)
    else:
        context.invoke(create_virtualenv, python=python)
    context.invoke(install_requirements)
    context.invoke(run_buildout, clean=clean)
def run_buildout(context, clear):
    """Run the package buildout"""
    if context.obj.get("target_dir", None) is None:
        raise NotInPackageError(context.command.name)
    if not is_venv_disabled():
        params = ["./venv/bin/buildout"]
    else:
        params = ["buildout"]
    if clear:
        params.append("-n")
    echo("\nRUN: {0}".format(" ".join(params)), fg="green", reverse=True)
    subprocess.call(params, cwd=context.obj["target_dir"])
Beispiel #13
0
def run_debug(context, verbose):
    """Run the Plone client in debug mode"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = [
        './bin/instance',
        'debug',
    ]
    click.echo('RUN: {0}'.format(' '.join(params)))
    click.echo('INFO: You can stop it by pressing STRG + c')
    subprocess.call(
        params,
        cwd=context.obj['target_dir'],
    )
Beispiel #14
0
def run_buildout(context, verbose, clean):
    """Run the package buildout"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = [
        './bin/buildout',
    ]
    if clean:
        params.append('-n')
    click.echo('RUN: {0}'.format(' '.join(params)))
    subprocess.call(
        params,
        cwd=context.obj['target_dir'],
    )
Beispiel #15
0
def create_virtualenv(context, verbose, clean):
    """Create/update the local virtual environment for the Plone package"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = [
        'virtualenv',
        '.',
    ]
    if clean:
        params.append('--clear')
    click.echo('RUN: {0}'.format(' '.join(params)))
    subprocess.call(
        params,
        cwd=context.obj['target_dir'],
    )
def create_virtualenv(context, clear, upgrade, python):
    """Create/update the local virtualenv (venv) for the Plone package"""
    if context.obj.get("target_dir", None) is None:
        raise NotInPackageError(context.command.name)
    python_bin = python or context.obj.get("python")
    if python_bin == "python2.7":
        params = ["virtualenv", "-p", python_bin, "venv"]
    else:
        params = [python_bin, "-m", "venv", "venv"]
    if clear:
        params.append("--clear")
    if upgrade:
        params.append("--upgrade")
    echo("\nRUN: {0}".format(" ".join(params)), fg="green", reverse=True)
    subprocess.call(params, cwd=context.obj["target_dir"])
def build(context, clear, upgrade, python=None):
    """Bootstrap and build the package"""
    target_dir = context.obj.get("target_dir", None)
    if target_dir is None:
        raise NotInPackageError(context.command.name)
    if not is_venv_disabled():
        python = python or context.obj.get("python")
        if clear:
            context.invoke(create_virtualenv, clear=True, python=python)
        elif upgrade:
            context.invoke(create_virtualenv, clear=True, python=python)
        else:
            context.invoke(create_virtualenv, python=python)
    context.invoke(install_requirements)
    context.invoke(run_buildout, clear=clear)
Beispiel #18
0
def run_test(context, all, test, package):
    """Run the tests in your package"""
    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = ['./bin/test']
    if test:
        params.append('--test')
        params.append(test)
    if package:
        params.append('--package')
        params.append(package)
    if all:
        params.append('--all')

    echo('\nRUN: {0}'.format(' '.join(params)), fg='green', reverse=True)
    subprocess.call(params, cwd=context.obj['target_dir'])
def run_test(context, all, test, package):
    """Run the tests in your package"""
    if context.obj.get("target_dir", None) is None:
        raise NotInPackageError(context.command.name)
    params = ["./bin/test"]
    if test:
        params.append("--test")
        params.append(test)
    if package:
        params.append("--package")
        params.append(package)
    if all:
        params.append("--all")

    echo("\nRUN: {0}".format(" ".join(params)), fg="green", reverse=True)
    subprocess.call(params, cwd=context.obj["target_dir"])
Beispiel #20
0
def install_requirements(context, verbose):
    """Install the local package requirements"""

    if context.obj.get('target_dir', None) is None:
        raise NotInPackageError(context.command.name)
    params = [
        './bin/pip',
        'install',
        '-r',
        'requirements.txt',
        '--upgrade',
    ]
    click.echo('RUN: {0}'.format(' '.join(params)))
    subprocess.call(
        params,
        cwd=context.obj['target_dir'],
    )
Beispiel #21
0
 def add(context, template, verbose):
     """Add features to your existing Plone package"""
     if context.obj.get('target_dir', None) is None:
         raise NotInPackageError(context.command.name)
     bobtemplate = reg.resolve_template_name(template)
     if bobtemplate is None:
         raise NoSuchValue(
             context.command.name,
             template,
             possibilities=reg.get_templates(),
         )
     if verbose:
         click.echo('RUN: mrbob {0}'.format(bobtemplate))
     subprocess.call([
         'mrbob',
         bobtemplate,
     ], )