-----------------------------------------------------------------------------
| 211 | |
| 212 | //----------------------------------------------------------------------------- |
| 213 | void pqPythonManager::executeScript(const QString& filename, vtkTypeUInt32 location) |
| 214 | { |
| 215 | // read python script from file |
| 216 | auto pxm = pqApplicationCore::instance()->getActiveServer()->proxyManager(); |
| 217 | const auto pyScript = pxm->LoadString(filename.toUtf8().data(), location); |
| 218 | if (pyScript.empty()) |
| 219 | { |
| 220 | qCritical() << "Failed to open file : " << filename; |
| 221 | return; |
| 222 | } |
| 223 | |
| 224 | const QByteArray code = QString(pyScript.c_str()).toLocal8Bit(); |
| 225 | const QVector<QByteArray> pre_cmd = { "import sys", |
| 226 | QString("__file__ = r'%1'").arg(filename).toUtf8() }; |
| 227 | const QVector<QByteArray> post_cmd = { "del __file__" }; |
| 228 | this->executeCode(code, pre_cmd, post_cmd); |
| 229 | } |
| 230 | |
| 231 | //----------------------------------------------------------------------------- |
| 232 | void pqPythonManager::executeScriptAndRender(const QString& filename, vtkTypeUInt32 location) |
no test coverage detected