| 147 | } |
| 148 | |
| 149 | Scripting::RunResult Scripting::runScriptFromFile(const std::filesystem::path& path, Context& context, bool captureOutput) |
| 150 | { |
| 151 | if (std::filesystem::exists(path)) |
| 152 | { |
| 153 | std::string absFile = std::filesystem::absolute(path).string(); |
| 154 | context.setObject("__file__", absFile); |
| 155 | auto result = Scripting::runScript(readFile(path), context, captureOutput); |
| 156 | context.setObject("__file__", nullptr); // There seems to be no API on pybind11::dict to remove a key. |
| 157 | return result; |
| 158 | } |
| 159 | FALCOR_THROW("Failed to run script. Can't find the file '{}'.", path); |
| 160 | } |
| 161 | |
| 162 | std::string Scripting::interpretScript(const std::string& script, Context& context) |
| 163 | { |