| | |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.util.ClassUtils; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.LineNumberReader; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Test |
| | | public void pyExec() { |
| | | String result = ""; |
| | | String path = ClassUtils.getDefaultClassLoader().getResource("").getPath(); |
| | | String filePath = path + "static/xch.py"; |
| | | System.out.println(filePath); |
| | | try { |
| | | Process process = Runtime.getRuntime().exec("python " + filePath); |
| | | process.waitFor(); |
| | | InputStreamReader ir = new InputStreamReader(process.getInputStream()); |
| | | LineNumberReader input = new LineNumberReader(ir); |
| | | result = input.readLine(); |
| | | input.close(); |
| | | ir.close(); |
| | | // process.waitFor(); |
| | | } catch (IOException | InterruptedException e) { |
| | | System.out.println(11); |
| | | } |
| | | System.out.println(result); |
| | | } |
| | | } |