mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-22 16:18:10 +00:00
Add all jython directories found in class path to jython interpreter's path (#751)
This commit is contained in:
parent
3a16b6e280
commit
c7d4130fab
@ -14,7 +14,9 @@
|
|||||||
package metadata.etl;
|
package metadata.etl;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.python.core.PyDictionary;
|
import org.python.core.PyDictionary;
|
||||||
import org.python.core.PyString;
|
import org.python.core.PyString;
|
||||||
@ -50,14 +52,25 @@ public abstract class EtlJob extends BaseJob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addJythonToPath(PySystemState pySystemState) {
|
private void addJythonToPath(PySystemState pySystemState) {
|
||||||
URL url = classLoader.getResource("jython");
|
Enumeration<URL> urls;
|
||||||
if (url != null) {
|
try {
|
||||||
File file = new File(url.getFile());
|
urls = classLoader.getResources("jython/");
|
||||||
String path = file.getPath();
|
} catch (IOException e) {
|
||||||
if (path.startsWith("file:")) {
|
logger.info("Failed to get resource: {}", e.getMessage());
|
||||||
path = path.substring(5);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (urls.hasMoreElements()) {
|
||||||
|
URL url = urls.nextElement();
|
||||||
|
logger.debug("jython url: {}", url.getPath());
|
||||||
|
if (url != null) {
|
||||||
|
File file = new File(url.getFile());
|
||||||
|
String path = file.getPath();
|
||||||
|
if (path.startsWith("file:")) {
|
||||||
|
path = path.substring(5);
|
||||||
|
}
|
||||||
|
pySystemState.path.append(new PyString(path.replace("!", "")));
|
||||||
}
|
}
|
||||||
pySystemState.path.append(new PyString(path.replace("!", "")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user