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 #!/bin/sh
echo "Waiting 5 seconds..." echo "Waiting 5 seconds..."
sleep 5 sleep 5
export PYTHONUNBUFFERED=1
exec ./multiCameraServer.py exec ./multiCameraServer.py

View File

@ -27,6 +27,7 @@ std::shared_ptr<Application> Application::GetInstance() {
void Application::Set(wpi::StringRef appType, void Application::Set(wpi::StringRef appType,
std::function<void(wpi::StringRef)> onFail) { std::function<void(wpi::StringRef)> onFail) {
wpi::StringRef appDir; wpi::StringRef appDir;
wpi::StringRef appEnv;
wpi::StringRef appCommand; wpi::StringRef appCommand;
if (appType == "builtin") { if (appType == "builtin") {
@ -41,6 +42,7 @@ void Application::Set(wpi::StringRef appType,
appCommand = "./multiCameraServerExample"; appCommand = "./multiCameraServerExample";
} else if (appType == "example-python") { } else if (appType == "example-python") {
appDir = "examples/python-multiCameraServer"; appDir = "examples/python-multiCameraServer";
appEnv = "export PYTHONUNBUFFERED=1";
appCommand = "./multiCameraServer.py"; appCommand = "./multiCameraServer.py";
} else if (appType == "upload-java") { } else if (appType == "upload-java") {
appCommand = appCommand =
@ -48,6 +50,7 @@ void Application::Set(wpi::StringRef appType,
} else if (appType == "upload-cpp") { } else if (appType == "upload-cpp") {
appCommand = "./uploaded"; appCommand = "./uploaded";
} else if (appType == "upload-python") { } else if (appType == "upload-python") {
appEnv = "export PYTHONUNBUFFERED=1";
appCommand = "./uploaded.py"; appCommand = "./uploaded.py";
} else if (appType == "custom") { } else if (appType == "custom") {
return; return;
@ -73,6 +76,7 @@ void Application::Set(wpi::StringRef appType,
os << "echo \"Waiting 5 seconds...\"\n"; os << "echo \"Waiting 5 seconds...\"\n";
os << "sleep 5\n"; os << "sleep 5\n";
if (!appDir.empty()) os << "cd " << appDir << '\n'; if (!appDir.empty()) os << "cd " << appDir << '\n';
if (!appEnv.empty()) os << appEnv << '\n';
os << "exec " << appCommand << '\n'; os << "exec " << appCommand << '\n';
} }