How to use the invoke.Config function in invoke

To help you get started, we’ve selected a few invoke examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyinvoke / invoke / tests / runners / local.py View on Github external
def _run(self, pty):
            runner = _KeyboardInterruptingFastLocal(Context(config=Config()))
            try:
                runner.run(_, pty=pty)
            except KeyboardInterrupt:
                pass
            return runner
github pyinvoke / invoke / tests / runners.py View on Github external
def _run(*args, **kwargs):
    klass = kwargs.pop("klass", _Dummy)
    settings = kwargs.pop("settings", {})
    context = Context(config=Config(overrides=settings))
    return klass(context).run(*args, **kwargs)
github pyinvoke / invoke / tests / context.py View on Github external
def honors_config_for_prompt_value(self, Local):
            runner = Local.return_value
            config = Config(overrides={"sudo": {"prompt": "FEED ME: "}})
            Context(config=config).sudo("whoami")
            cmd = "sudo -S -p 'FEED ME: ' whoami"
            assert runner.run.call_args[0][0] == cmd
github pyinvoke / invoke / tests / runners / local.py View on Github external
def _run(*args, **kwargs):
    klass = kwargs.pop('klass', Dummy)
    settings = kwargs.pop('settings', {})
    context = Context(config=Config(overrides=settings))
    return klass(context).run(*args, **kwargs)
github pyinvoke / invoke / tests / runners.py View on Github external
def _runner(out="", err="", **kwargs):
    klass = kwargs.pop("klass", _Dummy)
    runner = klass(Context(config=Config(overrides=kwargs)))
    if "exits" in kwargs:
        runner.returncode = Mock(return_value=kwargs.pop("exits"))
    out_file = BytesIO(b(out))
    err_file = BytesIO(b(err))
    runner.read_proc_stdout = out_file.read
    runner.read_proc_stderr = err_file.read
    return runner
github pyinvoke / invoke / tests / context.py View on Github external
def config_use_does_not_modify_config(self, Local):
                runner = Local.return_value
                watcher = self.watcher_klass()
                overrides = {"run": {"watchers": [watcher]}}
                config = Config(overrides=overrides)
                Context(config=config).sudo("whoami")
                # Here, 'watchers' is _the same object_ as was passed into
                # run(watchers=...).
                watchers = runner.run.call_args[1]["watchers"]
                # We want to make sure that what's in the config we just
                # generated, is untouched by the manipulation done inside
                # sudo().
                # First, that they aren't the same obj
                err = "Found sudo() reusing config watchers list directly!"
                assert watchers is not config.run.watchers, err
                # And that the list is as it was before (i.e. it is not both
                # our watcher and the sudo()-added one)
                err = "Our config watchers list was modified!"
                assert config.run.watchers == [watcher], err
github pyinvoke / invoke / tests / init.py View on Github external
def config_class(self):
            assert invoke.Config is invoke.config.Config
github pyinvoke / invoke / invoke / loader.py View on Github external
def __init__(self, config=None):
        """
        Set up a new loader with some `.Config`.

        :param config:
            An explicit `.Config` to use; it is referenced for loading-related
            config options. Defaults to an anonymous ``Config()`` if none is
            given.
        """
        if config is None:
            config = Config()
        self.config = config
github pyinvoke / invoke / integration / context.py View on Github external
def base_case(self):
            # NOTE: Assumes a user whose password is 'mypass' has been created
            # & added to passworded (not passwordless) sudo configuration; and
            # that this user is the one running the test suite. Only for
            # running on Travis, basically.
            if not os.environ.get("TRAVIS", False):
                skip()
            config = Config({"sudo": {"password": "mypass"}})
            result = Context(config=config).sudo("whoami", hide=True)
            assert result.stdout.strip() == "root"