Runs Python visualization using system()
| 69 | |
| 70 | // Runs Python visualization using system() |
| 71 | bool runPythonVisualizer(const VisualizerArgs &args) { |
| 72 | std::pair<int, int> r = tryParseResolution(args.resolution); |
| 73 | |
| 74 | // Create a temporary Python script |
| 75 | std::ofstream tempFile("spectacularAI_temp_visualizer.py"); |
| 76 | tempFile << pythonScript; |
| 77 | tempFile.close(); |
| 78 | |
| 79 | std::stringstream ss; |
| 80 | ss << " spectacularAI_temp_serialization"; |
| 81 | ss << " --resolution " << r.first << "x" << r.second; |
| 82 | ss << " --fps " << args.targetFps; |
| 83 | if (args.fullScreen) |
| 84 | ss << " --fullScreen"; |
| 85 | if (!args.recordWindow.empty()) |
| 86 | ss << " --recordWindow " << args.recordWindow; |
| 87 | if (args.voxelSize > 0) |
| 88 | ss << " --voxel " << args.voxelSize; |
| 89 | if (args.colorOnly) |
| 90 | ss << " --color"; |
| 91 | |
| 92 | // Execute the Python script using system() |
| 93 | std::string pythonCommand = "python spectacularAI_temp_visualizer.py " + ss.str(); |
| 94 | int result = system(pythonCommand.c_str()); |
| 95 | |
| 96 | // Delete the temporary Python script |
| 97 | std::remove("spectacularAI_temp_visualizer.py"); |
| 98 | |
| 99 | return result == 0; |
| 100 | } |
| 101 | |
| 102 | } // anonymous namespace |
| 103 |
no test coverage detected