From 5a44ed71e0cc9a5abd876f244b8503086991fc3d Mon Sep 17 00:00:00 2001 From: Kevin Bogusch Date: Tue, 24 Dec 2024 10:01:27 -0500 Subject: [PATCH] Fixed run_cmd to account for empty stdout On Linux, a successful compile does not produce any standard out, which is what I was implicitly expecting. I added a dummy value for stdout if the command is successful, which ensures that even when the compiler produces no output, we still look like a success. --- week4/day4.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/week4/day4.ipynb b/week4/day4.ipynb index 552d0c4..32f4ffb 100644 --- a/week4/day4.ipynb +++ b/week4/day4.ipynb @@ -455,7 +455,7 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": 113, "id": "e42286bc-085c-45dc-b101-234308e58269", "metadata": {}, "outputs": [], @@ -477,7 +477,7 @@ "def run_cmd(command_to_run):\n", " try:\n", " run_result = subprocess.run(command_to_run, check=True, text=True, capture_output=True)\n", - " return run_result.stdout\n", + " return run_result.stdout if run_result.stdout else \"SUCCESS\"\n", " except:\n", " return \"\"\n", "\n", @@ -513,7 +513,7 @@ " elif my_platform == \"Linux\":\n", " if os.path.isfile(\"./simple\"):\n", " os.remove(\"./simple\")\n", - " compile_cmd = [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]\n", + " compile_cmd = [\"g++\", \"simple.cpp\", \"-o\", \"simple\"]\n", " if run_cmd(compile_cmd):\n", " if run_cmd([\"./simple\"]) == \"Hello\":\n", " my_compiler = [\"Linux\", \"GCC\", [\"g++\", f\"{filename_base}.cpp\", \"-o\", f\"{filename_base}\" ]]\n",