Makefile: add pickrand
[cmccabe-bin] / classpath_builder.py
1 #!/usr/bin/python
2
3 import os
4 import subprocess
5 import sys
6
7 def usage():
8     print >>sys.stderr, "classpath_builder takes a directory, and returns \
9 the CLASSPATH environment variable that would give you access to all the \
10 jars in or under that directory.\n"
11     print >>sys.stderr, "Usage: classpath_builder.py [directory-name]"
12
13 if (len(sys.argv) == 1):
14     usage()
15     sys.exit(1)
16 if (sys.argv[1] == "-h") or (sys.argv[1] == "--help"):
17     usage()
18     sys.exit(0)
19 if (not os.path.exists(sys.argv[1])):
20     usage()
21     sys.exit(1)
22 proc = subprocess.Popen(["find", sys.argv[1], "-name", "*.jar"], \
23     shell=False, stdout=subprocess.PIPE)
24 data = proc.communicate()[0]
25 lines = data.splitlines()
26 sep=""
27 outs=":".join(lines)
28 print "CLASSPATH=\"$CLASSPATH:" + outs + "\""