Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/invoke/__init__.py: 89%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from importlib import metadata
2from typing import Any
4from .collection import Collection # noqa
5from .config import Config # noqa
6from .context import Context, MockContext # noqa
7from .exceptions import ( # noqa
8 AmbiguousEnvVar,
9 AuthFailure,
10 CollectionNotFound,
11 CommandTimedOut,
12 Exit,
13 ParseError,
14 PlatformError,
15 ResponseNotAccepted,
16 SubprocessPipeError,
17 ThreadException,
18 UncastableEnvVar,
19 UnexpectedExit,
20 UnknownFileType,
21 UnpicklableConfigMember,
22 WatcherError,
23)
24from .executor import Executor # noqa
25from .loader import FilesystemLoader # noqa
26from .parser import Argument, Parser, ParserContext, ParseResult # noqa
27from .program import Program # noqa
28from .runners import Failure, Local, Promise, Result, Runner # noqa
29from .tasks import Call, Task, call, task # noqa
30from .terminals import pty_size # noqa
31from .watchers import FailingResponder, Responder, StreamWatcher # noqa
33__version__ = metadata.version("invoke")
36def run(command: str, **kwargs: Any) -> Result:
37 """
38 Run ``command`` in a subprocess and return a `.Result` object.
40 See `.Runner.run` for API details.
42 .. note::
43 This function is a convenience wrapper around Invoke's `.Context` and
44 `.Runner` APIs.
46 Specifically, it creates an anonymous `.Context` instance and calls its
47 `~.Context.run` method, which in turn defaults to using a `.Local`
48 runner subclass for command execution.
50 .. versionadded:: 1.0
51 """
52 return Context().run(command, **kwargs)
55def sudo(command: str, **kwargs: Any) -> Result:
56 """
57 Run ``command`` in a ``sudo`` subprocess and return a `.Result` object.
59 See `.Context.sudo` for API details, such as the ``password`` kwarg.
61 .. note::
62 This function is a convenience wrapper around Invoke's `.Context` and
63 `.Runner` APIs.
65 Specifically, it creates an anonymous `.Context` instance and calls its
66 `~.Context.sudo` method, which in turn defaults to using a `.Local`
67 runner subclass for command execution (plus sudo-related bits &
68 pieces).
70 .. versionadded:: 1.4
71 """
72 return Context().sudo(command, **kwargs)