How to use the invoke.Collection.from_module function in invoke

To help you get started, we’ve selected a few invoke examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyinvoke / invoke / tests / program.py View on Github external
def explicit_namespace_works_correctly(self):
            # Regression-ish test re #288
            ns = Collection.from_module(load("integration"))
            expect("print-foo", out="foo\n", program=Program(namespace=ns))
github pyinvoke / invoke / tests / task.py View on Github external
def _load(self, name):
        mod, _ = self.loader.load(name)
        return Collection.from_module(mod)
github behave / behave / tasks / __init__.py View on Github external
# -----------------------------------------------------------------------------
# TASKS:
# -----------------------------------------------------------------------------
# None


# -----------------------------------------------------------------------------
# TASK CONFIGURATION:
# -----------------------------------------------------------------------------
namespace = Collection()
# DISABLED: namespace.add_task(clean.clean)
# DISABLED: namespace.add_task(clean.clean_all)
namespace.add_collection(Collection.from_module(cleanup), name="cleanup")
namespace.add_collection(Collection.from_module(docs))
namespace.add_collection(Collection.from_module(test))
namespace.add_collection(Collection.from_module(release))
namespace.add_collection(Collection.from_module(develop))
cleanup.cleanup_tasks.add_task(cleanup.clean_python)

cleanup.cleanup_tasks.add_task(cleanup.clean_python)

# -- INJECT: clean configuration into this namespace
namespace.configure(cleanup.namespace.configuration())
if sys.platform.startswith("win"):
    # -- OVERRIDE SETTINGS: For platform=win32, ... (Windows)
    from ._compat_shutil import which
    run_settings = dict(echo=True, pty=False, shell=which("cmd"))
    namespace.configure({"run": run_settings})
else:
    namespace.configure({"run": dict(echo=True, pty=True)})
github behave / behave / tasks / __init__.py View on Github external
# -----------------------------------------------------------------------------
# TASKS:
# -----------------------------------------------------------------------------
# None


# -----------------------------------------------------------------------------
# TASK CONFIGURATION:
# -----------------------------------------------------------------------------
namespace = Collection()
# DISABLED: namespace.add_task(clean.clean)
# DISABLED: namespace.add_task(clean.clean_all)
namespace.add_collection(Collection.from_module(cleanup), name="cleanup")
namespace.add_collection(Collection.from_module(docs))
namespace.add_collection(Collection.from_module(test))
namespace.add_collection(Collection.from_module(release))
namespace.add_collection(Collection.from_module(develop))
cleanup.cleanup_tasks.add_task(cleanup.clean_python)

cleanup.cleanup_tasks.add_task(cleanup.clean_python)

# -- INJECT: clean configuration into this namespace
namespace.configure(cleanup.namespace.configuration())
if sys.platform.startswith("win"):
    # -- OVERRIDE SETTINGS: For platform=win32, ... (Windows)
    from ._compat_shutil import which
    run_settings = dict(echo=True, pty=False, shell=which("cmd"))
    namespace.configure({"run": run_settings})
else:
    namespace.configure({"run": dict(echo=True, pty=True)})
github CenterForOpenScience / osf.io / tasks / __init__.py View on Github external
# gets the root path for all the scripts that rely on it
HERE = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
WHEELHOUSE_PATH = os.environ.get('WHEELHOUSE')
CONSTRAINTS_PATH = os.path.join(HERE, 'requirements', 'constraints.txt')
NO_TESTS_COLLECTED = 5
ns = Collection()

try:
    from tasks import local as local_tasks
    ns.add_collection(Collection.from_module(local_tasks), name='local')
except ImportError:
    pass

try:
    from admin import tasks as admin_tasks
    ns.add_collection(Collection.from_module(admin_tasks), name='admin')
except ImportError:
    pass


def task(*args, **kwargs):
    """Behaves the same way as invoke.task. Adds the task
    to the root namespace.
    """
    if len(args) == 1 and callable(args[0]):
        new_task = invoke.task(args[0])
        ns.add_task(new_task)
        return new_task

    def decorator(f):
        new_task = invoke.task(f, *args, **kwargs)
        ns.add_task(new_task)
github behave / behave / tasks / __init__.py View on Github external
# TASKS:
# -----------------------------------------------------------------------------
# None


# -----------------------------------------------------------------------------
# TASK CONFIGURATION:
# -----------------------------------------------------------------------------
namespace = Collection()
# DISABLED: namespace.add_task(clean.clean)
# DISABLED: namespace.add_task(clean.clean_all)
namespace.add_collection(Collection.from_module(cleanup), name="cleanup")
namespace.add_collection(Collection.from_module(docs))
namespace.add_collection(Collection.from_module(test))
namespace.add_collection(Collection.from_module(release))
namespace.add_collection(Collection.from_module(develop))
cleanup.cleanup_tasks.add_task(cleanup.clean_python)

cleanup.cleanup_tasks.add_task(cleanup.clean_python)

# -- INJECT: clean configuration into this namespace
namespace.configure(cleanup.namespace.configuration())
if sys.platform.startswith("win"):
    # -- OVERRIDE SETTINGS: For platform=win32, ... (Windows)
    from ._compat_shutil import which
    run_settings = dict(echo=True, pty=False, shell=which("cmd"))
    namespace.configure({"run": run_settings})
else:
    namespace.configure({"run": dict(echo=True, pty=True)})
github pyslackers / sir-bot-a-lot / tasks / docker / __init__.py View on Github external
from invoke import Collection
from invoke import Failure
from invoke import task

from sirbot import DATA
from tasks.docker import base
from tasks.docker import gunicorn
from tasks.helpers import run_cmd, container_rm, image_rm, container_stop, \
    image_build, get_cache_string, get_tag

ns = Collection()
ns.add_collection(Collection.from_module(base))
ns.add_collection(Collection.from_module(gunicorn))

NAMESPACE = DATA['author'].lower()
APP = 'api'
TAG = 'latest'
CACHE = ''


@task(pre=[gunicorn.build], default=True)
def build(ctx, invalidate_cache=False):
    """Build the brand social app image"""
    tag = '{NAMESPACE}/{APP}:{TAG} .'.format(**globals())
    image_build(ctx, tag, get_cache_string(invalidate_cache))


@task(build)
def up(ctx):
github ofek / csi-gcs / tasks / __init__.py View on Github external
from invoke import Collection

from . import docs
from . import image
from . import test
from . import env
from . import build
from .utils import set_root

ns = Collection()
ns.add_collection(Collection.from_module(image))
ns.add_collection(Collection.from_module(docs))
ns.add_collection(Collection.from_module(test))
ns.add_collection(Collection.from_module(env))
ns.add_collection(Collection.from_module(build))

set_root()