forked from lcorcodilos/BstarToTW_CMSDAS2020
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CondorHelper.py
45 lines (34 loc) · 1.46 KB
/
CondorHelper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import subprocess
from optparse import OptionParser
import time
parser = OptionParser()
parser.add_option('-r', '--runscript', metavar='FILE', type='string', action='store',
default = '',
dest = 'runscript',
help = 'Run template to use')
parser.add_option('-i', '--inputs', metavar='FILE', type='string', action='store',
default = '',
dest = 'inputs',
help = 'Inputs to send along')
parser.add_option('-a', '--args', metavar='FILE', type='string', action='store',
default = '',
dest = 'args',
help = 'Text file with python arguments')
(options, args) = parser.parse_args()
commands = []
print(options.args)
# Tar stuff
if options.inputs != '':
commands.append("tar czvf tarball.tgz "+options.inputs)
commands.append('mkdir -p condor/logs/')
commands.append('mkdir -p logs/')
# Make JDL from template
timestr = time.strftime("%Y%m%d-%H%M%S")
out_jdl = 'temp_'+timestr+'_jdl'
commands.append("sed 's$TEMPSCRIPT$"+options.runscript+"$g' $CMSSW_BASE/src/TIMBER/TIMBER/Utilities/Condor/templates/jdl_template > "+out_jdl)
commands.append("sed -i 's$TEMPARGS$"+options.args+"$g' "+out_jdl)
commands.append("condor_submit "+out_jdl+" -debugfile condor_submit_debug.log")
commands.append("mv "+out_jdl+" condor/logs/")
for s in commands:
print(s)
subprocess.call([s],shell=True)