|
16 | 16 | import java.util.Map; |
17 | 17 | import java.util.Properties; |
18 | 18 | import java.util.concurrent.ExecutionException; |
| 19 | +import java.util.logging.Level; |
19 | 20 | import java.util.logging.Logger; |
20 | 21 | import java.util.prefs.Preferences; |
21 | 22 | import java.util.regex.Matcher; |
@@ -148,7 +149,13 @@ public static String getTermFontFam() { |
148 | 149 | } |
149 | 150 |
|
150 | 151 | public static String getServerVersion() throws IOException { |
151 | | - return getCommandOutput(new String[]{getLspPythonExe(), "-m", "pylsp", "--version"}, null); |
| 152 | + String commandOutput = getCommandOutput(new String[]{getLspPythonExe(), "-m", "pylsp", "--version"}, null); |
| 153 | + if (!commandOutput.startsWith("__main__.py")) { |
| 154 | + LOG.log(Level.SEVERE, commandOutput); |
| 155 | + return "UNKNOW"; |
| 156 | + } |
| 157 | + return commandOutput; |
| 158 | + |
152 | 159 | } |
153 | 160 |
|
154 | 161 | public static String getCommandOutput(String[] cmd, FileObject projectDir) throws IOException { |
@@ -291,7 +298,12 @@ public static Properties getProperties(@NonNull Project project, boolean isCreat |
291 | 298 | } |
292 | 299 |
|
293 | 300 | public static String getVersion(String projectPythonExe) throws IOException { |
294 | | - return getCommandOutput(new String[]{projectPythonExe, "--version"}, null); |
| 301 | + String commandOutput = getCommandOutput(new String[]{projectPythonExe, "--version"}, null); |
| 302 | + if (!commandOutput.startsWith("Py")) { |
| 303 | + LOG.log(Level.SEVERE, commandOutput); |
| 304 | + return ""; |
| 305 | + } |
| 306 | + return commandOutput; |
295 | 307 | } |
296 | 308 |
|
297 | 309 | public static ImageIcon getErrorIcon() { |
|
0 commit comments