Beispiel #1
0
def run_triggers(name, path, commands):
    if commands:
        LOGGER.debug("Running the {} trigger for {}".format(name, path))
    for command in commands:
        if isinstance(command, type(lambda x: x)):
            command()
        else:
            run(command)
Beispiel #2
0
 def show_parameters_callback(self, ctx, param, value):
     if value and not ctx.resilient_parsing:
         raw_args = config.command_line_settings["parameters"][self.path]
         index = raw_args.index('--show-parameters')
         raw_args = raw_args[:index] + raw_args[index + 2:]
         config.command_line_settings["parameters"][self.path] = raw_args
         config.merge_settings()
         run(["parameters"] + self.parameters_callback_split_value(value) +
             ["show", self.path])
         exit(0)
Beispiel #3
0
def execute_flow_step(cmd, args=None):
    cmd.extend(args or [])
    LOGGER.status(
        "Running step '{}'".format(
            " ".join(cmd)
        )
    )
    old_allow = overloads.allow_dotted_commands
    overloads.allow_dotted_commands = True
    try:
        run(cmd)
    except:
        raise
    finally:
        overloads.allow_dotted_commands = old_allow
Beispiel #4
0
        def alias_command(ctx, *args, **kwargs):
            if "config" in kwargs:
                del kwargs["config"]
            commands = list(commands_to_run)

            for command_ in commands[:-1]:
                LOGGER.debug("Running command: {}".format(" ".join(
                    quote(c) for c in command_)))
                run(command_)
            arguments = ctx.command.complete_arguments[:]
            arguments = clean_flow_arguments(arguments)
            whole_command = commands[-1] + arguments
            original_command_ctx = get_ctx(whole_command, side_effects=True)
            cur_ctx = original_command_ctx
            ctxs = []
            # if the resolution of the context brought too many commands, we
            # must not call the call back of the children of the original_command
            while cur_ctx and ctx.command.original_command != cur_ctx.command:
                cur_ctx = cur_ctx.parent

            while cur_ctx:
                ctxs.insert(0, cur_ctx)
                cur_ctx = cur_ctx.parent
            LOGGER.develop("Running command: {}".format(" ".join(
                quote(c) for c in commands[-1])))

            def run_callback(_ctx):
                LOGGER.develop(
                    "Running callback of {} with args {}, params {}".format(
                        _ctx.command.path,
                        config.commandline_profile.get_settings("parameters")[
                            _ctx.command.path],
                        _ctx.params,
                    ))
                with _ctx:
                    old_resilient_parsing = _ctx.resilient_parsing
                    _ctx.resilient_parsing = ctx.resilient_parsing
                    _ctx.command.callback(**_ctx.params)
                    _ctx.resilient_parsing = old_resilient_parsing

            for cur_ctx in ctxs:
                run_callback(cur_ctx)