|
@@ 463-488 (lines=26) @@
|
| 460 |
|
def dependencies(self): |
| 461 |
|
""" |
| 462 |
|
Return the list of this action's dependencies. |
| 463 |
|
""" |
| 464 |
|
return list(self.__dependencies) |
| 465 |
|
|
| 466 |
|
def get_all_dependencies(self): |
| 467 |
|
""" |
| 468 |
|
Return the set of this action's recursive dependencies, including itself. |
| 469 |
|
""" |
| 470 |
|
dependencies = set([self]) |
| 471 |
|
for dependency in self.__dependencies: |
| 472 |
|
dependencies |= dependency.get_all_dependencies() |
| 473 |
|
return dependencies |
| 474 |
|
|
| 475 |
|
def get_preview(self): |
| 476 |
|
""" |
| 477 |
|
Return the labels of this action and its dependencies, in an order that could be the execution order. |
| 478 |
|
""" |
| 479 |
|
return [action.__label for action in self.get_possible_execution_order()] |
| 480 |
|
|
| 481 |
|
def get_possible_execution_order(self, seen_actions=None): |
| 482 |
|
if seen_actions is None: |
| 483 |
|
seen_actions = set() |
| 484 |
|
actions = [] |
| 485 |
|
if self not in seen_actions: |
| 486 |
|
seen_actions.add(self) |
| 487 |
|
for dependency in self.__dependencies: |
| 488 |
|
actions += dependency.get_possible_execution_order(seen_actions) |
| 489 |
|
actions.append(self) |
| 490 |
|
return actions |
| 491 |
|
|
|
@@ 490-513 (lines=24) @@
|
| 487 |
|
for dependency in self.__dependencies: |
| 488 |
|
actions += dependency.get_possible_execution_order(seen_actions) |
| 489 |
|
actions.append(self) |
| 490 |
|
return actions |
| 491 |
|
|
| 492 |
|
|
| 493 |
|
class CompoundException(Exception): |
| 494 |
|
""" |
| 495 |
|
Exception thrown by :func:`.execute` when a dependencies raise exceptions. |
| 496 |
|
""" |
| 497 |
|
|
| 498 |
|
def __init__(self, exceptions, execution_report): |
| 499 |
|
super(CompoundException, self).__init__(exceptions) |
| 500 |
|
self.__exceptions = exceptions |
| 501 |
|
self.__execution_report = execution_report |
| 502 |
|
|
| 503 |
|
@property |
| 504 |
|
def exceptions(self): |
| 505 |
|
""" |
| 506 |
|
The list of the encapsulated exceptions. |
| 507 |
|
""" |
| 508 |
|
return self.__exceptions |
| 509 |
|
|
| 510 |
|
@property |
| 511 |
|
def execution_report(self): |
| 512 |
|
""" |
| 513 |
|
The :class:`.ExecutionReport` of the failed execution. |
| 514 |
|
""" |
| 515 |
|
return self.__execution_report |
| 516 |
|
|