-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunall
More file actions
executable file
·61 lines (41 loc) · 1.06 KB
/
runall
File metadata and controls
executable file
·61 lines (41 loc) · 1.06 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# Runs all jobs specified in an input file using threading
### Imports
import sys
from multiprocessing import Pool
#from subprocess import check_call, call
import os
def run_command(cmd):
command = cmd.split()[0]
tmp_args = cmd.split()[1:]
args = ""
for arg in tmp_args:
args += arg + " "
print "command = ", command
print "args = ", args
#check_call([command,args])
#call(command, args)
os.system(cmd)
if __name__ == '__main__':
usage=" Usage: runall job-file nprocs"
### Exit conditions if input != usage
if len(sys.argv) != 3:
print usage
sys.exit(1)
f_jobs = sys.argv[1]
nprocs = int(sys.argv[2])
print "nprocs = ", nprocs
if nprocs < 1:
print "Error."
sys.exit(1)
debug = True
f = open(f_jobs, "r")
Jobs = f.readlines()
f.close()
N_jobs = len(Jobs)
print "N_jobs = ", N_jobs
if N_jobs < 1:
print "Error."
sys.exit(1)
pool = Pool(processes=nprocs)
pool.map(run_command, Jobs)