示例#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))
示例#2
0
文件: core.py 项目: ludbek/easypy
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))
示例#3
0
文件: core.py 项目: ludbek/easypy
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))
示例#4
0
文件: core.py 项目: ludbek/easypy
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))
示例#5
0
文件: core.py 项目: ludbek/easypy
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)
示例#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))
示例#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))
示例#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)
示例#9
0
文件: core.py 项目: ludbek/easypy
def display_local_tasks():
    print_title("In this project")
    cli.dispatch(['xxx.py', '-l'])
示例#10
0
文件: core.py 项目: ludbek/easypy
def display_easypy_tasks():
    print_title("At easypy")
    argv = ['xxx.py']
    argv.append('-l')
    cli.dispatch(prepare_args(argv))
示例#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})
示例#12
0
文件: _utils.py 项目: melor/invoke
def _dispatch(argstr, version=None):
    from invoke.cli import dispatch
    return dispatch(argstr.split(), version)
示例#13
0
def _dispatch(argstr, version=None):
    from invoke.cli import dispatch
    return dispatch(argstr.split(), version)
示例#14
0
def display_local_tasks():
    print_title("In this project")
    cli.dispatch(['xxx.py', '-l'])
示例#15
0
def display_easypy_tasks():
    print_title("At easypy")
    argv = ['xxx.py']
    argv.append('-l')
    cli.dispatch(prepare_args(argv))
示例#16
0
文件: cli.py 项目: jthigpen/invoke
 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})
示例#17
0
文件: cli.py 项目: jthigpen/invoke
 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)
示例#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)