119 |
|
#=================================================================================================== |
120 |
|
# Define string to explain usage of the script |
121 |
|
usage = \ |
122 |
< |
"\nUsage: jobSitter.py [ --pattern= --blacklist=" + \ |
123 |
< |
" --status --help --backward --clean --extend --one --exe ]\n" |
122 |
> |
"\nUsage: jobSitter.py [ --pattern= --apattern= --blacklist=" \ |
123 |
> |
+ " --status --kill --remove --help --backward --clean --extend --one" \ |
124 |
> |
+ " --exe ]\n" |
125 |
|
|
126 |
|
# Define the valid options which can be specified and check out the command line |
127 |
< |
valid = ['pattern=','blacklist=','catalog=','help','backward','kill','clean','exe','extend','one'] |
127 |
> |
valid = ['pattern=','apattern=','blacklist=','catalog=', |
128 |
> |
'help','backward','kill','remove','clean','exe','extend','one'] |
129 |
|
try: |
130 |
|
opts, args = getopt.getopt(sys.argv[1:], "", valid) |
131 |
|
except getopt.GetoptError, ex: |
138 |
|
# -------------------------------------------------------------------------------------------------- |
139 |
|
# Set defaults |
140 |
|
pattern = '' |
141 |
+ |
apattern = '' |
142 |
|
blacklist = '' |
143 |
|
catalog = 0 |
144 |
|
clean = 0 |
145 |
|
kill = 0 |
146 |
+ |
remove = 0 |
147 |
|
exe = 0 |
148 |
|
extend = 0 |
149 |
|
one = 0 |
156 |
|
sys.exit(0) |
157 |
|
if opt == "--pattern": |
158 |
|
pattern = arg |
159 |
+ |
if opt == "--apattern": |
160 |
+ |
apattern = arg |
161 |
|
if opt == "--blacklist": |
162 |
|
blacklist = arg |
163 |
|
if opt == "--catalog": |
174 |
|
backward = ' -r ' |
175 |
|
if opt == "--kill": |
176 |
|
kill = 1 |
177 |
+ |
if opt == "--remove": |
178 |
+ |
remove = 1 |
179 |
|
|
180 |
|
# -------------------------------------------------------------------------------------------------- |
181 |
|
# Here is where the real action starts ------------------------------------------------------------- |
196 |
|
crabTask = task.Task(tag) |
197 |
|
|
198 |
|
#print 'Pattern: ' + pattern + ' tag: ' + crabTask.mitDataset |
199 |
+ |
if apattern != '' and re.search(apattern,crabTask.mitDataset): |
200 |
+ |
print '\n Skipping: ' + crabTask.mitDataset + '\n\n' |
201 |
|
if re.search(pattern,crabTask.mitDataset): |
202 |
|
crabTasks.append(crabTask) |
203 |
|
crabTask.show() |
207 |
|
|
208 |
|
# Process the crab tasks determined to be relevant in the last query |
209 |
|
print '\n==============================================================================' |
210 |
< |
print ' Process crab task list (please wait, crab commands are first fully parsed)\n' |
210 |
> |
print ' Process crab task list\n' |
211 |
|
i = 0 |
212 |
|
for crabTask in crabTasks: |
213 |
|
|
224 |
|
crabTask.killAndRemove(1) |
225 |
|
continue |
226 |
|
|
227 |
+ |
if remove == 1: |
228 |
+ |
crabTask.remove(1) |
229 |
+ |
continue |
230 |
+ |
|
231 |
|
crabTask.loadAllLfns(crabTask.mitCfg + '/' + crabTask.mitVersion + '/' + \ |
232 |
|
crabTask.mitDataset + '.lfns') |
233 |
|
#if crabTask.status == 'cataloged': |
276 |
|
if extend == 1: |
277 |
|
cmd = 'crab -extend -c ' + crabTask.tag |
278 |
|
print '\n------------------------------------------------------------------------------' |
279 |
< |
print ' --> EXTEND ' + crabTask.tag + ' -- wait crab commands first fully parsed -- ' \ |
279 |
> |
print ' --> EXTEND ' + crabTask.tag + ' -- ' \ |
280 |
|
+ '\n -> ' + dataset + ' (' + crabTask.mitDataset + ')'\ |
281 |
|
+ '\n -> ' + storageEle \ |
282 |
|
+ '\n -> ' + storagePath |
285 |
|
os.system(cmd) |
286 |
|
|
287 |
|
print '\n------------------------------------------------------------------------------' |
288 |
< |
print ' --> STATUS ' + crabTask.tag + ' -- wait crab commands first fully parsed -- ' \ |
288 |
> |
print ' --> STATUS ' + crabTask.tag + ' -- ' \ |
289 |
|
+ '\n -> ' + dataset + ' (' + crabTask.mitDataset + ')'\ |
290 |
|
+ '\n -> ' + storageEle \ |
291 |
|
+ '\n -> ' + storagePath |
361 |
|
|
362 |
|
cmd = 'crab -getoutput -continue ' + crabTask.tag |
363 |
|
print '\n------------------------------------------------------------------------------' |
364 |
< |
print ' --> GETOUTPUT ' + crabTask.tag + ' -- wait crab commands first fully parsed -- ' \ |
364 |
> |
print ' --> GETOUTPUT ' + crabTask.tag + ' -- ' \ |
365 |
|
+ '\n -> ' + dataset \ |
366 |
|
+ '\n -> ' + storageEle \ |
367 |
|
+ '\n -> ' + storagePath |