コード例 #1
0
    def test_simple(self):
        scheduler = CommandScheduler()
        scheduler.set_before("task2", "task1")
        scheduler.set_after("task2", "task3")
        scheduler.set_after("task2", "task4")
        scheduler.set_before("task4", "task3")

        tasks = scheduler.order("task4")
        self.assertEqual(tasks, ["task1", "task2", "task3"])
コード例 #2
0
ファイル: test_dependency.py プロジェクト: aspidites/Bento
    def test_simple(self):
        scheduler = CommandScheduler()
        scheduler.set_before("task2", "task1")
        scheduler.set_after("task2", "task3")
        scheduler.set_after("task2", "task4")
        scheduler.set_before("task4", "task3")

        tasks = scheduler.order("task4")
        self.assertEqual(tasks, ["task1", "task2", "task3"])
コード例 #3
0
    def __init__(self,
                 command_data_db,
                 commands_registry=None,
                 contexts_registry=None,
                 options_registry=None,
                 commands_scheduler=None):
        self._commands_registry = commands_registry or CommandRegistry()
        self._contexts_registry = contexts_registry or ContextRegistry()
        self._options_registry = options_registry or OptionsRegistry()
        self._scheduler = commands_scheduler or CommandScheduler()
        self._hooks_registry = HookRegistry()

        self.backend = None
        self._package_options = None

        self._command_data_db = command_data_db
        if command_data_db is None:
            self._command_data_store = {}
        else:
            self._command_data_store = read_or_create_dict(
                command_data_db.abspath())
コード例 #4
0
ファイル: test_dependency.py プロジェクト: aspidites/Bento
    def test_cycle(self):
        scheduler = CommandScheduler()
        scheduler.set_before("task2", "task1")
        scheduler.set_before("task1", "task2")

        self.assertRaises(ValueError, lambda: scheduler.order("task1"))
コード例 #5
0
def main(argv=None):
    if hasattr(os, "getuid"):
        if os.getuid() == 0:
            pprint(
                "RED",
                "Using bentomaker under root/sudo is *strongly* discouraged - do you want to continue ? y/N"
            )
            ans = input()
            if not ans.lower() in ["y", "yes"]:
                raise bento.errors.UsageException(
                    "bentomaker execution canceld (not using bentomaker with admin privileges)"
                )

    if argv is None:
        argv = sys.argv[1:]

    options_context = create_global_options_context()
    popts = parse_global_options(options_context, argv)

    cmd_name = popts.cmd_name

    if popts.show_version:
        print(bento.__version__)
        return

    if popts.show_full_version:
        print(bento.__version__ + "git" + bento.__git_revision__)
        return

    source_root = os.path.join(os.getcwd(), os.path.dirname(popts.bento_info))
    build_root = os.path.join(os.getcwd(), popts.build_directory)

    top_node, build_node, run_node = bento.core.node.create_base_nodes(
        source_root, build_root)
    if run_node != top_node and run_node.is_src():
        raise bento.errors.UsageException(
            "You cannot execute bentomaker in a subdirectory of the source tree !"
        )
    if run_node != build_node and run_node.is_bld():
        raise bento.errors.UsageException(
            "You cannot execute bentomaker in a subdirectory of the build tree !"
        )

    global_context = GlobalContext(build_node.make_node(CMD_DATA_DUMP),
                                   CommandRegistry(), ContextRegistry(),
                                   OptionsRegistry(), CommandScheduler())
    global_context.register_options_context_without_command(
        "", options_context)

    if not popts.disable_autoconfigure:
        global_context.set_before("build", "configure")
    global_context.set_before("build_egg", "build")
    global_context.set_before("build_wheel", "build")
    global_context.set_before("build_wininst", "build")
    global_context.set_before("install", "build")

    if cmd_name and cmd_name not in ["convert"]:
        return _wrapped_main(global_context, popts, run_node, top_node,
                             build_node)
    else:
        # XXX: is cached package necessary here ?
        cached_package = None
        register_stuff(global_context)
        for cmd_name in global_context.command_names():
            register_options(global_context, cmd_name)
        return _main(global_context, cached_package, popts, run_node, top_node,
                     build_node)
コード例 #6
0
ファイル: bentomaker.py プロジェクト: pberkes/Bento
    import \
        CachedPackage
from bentomakerlib.help \
    import \
        get_usage

if os.environ.get("BENTOMAKER_DEBUG", "0") != "0":
    BENTOMAKER_DEBUG = True
else:
    BENTOMAKER_DEBUG = False

SCRIPT_NAME = 'bentomaker'

CONTEXT_REGISTRY = ContextRegistry()

CMD_SCHEDULER = CommandScheduler()
CMD_SCHEDULER.set_before("build", "configure")
CMD_SCHEDULER.set_before("build_egg", "build")
CMD_SCHEDULER.set_before("build_wininst", "build")
CMD_SCHEDULER.set_before("install", "build")

# Path relative to build directory
CMD_DATA_DUMP = os.path.join(_SUB_BUILD_DIR, "cmd_data.db")

# FIXME: those private functions hiding global variables are horrible - they
# are a dirty workaround until a better solution to pass nodes to the
# underlying implementation is found (Node instances can only be created once
# the source and build directories are known)
__CMD_DATA_STORE = None
def _get_cmd_data_provider(dump_node):
    global __CMD_DATA_STORE
コード例 #7
0
    def test_cycle(self):
        scheduler = CommandScheduler()
        scheduler.set_before("task2", "task1")
        scheduler.set_before("task1", "task2")

        self.assertRaises(ValueError, lambda: scheduler.order("task1"))