✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ beluga.o2switch.net ​🇻​♯➤ 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2026

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 185.154.139.77 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.84
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/alt/python27/lib/python2.7/site-packages/invoke//executor.py
from .util import six

from .config import Config
from .parser import ParserContext
from .util import debug
from .tasks import Call, Task


class Executor(object):
    """
    An execution strategy for Task objects.

    Subclasses may override various extension points to change, add or remove
    behavior.

    .. versionadded:: 1.0
    """

    def __init__(self, collection, config=None, core=None):
        """
        Initialize executor with handles to necessary data structures.

        :param collection:
            A `.Collection` used to look up requested tasks (and their default
            config data, if any) by name during execution.

        :param config:
            An optional `.Config` holding configuration state. Defaults to an
            empty `.Config` if not given.

        :param core:
            An optional `.ParseResult` holding parsed core program arguments.
            Defaults to ``None``.
        """
        self.collection = collection
        self.config = config if config is not None else Config()
        self.core = core

    def execute(self, *tasks):
        """
        Execute one or more ``tasks`` in sequence.

        :param tasks:
            An all-purpose iterable of "tasks to execute", each member of which
            may take one of the following forms:

            **A string** naming a task from the Executor's `.Collection`. This
            name may contain dotted syntax appropriate for calling namespaced
            tasks, e.g. ``subcollection.taskname``. Such tasks are executed
            without arguments.

            **A two-tuple** whose first element is a task name string (as
            above) and whose second element is a dict suitable for use as
            ``**kwargs`` when calling the named task. E.g.::

                [
                    ('task1', {}),
                    ('task2', {'arg1': 'val1'}),
                    ...
                ]

            is equivalent, roughly, to::

                task1()
                task2(arg1='val1')

            **A `.ParserContext`** instance, whose ``.name`` attribute is used
            as the task name and whose ``.as_kwargs`` attribute is used as the
            task kwargs (again following the above specifications).

            .. note::
                When called without any arguments at all (i.e. when ``*tasks``
                is empty), the default task from ``self.collection`` is used
                instead, if defined.

        :returns:
            A dict mapping task objects to their return values.

            This dict may include pre- and post-tasks if any were executed. For
            example, in a collection with a ``build`` task depending on another
            task named ``setup``, executing ``build`` will result in a dict
            with two keys, one for ``build`` and one for ``setup``.

        .. versionadded:: 1.0
        """
        # Normalize input
        debug("Examining top level tasks {!r}".format([x for x in tasks]))
        calls = self.normalize(tasks)
        debug("Tasks (now Calls) with kwargs: {!r}".format(calls))
        # Obtain copy of directly-given tasks since they should sometimes
        # behave differently
        direct = list(calls)
        # Expand pre/post tasks
        # TODO: may make sense to bundle expansion & deduping now eh?
        expanded = self.expand_calls(calls)
        # Get some good value for dedupe option, even if config doesn't have
        # the tree we expect. (This is a concession to testing.)
        try:
            dedupe = self.config.tasks.dedupe
        except AttributeError:
            dedupe = True
        # Dedupe across entire run now that we know about all calls in order
        calls = self.dedupe(expanded) if dedupe else expanded
        # Execute
        results = {}
        # TODO: maybe clone initial config here? Probably not necessary,
        # especially given Executor is not designed to execute() >1 time at the
        # moment...
        for call in calls:
            autoprint = call in direct and call.autoprint
            args = call.args
            debug("Executing {!r}".format(call))
            # Hand in reference to our config, which will preserve user
            # modifications across the lifetime of the session.
            config = self.config
            # But make sure we reset its task-sensitive levels each time
            # (collection & shell env)
            # TODO: load_collection needs to be skipped if task is anonymous
            # (Fabric 2 or other subclassing libs only)
            collection_config = self.collection.configuration(call.called_as)
            config.load_collection(collection_config)
            config.load_shell_env()
            debug("Finished loading collection & shell env configs")
            # Get final context from the Call (which will know how to generate
            # an appropriate one; e.g. subclasses might use extra data from
            # being parameterized), handing in this config for use there.
            context = call.make_context(config)
            args = (context,) + args
            result = call.task(*args, **call.kwargs)
            if autoprint:
                print(result)
            # TODO: handle the non-dedupe case / the same-task-different-args
            # case, wherein one task obj maps to >1 result.
            results[call.task] = result
        return results

    def normalize(self, tasks):
        """
        Transform arbitrary task list w/ various types, into `.Call` objects.

        See docstring for `~.Executor.execute` for details.

        .. versionadded:: 1.0
        """
        calls = []
        for task in tasks:
            name, kwargs = None, {}
            if isinstance(task, six.string_types):
                name = task
            elif isinstance(task, ParserContext):
                name = task.name
                kwargs = task.as_kwargs
            else:
                name, kwargs = task
            c = Call(task=self.collection[name], kwargs=kwargs, called_as=name)
            calls.append(c)
        if not tasks and self.collection.default is not None:
            calls = [Call(task=self.collection[self.collection.default])]
        return calls

    def dedupe(self, calls):
        """
        Deduplicate a list of `tasks <.Call>`.

        :param calls: An iterable of `.Call` objects representing tasks.

        :returns: A list of `.Call` objects.

        .. versionadded:: 1.0
        """
        deduped = []
        debug("Deduplicating tasks...")
        for call in calls:
            if call not in deduped:
                debug("{!r}: no duplicates found, ok".format(call))
                deduped.append(call)
            else:
                debug("{!r}: found in list already, skipping".format(call))
        return deduped

    def expand_calls(self, calls):
        """
        Expand a list of `.Call` objects into a near-final list of same.

        The default implementation of this method simply adds a task's
        pre/post-task list before/after the task itself, as necessary.

        Subclasses may wish to do other things in addition (or instead of) the
        above, such as multiplying the `calls <.Call>` by argument vectors or
        similar.

        .. versionadded:: 1.0
        """
        ret = []
        for call in calls:
            # Normalize to Call (this method is sometimes called with pre/post
            # task lists, which may contain 'raw' Task objects)
            if isinstance(call, Task):
                call = Call(task=call)
            debug("Expanding task-call {!r}".format(call))
            # TODO: this is where we _used_ to call Executor.config_for(call,
            # config)...
            # TODO: now we may need to preserve more info like where the call
            # came from, etc, but I feel like that shit should go _on the call
            # itself_ right???
            # TODO: we _probably_ don't even want the config in here anymore,
            # we want this to _just_ be about the recursion across pre/post
            # tasks or parameterization...?
            ret.extend(self.expand_calls(call.pre))
            ret.append(call)
            ret.extend(self.expand_calls(call.post))
        return ret


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
8 Jan 2025 10.42 AM
root / linksafe
0755
parser
--
25 Jul 2024 8.44 AM
root / linksafe
0755
__init__.py
1.385 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
__init__.pyc
2.091 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
__init__.pyo
2.091 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
__main__.py
0.046 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
__main__.pyc
0.225 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
__main__.pyo
0.225 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
_version.py
0.078 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
_version.pyc
0.27 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
_version.pyo
0.27 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
collection.py
20.879 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
collection.pyc
20.61 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
collection.pyo
20.61 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
complete.py
3.877 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
complete.pyc
2.554 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
complete.pyo
2.554 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
config.py
47.493 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
config.pyc
38.222 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
config.pyo
38.222 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
context.py
20.874 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
context.pyc
16.685 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
context.pyo
16.685 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
env.py
3.982 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
env.pyc
4.249 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
env.pyo
4.249 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
exceptions.py
9.646 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
exceptions.pyc
12.605 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
exceptions.pyo
12.605 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
executor.py
8.126 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
executor.pyc
6.621 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
executor.pyo
6.621 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
loader.py
4.688 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
loader.pyc
4.637 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
loader.pyo
4.637 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
main.py
0.18 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
main.pyc
0.401 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
main.pyo
0.401 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
program.py
31.392 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
program.pyc
25.531 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
program.pyo
25.531 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
runners.py
47.323 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
runners.pyc
38.188 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
runners.pyo
38.188 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
tasks.py
18.815 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
tasks.pyc
16.439 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
tasks.pyo
16.439 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
terminals.py
7.335 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
terminals.pyc
6.47 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
terminals.pyo
6.47 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
util.py
10.528 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
util.pyc
7.727 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
util.pyo
7.727 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
watchers.py
4.856 KB
1 Aug 2018 1.00 AM
root / linksafe
0644
watchers.pyc
5.387 KB
22 Oct 2019 3.11 AM
root / linksafe
0644
watchers.pyo
5.387 KB
22 Oct 2019 3.11 AM
root / linksafe
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF