From b745250a00bdb92307df9cfe4e66713055b7ca85 Mon Sep 17 00:00:00 2001 From: skogaby Date: Fri, 1 Feb 2019 19:37:47 -0600 Subject: [PATCH] Resolve the issue of the Python executable name on different platforms --- src/main/java/com/buttongames/butterfly/util/CardIdUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/buttongames/butterfly/util/CardIdUtils.java b/src/main/java/com/buttongames/butterfly/util/CardIdUtils.java index 2aeeea4..4c6f637 100644 --- a/src/main/java/com/buttongames/butterfly/util/CardIdUtils.java +++ b/src/main/java/com/buttongames/butterfly/util/CardIdUtils.java @@ -41,7 +41,9 @@ public class CardIdUtils { path = Paths.get(Main.class.getResource("/cardconv.py").toURI()); } - final ProcessBuilder builder = new ProcessBuilder("python", + // when running this under Windows, Python 3 still is called python.exe; Linux has python3 as an executable + final String command = System.getProperty("os.name").toLowerCase().startsWith("windows") ? "python" : "python3"; + final ProcessBuilder builder = new ProcessBuilder(command, "-c", "import cardconv; print(cardconv.CardCipher.encode('" + id + "'));"); builder.directory(path.getParent().toFile());