- Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathlist_apps.py
executable file
·62 lines (52 loc) · 2.41 KB
/
list_apps.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
# cwltool --print-rdf wf_pgap_simple2.cwl | grep baseCommand | cut -d'"' -f2 | sort -u
importsubprocess
importargparse
arg_overrides= {
"sqlite3": "-version",
"cat": "--help",
"split": "--help",
"xsltproc": "--version"
}
defcheck_binaries(binaries):
forbinbinaries:
test_cmd= [b, "-help"]
ifbinarg_overrides:
test_cmd= [b, arg_overrides[b]]
ifb[-3:] ==".py":
# We should try to compile it
# docker run ncbi/gpdev:2018-11-28.prod.build629 /bin/bash -c "python -m py_compile `whereis -b yaml2json.py | cut -d: -f2`"
# cmd = ["docker", "run", "ncbi/gpdev:2018-11-28.prod.build629", "python", "-m", "py_compile", b]
test_str="python -m py_compile `whereis -b {} | cut -d: -f2`".format(b)
test_cmd= ["/bin/bash", "-c", test_str]
cmd= []
cmd.extend(docker_prefix)
cmd.extend(test_cmd)
robj=subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
r=robj.returncode
ifr!=0:
print(robj.stderr)
print(robj.stdout)
else:
print(r, " ".join(test_cmd))
defmain():
parser=argparse.ArgumentParser(description='Test each PGAP binary to see if they can be executed simply.')
parser.add_argument('--workflow', '-w', dest='workflow', default='wf_pgap_simple.cwl',
help='Workflow to garner app list from. (default: %(default)s)')
parser.add_argument('--check', '-c', help='If set, check if programs are executable')
parser.add_argument('--docker', '-d', dest='docker',
help='If check flag set, execute programs in a container based on this image (default: no container)')
args=parser.parse_args()
docker_prefix= []
ifargs.docker:
docker_prefix= ["docker", "run", args.docker]
# where args.docker is image name like "ncbi/gpdev:2018-11-28.prod.build629"
workflow=args.workflow
getcmdstr="cwltool --print-rdf {} | grep baseCommand | cut -d'\"' -f2 | sort -u".format(workflow)
robj=subprocess.run(getcmdstr, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
binaries=robj.stdout.split()
print(binaries)
if (args.check):
check_binaries(binaries)
if__name__=="__main__":
main()