Beispiel #1
0
def display_apackage_tasks(package_name):
    """
    Display tasks in a site package.
    """
    argv = ['xxx']
    argv.append('-l')
    print_title("In %s" % package_name)
    cli.dispatch(prepare_args(argv, package_name))
Beispiel #2
0
def display_apackage_tasks(package_name):
    """
    Display tasks in a site package.
    """
    argv = ['xxx']
    argv.append('-l')
    print_title("In %s"%package_name)
    cli.dispatch(prepare_args(argv, package_name))
Beispiel #3
0
def run_package_task(argv):
    """
    Run tasks in a site package.
    """
    _, site_packages, _ = next(os.walk(get_site_dir()))
    package_name = argv[1]
    if not package_name in site_packages:
        raise PackageNotAvailable(package_name)
    if not is_valid_package(package_name):
        raise InvalidPackage(package_name)
    # if length of argv is 2, the request is in format $ py <package>
    # list the tasks in package
    if len(argv) == 2:
        display_apackage_tasks(package_name)
        return
    cli.dispatch(prepare_args(argv))
Beispiel #4
0
def run_easypy_task(argv):
    """
    Run task in easypy.
    """
    from easypy import tasks
    tasks = Collection.from_module(tasks).task_names
    if len(argv) == 1:
        # the request is in the format $ py
        # display available tasks in easypy
        display_easypy_tasks()
    else:
        # the request is in the format $ py <task>
        task = argv[1]
        if not task in tasks.keys():
            raise TaskNotAvailable(task)
        cli.dispatch(prepare_args(argv))
Beispiel #5
0
def run_local_task(argv):
    """
    Run task in user's project directory.
    """
    task = argv[1]
    from invoke.loader import FilesystemLoader
    try:
        tasks = FilesystemLoader().load().task_names
    except CollectionNotFound:
        raise TaskNotAvailable(task)
    if task == '.':
        display_local_tasks()
        return
    if not task in tasks.keys():
        raise TaskNotAvailable(task)
    cli.dispatch(argv)
Beispiel #6
0
def run_easypy_task(argv):
    """
    Run task in easypy.
    """
    from easypy import tasks
    tasks = Collection.from_module(tasks).task_names
    if len(argv) == 1:
        # the request is in the format $ py
        # display available tasks in easypy
        display_easypy_tasks()
    else:
        # the request is in the format $ py <task>
        task = argv[1]
        if not task in tasks.keys():
            raise TaskNotAvailable(task)
        cli.dispatch(prepare_args(argv))
Beispiel #7
0
def run_package_task(argv):
    """
    Run tasks in a site package.
    """
    _, site_packages, _ = next(os.walk(get_site_dir()))
    package_name = argv[1]
    if not package_name in site_packages:
        raise PackageNotAvailable(package_name)
    if not is_valid_package(package_name):
        raise InvalidPackage(package_name)
    # if length of argv is 2, the request is in format $ py <package>
    # list the tasks in package
    if len(argv) == 2:
        display_apackage_tasks(package_name)
        return
    cli.dispatch(prepare_args(argv))
Beispiel #8
0
def run_local_task(argv):
    """
    Run task in user's project directory.
    """
    task = argv[1]
    from invoke.loader import FilesystemLoader
    try:
        tasks = FilesystemLoader().load().task_names
    except CollectionNotFound:
        raise TaskNotAvailable(task)
    if task == '.':
        display_local_tasks()
        return
    if not task in tasks.keys():
        raise TaskNotAvailable(task)
    cli.dispatch(argv)
Beispiel #9
0
def display_local_tasks():
    print_title("In this project")
    cli.dispatch(['xxx.py', '-l'])
Beispiel #10
0
def display_easypy_tasks():
    print_title("At easypy")
    argv = ['xxx.py']
    argv.append('-l')
    cli.dispatch(prepare_args(argv))
Beispiel #11
0
 def _test_flag(self, flag, kwarg, value):
     with patch('invoke.context.run') as run:
         dispatch(flag + ['-c', 'contextualized', 'run'])
         run.assert_called_with('x', **{kwarg: value})
Beispiel #12
0
def _dispatch(argstr, version=None):
    from invoke.cli import dispatch
    return dispatch(argstr.split(), version)
Beispiel #13
0
def _dispatch(argstr, version=None):
    from invoke.cli import dispatch
    return dispatch(argstr.split(), version)
Beispiel #14
0
def display_local_tasks():
    print_title("In this project")
    cli.dispatch(['xxx.py', '-l'])
Beispiel #15
0
def display_easypy_tasks():
    print_title("At easypy")
    argv = ['xxx.py']
    argv.append('-l')
    cli.dispatch(prepare_args(argv))
Beispiel #16
0
 def _test_flag(self, flag, kwarg, value):
     with patch('invoke.context.run') as run:
         dispatch(flag + ['-c', 'contextualized', 'run'])
         run.assert_called_with('x', **{kwarg: value})
Beispiel #17
0
 def contextualized_tasks_are_given_parser_context_arg(self):
     # go() in contextualized.py just returns its initial arg
     retval = dispatch(['-c', 'contextualized', 'go'])[0]
     assert isinstance(retval, Context)
Beispiel #18
0
 def contextualized_tasks_are_given_parser_context_arg(self):
     # go() in contextualized.py just returns its initial arg
     retval = dispatch(['-c', 'contextualized', 'go'])[0]
     assert isinstance(retval, Context)