MCPcopy Create free account
hub / github.com/MrKepzie/Natron / loadPythonGroups

Method loadPythonGroups

Engine/AppManager.cpp:1915–2095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1913}
1914
1915void
1916AppManager::loadPythonGroups()
1917{
1918#ifdef NATRON_RUN_WITHOUT_PYTHON
1919
1920 return;
1921#endif
1922 PythonGILLocker pgl;
1923 QStringList templatesSearchPath = getAllNonOFXPluginsPaths();
1924 std::string err;
1925 QStringList allPlugins;
1926
1927 ///For all search paths, first add the path to the python path, then run in order the init.py and initGui.py
1928 Q_FOREACH(const QString &templatesSearchDir, templatesSearchPath) {
1929 //Adding Qt resources to Python path is useless as Python does not know how to use it
1930 if ( templatesSearchDir.startsWith( QString::fromUtf8(":/Resources") ) ) {
1931 continue;
1932 }
1933 QDir d(templatesSearchDir);
1934 operateOnPathRecursive(&addToPythonPathFunctor, d);
1935 }
1936
1937 ///Also import Pyside.QtCore and Pyside.QtGui (the later only in non background mode)
1938 {
1939 std::string s;
1940 if (SHIBOKEN_MAJOR_VERSION == 2) {
1941 s = "import PySide2\nimport PySide2.QtCore as QtCore";
1942 } else {
1943 s = "import PySide\nimport PySide.QtCore as QtCore";
1944 }
1945 bool ok = NATRON_PYTHON_NAMESPACE::interpretPythonScript(s, &err, 0);
1946 if (!ok) {
1947 QString message = tr("Failed to import PySide.QtCore, make sure it is bundled with your Natron installation "
1948 "or reachable through the Python path. "
1949 "Note that Natron disables usage "
1950 "of site-packages).");
1951 std::cerr << message.toStdString() << std::endl;
1952 appPTR->writeToErrorLog_mt_safe(QLatin1String("PySide.QtCore"), QDateTime::currentDateTime(), message);
1953 }
1954 }
1955
1956 if ( !isBackground() ) {
1957 std::string s;
1958 if (SHIBOKEN_MAJOR_VERSION == 2) {
1959 s = "import PySide2.QtGui as QtGui";
1960 } else {
1961 s = "import PySide.QtGui as QtGui";
1962 }
1963 bool ok = NATRON_PYTHON_NAMESPACE::interpretPythonScript(s, &err, 0);
1964 if (!ok) {
1965 QString message = tr("Failed to import PySide.QtGui");
1966 std::cerr << message.toStdString() << std::endl;
1967 appPTR->writeToErrorLog_mt_safe(QLatin1String("PySide.QtGui"), QDateTime::currentDateTime(), message);
1968 }
1969 }
1970
1971
1972 QStringList foundInit;

Callers

nothing calls this directly

Calls 5

toStdStringMethod · 0.80
isEmptyMethod · 0.45
setLoadingStatusMethod · 0.45
isBackgroundMethod · 0.45

Tested by

no test coverage detected