Loading escheduler-server/src/main/java/cn/escheduler/server/worker/task/PythonCommandExecutor.java +5 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package cn.escheduler.server.worker.task; import cn.escheduler.common.Constants; import cn.escheduler.common.utils.FileUtils; import cn.escheduler.common.utils.PropertyUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Loading Loading @@ -71,11 +72,11 @@ public class PythonCommandExecutor extends AbstractCommandExecutor { if (!Files.exists(Paths.get(commandFile))) { logger.info("generate command file:{}", commandFile); StringBuilder sb = new StringBuilder(200); StringBuilder sb = new StringBuilder(); sb.append("#-*- encoding=utf8 -*-\n"); sb.append("\n\n"); sb.append(String.format("import py_%s_node\n",taskAppId)); sb.append(execCommand); logger.info(sb.toString()); // write data to file Loading @@ -86,8 +87,8 @@ public class PythonCommandExecutor extends AbstractCommandExecutor { @Override protected String commandType() { String envPath = System.getProperty("user.dir") + Constants.SINGLE_SLASH + "conf"+ Constants.SINGLE_SLASH +"env" + Constants.SINGLE_SLASH + Constants.ESCHEDULER_ENV_SH; String envPath = PropertyUtils.getString(Constants.ESCHEDULER_ENV_PATH); String pythonHome = getPythonHome(envPath); if (StringUtils.isEmpty(pythonHome)){ return PYTHON; Loading escheduler-server/src/main/java/cn/escheduler/server/worker/task/python/PythonTask.java +15 −14 Original line number Diff line number Diff line Loading @@ -112,14 +112,14 @@ public class PythonTask extends AbstractTask { */ private String buildCommand() throws Exception { // generate scripts String fileName = String.format("%s/py_%s_node.py", taskDir, taskProps.getTaskAppId()); Path path = new File(fileName).toPath(); // String fileName = String.format("%s/py_%s_node.py", taskDir, taskProps.getTaskAppId()); // Path path = new File(fileName).toPath(); if (Files.exists(path)) { return fileName; } // if (Files.exists(path)) { // return fileName; // } String rawScript = pythonParameters.getRawScript().replaceAll("\\r\\n", "\n"); Loading @@ -140,19 +140,20 @@ public class PythonTask extends AbstractTask { } pythonParameters.setRawScript(rawScript); // pythonParameters.setRawScript(rawScript); logger.info("raw script : {}", pythonParameters.getRawScript()); logger.info("task dir : {}", taskDir); Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-xr-x"); FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); Files.createFile(path, attr); Files.write(path, pythonParameters.getRawScript().getBytes(), StandardOpenOption.APPEND); return fileName; // Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-xr-x"); // FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); // // Files.createFile(path, attr); // // Files.write(path, pythonParameters.getRawScript().getBytes(), StandardOpenOption.APPEND); // // return fileName; return rawScript; } @Override Loading Loading
escheduler-server/src/main/java/cn/escheduler/server/worker/task/PythonCommandExecutor.java +5 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package cn.escheduler.server.worker.task; import cn.escheduler.common.Constants; import cn.escheduler.common.utils.FileUtils; import cn.escheduler.common.utils.PropertyUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Loading Loading @@ -71,11 +72,11 @@ public class PythonCommandExecutor extends AbstractCommandExecutor { if (!Files.exists(Paths.get(commandFile))) { logger.info("generate command file:{}", commandFile); StringBuilder sb = new StringBuilder(200); StringBuilder sb = new StringBuilder(); sb.append("#-*- encoding=utf8 -*-\n"); sb.append("\n\n"); sb.append(String.format("import py_%s_node\n",taskAppId)); sb.append(execCommand); logger.info(sb.toString()); // write data to file Loading @@ -86,8 +87,8 @@ public class PythonCommandExecutor extends AbstractCommandExecutor { @Override protected String commandType() { String envPath = System.getProperty("user.dir") + Constants.SINGLE_SLASH + "conf"+ Constants.SINGLE_SLASH +"env" + Constants.SINGLE_SLASH + Constants.ESCHEDULER_ENV_SH; String envPath = PropertyUtils.getString(Constants.ESCHEDULER_ENV_PATH); String pythonHome = getPythonHome(envPath); if (StringUtils.isEmpty(pythonHome)){ return PYTHON; Loading
escheduler-server/src/main/java/cn/escheduler/server/worker/task/python/PythonTask.java +15 −14 Original line number Diff line number Diff line Loading @@ -112,14 +112,14 @@ public class PythonTask extends AbstractTask { */ private String buildCommand() throws Exception { // generate scripts String fileName = String.format("%s/py_%s_node.py", taskDir, taskProps.getTaskAppId()); Path path = new File(fileName).toPath(); // String fileName = String.format("%s/py_%s_node.py", taskDir, taskProps.getTaskAppId()); // Path path = new File(fileName).toPath(); if (Files.exists(path)) { return fileName; } // if (Files.exists(path)) { // return fileName; // } String rawScript = pythonParameters.getRawScript().replaceAll("\\r\\n", "\n"); Loading @@ -140,19 +140,20 @@ public class PythonTask extends AbstractTask { } pythonParameters.setRawScript(rawScript); // pythonParameters.setRawScript(rawScript); logger.info("raw script : {}", pythonParameters.getRawScript()); logger.info("task dir : {}", taskDir); Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-xr-x"); FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); Files.createFile(path, attr); Files.write(path, pythonParameters.getRawScript().getBytes(), StandardOpenOption.APPEND); return fileName; // Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-xr-x"); // FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); // // Files.createFile(path, attr); // // Files.write(path, pythonParameters.getRawScript().getBytes(), StandardOpenOption.APPEND); // // return fileName; return rawScript; } @Override Loading