添加一个python目录

This commit is contained in:
hekaiyu 2025-12-11 16:36:46 +08:00
parent b37b982d8e
commit ca1cd80f97
3 changed files with 10 additions and 5 deletions

View File

@ -9,6 +9,11 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "t1h-download") @ConfigurationProperties(prefix = "t1h-download")
public class T1hDownloadProperties { public class T1hDownloadProperties {
/**
* python环境路径
*/
private String pythonPath;
/** /**
* 下载T1H的Py脚本路径 * 下载T1H的Py脚本路径
*/ */

View File

@ -24,7 +24,8 @@ public class ExecutePyUtils {
processWatch.start(); processWatch.start();
Process process = null; Process process = null;
try { try {
System.out.println("执行命令: " + String.join(" ", processBuilder.command()));
System.out.println("工作目录: " + processBuilder.directory());
process = processBuilder.start(); process = processBuilder.start();
// 异步处理输出流 // 异步处理输出流

View File

@ -86,7 +86,7 @@ public class DownloadT1hJob {
List<String> forecastTimes = generateForecastTimes(); List<String> forecastTimes = generateForecastTimes();
ProcessBuilder processBuilder = new ProcessBuilder( ProcessBuilder processBuilder = new ProcessBuilder(
systemStorageProperties.getAiModelsPath() + File.separator + "python3 ", t1hDownloadProperties.getPythonPath(),
getPythonScriptPath(t1hDownloadProperties.getMergeT1hPy()), getPythonScriptPath(t1hDownloadProperties.getMergeT1hPy()),
"--indir", getFullPath(t1hDownloadProperties.getT1hPath(), baseTime), "--indir", getFullPath(t1hDownloadProperties.getT1hPath(), baseTime),
"--output_dir", getFullPath(systemStorageProperties.getT1h(), baseTime), "--output_dir", getFullPath(systemStorageProperties.getT1h(), baseTime),
@ -94,7 +94,7 @@ public class DownloadT1hJob {
"--forecast_times", String.join(",", forecastTimes), "--forecast_times", String.join(",", forecastTimes),
"--base_date", baseTime "--base_date", baseTime
); );
processBuilder.directory(new File(systemStorageProperties.getRootPath()));
ExecutePyUtils.executePythonProcess(processBuilder, "文件合并"); ExecutePyUtils.executePythonProcess(processBuilder, "文件合并");
} }
@ -127,7 +127,6 @@ public class DownloadT1hJob {
log.info("执行Python脚本: {}", Arrays.toString(command)); log.info("执行Python脚本: {}", Arrays.toString(command));
ProcessBuilder processBuilder = new ProcessBuilder(command); ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(new File(systemStorageProperties.getRootPath()));
ExecutePyUtils.executePythonProcess(processBuilder, ExecutePyUtils.executePythonProcess(processBuilder,
String.format("元素%s预报时长%s下载", element, forecastHours)); String.format("元素%s预报时长%s下载", element, forecastHours));
} }
@ -137,7 +136,7 @@ public class DownloadT1hJob {
*/ */
private String[] buildPythonCommand(String element, String baseTime, String forecastHours) { private String[] buildPythonCommand(String element, String baseTime, String forecastHours) {
return new String[]{ return new String[]{
systemStorageProperties.getAiModelsPath() + File.separator + "python3 ", t1hDownloadProperties.getPythonPath(),
getPythonScriptPath(t1hDownloadProperties.getDownloadT1hPy()), getPythonScriptPath(t1hDownloadProperties.getDownloadT1hPy()),
"--base-time", baseTime, "--base-time", baseTime,
"--element", element, "--element", element,