Exemplo n.º 1
0
def run_cmd(global_context, cached_package, cmd_name, cmd_argv, run_node,
            top_node, build_node):
    cmd = global_context.retrieve_command(cmd_name)

    # XXX: fix this special casing (commands which do not need a pkg instance)
    if cmd_name in ["help", "convert"]:
        global_context.run_command(cmd_name, cmd_argv, PackageDescription(),
                                   run_node)
        return

    if is_help_only(global_context, cmd_name, cmd_argv):
        options_context = global_context.retrieve_options_context(cmd_name)
        options_context.parser.print_help()
        return

    bento_info = top_node.find_node(BENTO_SCRIPT)
    if bento_info is None:
        raise bento.errors.UsageException(
            "Error: no %s found !" %
            os.path.join(top_node.abspath(), BENTO_SCRIPT))

    running_package = get_running_package(global_context, cached_package,
                                          bento_info)
    run_with_dependencies(global_context, cmd_name, cmd_argv, run_node,
                          top_node, running_package)

    global_context.save_command_argv(cmd_name, cmd_argv)
    global_context.store()
Exemplo n.º 2
0
def run_cmd(global_context, cached_package, cmd_name, cmd_argv, run_node, top_node, build_node):
    cmd = global_context.retrieve_command(cmd_name)

    # XXX: fix this special casing (commands which do not need a pkg instance)
    if cmd_name in ["help", "convert"]:
        options_context = global_context.retrieve_options_context(cmd_name)
        context_klass = global_context.retrieve_command_context(cmd_name)
        context = context_klass(global_context, cmd_argv, options_context, PackageDescription(), run_node)
        cmd.run(context)
        return

    if is_help_only(global_context, cmd_name, cmd_argv):
        options_context = global_context.retrieve_options_context(cmd_name)
        options_context.parser.print_help()
        return

    bento_info = top_node.find_node(BENTO_SCRIPT)
    if bento_info is None:
        raise bento.errors.UsageException("Error: no %s found !" % os.path.join(top_node.abspath(), BENTO_SCRIPT))

    running_package = get_running_package(global_context, cached_package, bento_info)
    run_with_dependencies(global_context, cmd_name, cmd_argv, run_node, top_node, running_package)

    global_context.save_command_argv(cmd_name, cmd_argv)
    global_context.store()