Default Python output to unbuffered (#52)

pull/311/head
Peter Johnson 2019-01-11 03:20:41 -08:00 committed by GitHub
parent f904336fb8
commit f511557b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#!/bin/sh
echo "Waiting 5 seconds..."
sleep 5
export PYTHONUNBUFFERED=1
exec ./multiCameraServer.py

View File

@ -27,6 +27,7 @@ std::shared_ptr<Application> Application::GetInstance() {
void Application::Set(wpi::StringRef appType,
std::function<void(wpi::StringRef)> 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';
}