1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """Intermediate data structure produced by builders and sent to the
21 dependence directed acyclic graph (DAG) that sequences execution.
22
23 Users who create their own builders to call python functions should emit
24 an plan_t object and add it to the DAG.
25 """
26
28 """
29 An object that the builders create and is passed to the DAG L{dag_t} to
30 order the tasks. This is used exclusively to create
31 L{command_t}'s.
32 """
33 - def __init__(self, command, args=None, env=None, input=None, output=None, name=None):
34 """
35 Create an input record for the L{dag_t} describing a
36 command. The command can be a string to execute or a python
37 function or a list of strings and python functions. The python
38 function will be passed two arguments: args and env. args is
39 typically a list, but could be anything.
40
41 The input and output lists of files are used by the L{dag_t} to
42 order this command relative to other commands.
43
44 When the command is a python function, the python function is
45 called with two arguments: args and an env of type
46 L{env_t}. The args can be anything but are typically the
47 inputs to the python function and any information required to
48 generate the corresponding outputs. The python functions return
49 a 2-typle (retcode, stdout).
50
51 The input list: When the command is a python function, the
52 plan_t's input list contains at least the input files names
53 passed via args variable. The input list can be a superset
54 containing more stuff that might trigger the command
55 execution.
56
57 If the command does not produce a specific output, you can
58 specify a dummy file name to allow sequencing relative to
59 other commands.
60
61 @type command: string or python function or a list
62 @param command: string or python function.
63
64 @type args: list
65 @param args: (optional) arguments to the command if it is a python function
66
67 @type env: L{env_t}
68 @param env: (optional) an environment to pass to the python function
69
70 @type input: list
71 @param input: (optional) files upon which this command depends.
72
73 @type output: list
74 @param output: (optional) files which depend on this command.
75
76 @type name: string
77 @param name: (optional) short name to be used to identify the work/task
78 """
79 self.command = command
80 self.args = args
81 self.env = env
82 self.input = input
83 self.output = output
84 self.name = name
85
87 s = []
88 if self.name:
89 s.append('NAME: ' + str(self.name))
90 s.append('CMD: ' + str(self.command))
91 s.append('INPUT: ' + str(self.input))
92 s.append('OUTPUT: ' + str(self.output))
93 return " ".join(s)
94