|
@@ -69,10 +69,13 @@ public class PythonExecute {
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
+ String platform = getSystem();
|
|
|
//Runtime方式
|
|
|
JSONObject json = new JSONObject(params);
|
|
|
- String[] arguments = new String[]{"su", "-" , "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
-// String[] arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ String[] arguments = new String[]{"su", "-", "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ if ("windows".equals(platform)) {
|
|
|
+ arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ }
|
|
|
try {
|
|
|
System.out.println(pythonexe);
|
|
|
System.out.println(pythonfile);
|
|
@@ -106,8 +109,11 @@ public class PythonExecute {
|
|
|
System.out.println(pythonfile);
|
|
|
System.out.println(functionName);
|
|
|
System.out.println(Base64Utils.base64Encode(json.toJSONString()));
|
|
|
- String[] arguments = new String[]{"su", "-" , "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
-// String[] arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ String[] arguments = new String[]{"su", "-", "geoscene", pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ String platform = getSystem();
|
|
|
+ if ("windows".equals(platform)) {
|
|
|
+ arguments = new String[]{pythonexe, pythonfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ }
|
|
|
try {
|
|
|
Process process = Runtime.getRuntime().exec(arguments);
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
@@ -141,7 +147,10 @@ public class PythonExecute {
|
|
|
System.out.println(functionName);
|
|
|
System.out.println(Base64Utils.base64Encode(json.toJSONString()));
|
|
|
String[] arguments = new String[]{"su", "-", "geoscene", pythonexe, gisfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
-// String[] arguments = new String[]{pythonexe, gisfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ String platform = getSystem();
|
|
|
+ if ("windows".equals(platform)) {
|
|
|
+ arguments = new String[]{pythonexe, gisfile, functionName, Base64Utils.base64Encode(json.toJSONString())};
|
|
|
+ }
|
|
|
try {
|
|
|
Process process = Runtime.getRuntime().exec(arguments);
|
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
@@ -264,4 +273,15 @@ public class PythonExecute {
|
|
|
this.value = value;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static String getSystem() {
|
|
|
+ String osName = System.getProperty("os.name").toLowerCase();
|
|
|
+ if (osName.contains("win")) {
|
|
|
+ return "windows";
|
|
|
+ } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
|
|
|
+ return "linux";
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|