babymaker  e95a6a9342d4604277fe7cc6149b6b5b24447d89
resubmit_crab.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 from __future__ import print_function
4 
5 import argparse
6 import glob
7 import os
8 import subprocess
9 import time
10 
11 def FullPath(path):
12  return os.path.abspath(os.path.expanduser(path))
13 
14 def Resubmit(dir_list, interval):
15  dir_list = [ FullPath(d) for sub_list in dir_list for d in glob.glob(sub_list) ]
16 
17  print("Resubmitting the following projects every {} seconds:".format(interval))
18  for d in dir_list:
19  print(d)
20  print("")
21 
22  while(True):
23  for d in dir_list:
24  subprocess.call(["crab","resubmit","-d",d])
25  time.sleep(interval)
26 
27 if __name__ == "__main__":
28  parser = argparse.ArgumentParser(description="Resubmits all failed jobs in specified directories repeatedly after specified interval.",
29  formatter_class=argparse.ArgumentDefaultsHelpFormatter)
30  parser.add_argument("resub_dir", nargs="*", help="CRAB directories to resubmit")
31  parser.add_argument("--interval", type=float, default=600, help="Seconds between resubmission attempts.")
32 
33  args = parser.parse_args()
34  Resubmit(args.resub_dir, args.interval)
def FullPath(path)
def Resubmit(dir_list, interval)