def esub(args, bsubargs, jobscript): data = {"command": ""} if args.aices: data["project"] = "aices" if args.aices2: data["project"] = "aices2" scriptargs = [] for line in jobscript.splitlines(True): if line.startswith("#!"): data["command"] += line elif line.startswith("#BSUB "): scriptargs += shlex.split(line[6:].split("#")[0]) else: data["command"] += line.split("#")[0] bsubargs = scriptargs + bsubargs last = False cmd = False for arg in bsubargs: if cmd: data["command"] += " " + arg continue if arg[0] == "-": if last: data[last] = True last = arg else: if last: data[last] = arg last = False else: cmd = True data["command"] = arg if last: data[last] = True try: jobid = submitjob(data) subprocess.Popen(["ejobs", "--noheader", jobid]) except Exception as e: print(color(e.strerror, "r")) sys.exit(-1)
def esub(args, bsubargs, jobscript): """Wrapper script with bsub functionality.""" data = {"command": ""} scriptargs = [] for line in jobscript.splitlines(True): if line.startswith("#!"): data["command"] += line elif line.startswith("#BSUB "): scriptargs += shlex.split(line[6:].split("#")[0]) else: data["command"] += line.split("#")[0] bsubargs = scriptargs + bsubargs last = False cmd = False for arg in bsubargs: if cmd: data["command"] += " " + arg continue if arg[0] == "-": if last: data[last] = True last = arg else: if last: data[last] = arg last = False else: cmd = True data["command"] = arg if last: data[last] = True try: jobid = submitjob(data) print(jobid) except Exception as e: print(color(e.strerror, "r")) sys.exit(-1)