-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbootstrap.py
executable file
·35 lines (28 loc) · 921 Bytes
/
bootstrap.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
#!/usr/local/bin/jython
# -*- coding: utf-8 -*-
import sys
import os
from os.path import isfile, isdir, abspath
import subprocess
from glob import glob
def read_classpath():
with open("/tmp/classpath.txt", "r") as f:
return f.read()
def write_classpath(classpath):
with open("/tmp/classpath.txt", "w") as f:
f.write(classpath)
if not isfile("/tmp/classpath.txt"):
# Import all required jar files to perform AST construction
paths = [jar for jar in glob("/Libs/*.jar")]
classpath = "%s:%s" % (":".join(paths), os.environ.get("CLASSPATH"))
write_classpath(classpath)
else:
classpath = read_classpath()
os.environ["CLASSPATH"] = classpath
current_dir = os.getcwd()
os.environ["JYTHONPATH"] = current_dir + ":" + ":".join([abspath(folder) for folder in glob("*") if isdir(folder)])
if sys.argv[1] == "clean":
os.remove("/tmp/classpath.txt")
print "Cleaned"
else:
subprocess.call(["jython", sys.argv[1]])