* The main thread for this class invoked by Thread.run()
*
* @see java.lang.Thread#run()
*/
public void run() {
PythonInterpreter p = new PythonInterpreter();
for (String name : this.locals.keySet()) {
p.set(name, this.locals.get(name));
}
URL jarUrl = JythonServer.class.getProtectionDomain().getCodeSource().getLocation();
String jarPath = jarUrl.getPath();
if (jarUrl.getProtocol().equals("file")) {
// If URL is of type file, assume that we are in dev env and set path to python dir.
// else use the jar file as is
jarPath = jarPath + "../../src/main/python/";
}
p.exec("import sys");
p.exec("sys.path.append('" + jarPath + "')");
p.exec("from debugserver import run_server");
if (this.host == null) {
p.exec("run_server(port=" + this.port + ", locals=locals())");
} else {
p.exec("run_server(port=" + this.port + ", host='" + this.host + "', locals=locals())");
}
}