public static void chdir(PyObject path) { PySystemState sys = Py.getSystemState(); Path absolutePath = absolutePath(path); // stat raises ENOENT for us if path doesn't exist if (!basicstat(path, absolutePath).isDirectory()) { throw Py.OSError(Errno.ENOTDIR, path); } if (os == OS.NT) { // No symbolic links and preserve dos-like names (e.g. PROGRA~1) sys.setCurrentWorkingDir(absolutePath.toString()); } else { // Resolve symbolic links try { sys.setCurrentWorkingDir(absolutePath.toRealPath().toString()); } catch (IOException ioe) { throw Py.OSError(ioe); } } }
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { PySystemState sys = new PySystemState(); sys.setCurrentWorkingDir(build.getWorkspace().getRemote()); PythonInterpreter interp = new PythonInterpreter(null, sys); interp.setOut(listener.getLogger()); interp.setErr(listener.getLogger()); interp.exec(this.getCommand()); interp.cleanup(); build.setResult(Result.SUCCESS); return true; } }