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))
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))
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))
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))
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)
def display_local_tasks(): print_title("In this project") cli.dispatch(['xxx.py', '-l'])
def display_easypy_tasks(): print_title("At easypy") argv = ['xxx.py'] argv.append('-l') cli.dispatch(prepare_args(argv))
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})
def _dispatch(argstr, version=None): from invoke.cli import dispatch return dispatch(argstr.split(), version)
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)