From f511557b89135eff73677934be816700db6f1ea9 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 11 Jan 2019 03:20:41 -0800 Subject: [PATCH] Default Python output to unbuffered (#52) --- deps/examples/python-multiCameraServer/runCamera | 1 + deps/tools/rpiConfigServer_src/Application.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/deps/examples/python-multiCameraServer/runCamera b/deps/examples/python-multiCameraServer/runCamera index 35064a7..83dec0e 100755 --- a/deps/examples/python-multiCameraServer/runCamera +++ b/deps/examples/python-multiCameraServer/runCamera @@ -1,4 +1,5 @@ #!/bin/sh echo "Waiting 5 seconds..." sleep 5 +export PYTHONUNBUFFERED=1 exec ./multiCameraServer.py diff --git a/deps/tools/rpiConfigServer_src/Application.cpp b/deps/tools/rpiConfigServer_src/Application.cpp index 7abbd23..56a3b87 100644 --- a/deps/tools/rpiConfigServer_src/Application.cpp +++ b/deps/tools/rpiConfigServer_src/Application.cpp @@ -27,6 +27,7 @@ std::shared_ptr Application::GetInstance() { void Application::Set(wpi::StringRef appType, std::function onFail) { wpi::StringRef appDir; + wpi::StringRef appEnv; wpi::StringRef appCommand; if (appType == "builtin") { @@ -41,6 +42,7 @@ void Application::Set(wpi::StringRef appType, appCommand = "./multiCameraServerExample"; } else if (appType == "example-python") { appDir = "examples/python-multiCameraServer"; + appEnv = "export PYTHONUNBUFFERED=1"; appCommand = "./multiCameraServer.py"; } else if (appType == "upload-java") { appCommand = @@ -48,6 +50,7 @@ void Application::Set(wpi::StringRef appType, } else if (appType == "upload-cpp") { appCommand = "./uploaded"; } else if (appType == "upload-python") { + appEnv = "export PYTHONUNBUFFERED=1"; appCommand = "./uploaded.py"; } else if (appType == "custom") { return; @@ -73,6 +76,7 @@ void Application::Set(wpi::StringRef appType, os << "echo \"Waiting 5 seconds...\"\n"; os << "sleep 5\n"; if (!appDir.empty()) os << "cd " << appDir << '\n'; + if (!appEnv.empty()) os << appEnv << '\n'; os << "exec " << appCommand << '\n'; }