| 10785 | } |
| 10786 | |
| 10787 | void |
| 10788 | Node::declareNodeVariableToPython(const std::string& nodeName) |
| 10789 | { |
| 10790 | #ifdef NATRON_RUN_WITHOUT_PYTHON |
| 10791 | |
| 10792 | return; |
| 10793 | #endif |
| 10794 | if (getScriptName_mt_safe().empty()) { |
| 10795 | return; |
| 10796 | } |
| 10797 | |
| 10798 | |
| 10799 | PythonGILLocker pgl; |
| 10800 | PyObject* mainModule = appPTR->getMainModule(); |
| 10801 | assert(mainModule); |
| 10802 | |
| 10803 | std::string appID = getApp()->getAppIDString(); |
| 10804 | std::string nodeFullName = appID + "." + nodeName; |
| 10805 | bool alreadyDefined = false; |
| 10806 | PyObject* nodeObj = NATRON_PYTHON_NAMESPACE::getAttrRecursive(nodeFullName, mainModule, &alreadyDefined); |
| 10807 | assert(nodeObj); |
| 10808 | Q_UNUSED(nodeObj); |
| 10809 | |
| 10810 | if (!alreadyDefined) { |
| 10811 | std::stringstream ss; |
| 10812 | ss << nodeFullName << " = " << appID << ".getNode(\"" << nodeName << "\")\n"; |
| 10813 | #ifdef DEBUG |
| 10814 | ss << "if not " << nodeFullName << ":\n"; |
| 10815 | ss << " print \"[BUG]: " << nodeFullName << " does not exist!\""; |
| 10816 | #endif |
| 10817 | std::string script = ss.str(); |
| 10818 | std::string output; |
| 10819 | std::string err; |
| 10820 | if ( !appPTR->isBackground() ) { |
| 10821 | getApp()->printAutoDeclaredVariable(script); |
| 10822 | } |
| 10823 | if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(script, &err, &output) ) { |
| 10824 | qDebug() << err.c_str(); |
| 10825 | } |
| 10826 | } |
| 10827 | } |
| 10828 | |
| 10829 | void |
| 10830 | Node::setNodeVariableToPython(const std::string& oldName, |
nothing calls this directly
no test coverage detected