当前位置: 首页>>代码示例>>Python>>正文


Python Task.get_dump方法代码示例

本文整理汇总了Python中Task.Task.get_dump方法的典型用法代码示例。如果您正苦于以下问题:Python Task.get_dump方法的具体用法?Python Task.get_dump怎么用?Python Task.get_dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Task.Task的用法示例。


在下文中一共展示了Task.get_dump方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Workflow

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import get_dump [as 别名]

#.........这里部分代码省略.........
        Runs the next task.
        Returns True if completed, False otherwise.

        :type  pick_up: boolean
        :param pick_up: When True, this method attempts to choose the next
                        task not by searching beginning at the root, but by
                        searching from the position at which the last call
                        of complete_next() left off.
        :rtype:  boolean
        :returns: True if all tasks were completed, False otherwise.
        """
        # Try to pick up where we left off.
        blacklist = []
        if pick_up and self.last_task is not None:
            try:
                iter = Task.Iterator(self.last_task, Task.READY)
                next = iter.next()
            except:
                next = None
            self.last_task = None
            if next is not None:
                if next.complete():
                    self.last_task = next
                    return True
                blacklist.append(next)

        # Walk through all ready tasks.
        for task in Task.Iterator(self.task_tree, Task.READY):
            for blacklisted_task in blacklist:
                if task._is_descendant_of(blacklisted_task):
                    continue
            if task.complete():
                self.last_task = task
                return True
            blacklist.append(task)

        # Walk through all waiting tasks.
        for task in Task.Iterator(self.task_tree, Task.WAITING):
            task.task_spec._update_state(task)
            if not task._has_state(Task.WAITING):
                self.last_task = task
                return True
        return False

    def complete_all(self, pick_up=True):
        """
        Runs all branches until completion. This is a convenience wrapper
        around complete_next(), and the pick_up argument is passed along.

        :type  pick_up: boolean
        :param pick_up: Passed on to each call of complete_next().
        """
        while self.complete_next(pick_up):
            pass

    def get_dump(self):
        """
        Returns a complete dump of the current internal task tree for
        debugging.

        :rtype:  string
        :returns: The debug information.
        """
        return self.task_tree.get_dump()

    def dump(self):
        """
        Like get_dump(), but prints the output to the terminal instead of
        returning it.
        """
        print self.task_tree.dump()

    def serialize(self, serializer, **kwargs):
        """
        Serializes a Workflow instance using the provided serializer.

        :type  serializer: L{SpiffWorkflow.storage.Serializer}
        :param serializer: The serializer to use.
        :type  kwargs: dict
        :param kwargs: Passed to the serializer.
        :rtype:  object
        :returns: The serialized workflow.
        """
        return serializer.serialize_workflow(self, **kwargs)

    @classmethod
    def deserialize(cls, serializer, s_state, **kwargs):
        """
        Deserializes a Workflow instance using the provided serializer.

        :type  serializer: L{SpiffWorkflow.storage.Serializer}
        :param serializer: The serializer to use.
        :type  s_state: object
        :param s_state: The serialized workflow.
        :type  kwargs: dict
        :param kwargs: Passed to the serializer.
        :rtype:  Workflow
        :returns: The workflow instance.
        """
        return serializer.deserialize_workflow(s_state, **kwargs)
开发者ID:dave42,项目名称:SpiffWorkflow,代码行数:104,代码来源:Workflow.py

示例2: Job

# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import get_dump [as 别名]

#.........这里部分代码省略.........
        return self.workflow.get_task_from_name(name)


    def get_tasks(self, state = Task.ANY_MASK):
        """
        Returns a list of Task objects with the given state.

        @type  state: integer
        @param state: A bitmask of states.
        @rtype:  list[Task]
        @return: A list of tasks.
        """
        return [t for t in Task.Iterator(self.task_tree, state)]


    def complete_task_from_id(self, node_id):
        """
        Runs the task with the given id.

        @type  node_id: integer
        @param node_id: The id of the Task object.
        """
        if node_id is None:
            raise WorkflowException(self.workflow, 'node_id is None')
        for node in self.task_tree:
            if node.id == node_id:
                return node.complete()
        msg = 'A node with the given node_id (%s) was not found' % node_id
        raise WorkflowException(self.workflow, msg)


    def complete_next(self, pick_up = True):
        """
        Runs the next task.
        Returns True if completed, False otherwise.

        @type  pick_up: boolean
        @param pick_up: When True, this method attempts to choose the next
                        task not by searching beginning at the root, but by
                        searching from the position at which the last call
                        of complete_next() left off.
        @rtype:  boolean
        @return: True if all tasks were completed, False otherwise.
        """
        # Try to pick up where we left off.
        blacklist = []
        if pick_up and self.last_node is not None:
            try:
                iter = Task.Iterator(self.last_node, Task.READY)
                next = iter.next()
            except:
                next = None
            self.last_node = None
            if next is not None:
                if next.complete():
                    self.last_node = next
                    return True
                blacklist.append(next)

        # Walk through all waiting tasks.
        for node in Task.Iterator(self.task_tree, Task.READY):
            for blacklisted_node in blacklist:
                if node._is_descendant_of(blacklisted_node):
                    continue
            if node.complete():
                self.last_node = node
                return True
            blacklist.append(node)
        return False


    def complete_all(self, pick_up = True):
        """
        Runs all branches until completion. This is a convinience wrapper
        around complete_next(), and the pick_up argument is passed along.

        @type  pick_up: boolean
        @param pick_up: Passed on to each call of complete_next().
        """
        while self.complete_next(pick_up):
            pass


    def get_dump(self):
        """
        Returns a complete dump of the current internal task tree for
        debugging.

        @rtype:  string
        @return: The debug information.
        """
        return self.task_tree.get_dump()


    def dump(self):
        """
        Like get_dump(), but prints the output to the terminal instead of
        returning it.
        """
        return self.task_tree.dump()
开发者ID:gonicus,项目名称:clacks,代码行数:104,代码来源:Job.py


注:本文中的Task.Task.get_dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。