| 1834 | } |
| 1835 | |
| 1836 | void |
| 1837 | AppManager::loadPythonGroups() |
| 1838 | { |
| 1839 | #ifdef NATRON_RUN_WITHOUT_PYTHON |
| 1840 | |
| 1841 | return; |
| 1842 | #endif |
| 1843 | PythonGILLocker pgl; // useless? |
| 1844 | QStringList templatesSearchPath = getAllNonOFXPluginsPaths(); |
| 1845 | std::string err; |
| 1846 | QStringList allPlugins; |
| 1847 | |
| 1848 | ///For all search paths, first add the path to the python path, then run in order the init.py and initGui.py |
| 1849 | Q_FOREACH(const QString &templatesSearchDir, templatesSearchPath) { |
| 1850 | //Adding Qt resources to Python path is useless as Python does not know how to use it |
| 1851 | if ( templatesSearchDir.startsWith( QString::fromUtf8(":/Resources") ) ) { |
| 1852 | continue; |
| 1853 | } |
| 1854 | QDir d(templatesSearchDir); |
| 1855 | operateOnPathRecursive(&addToPythonPathFunctor, d); |
| 1856 | } |
| 1857 | |
| 1858 | ///Also import qtpy.QtCore and qtpy.QtGui (the later only in non background mode) |
| 1859 | { |
| 1860 | std::string s; |
| 1861 | s = "import qtpy\nfrom qtpy import QtCore"; |
| 1862 | bool ok = NATRON_PYTHON_NAMESPACE::interpretPythonScript(s, &err, 0); |
| 1863 | if (!ok) { |
| 1864 | QString message = tr("Failed to import qtpy.QtCore, make sure it is bundled with your Natron installation " |
| 1865 | "or reachable through the Python path. " |
| 1866 | "Note that Natron disables usage " |
| 1867 | "of site-packages)."); |
| 1868 | std::cerr << message.toStdString() << std::endl; |
| 1869 | appPTR->writeToErrorLog_mt_safe(QLatin1String("qtpy.QtCore"), QDateTime::currentDateTime(), message); |
| 1870 | } |
| 1871 | } |
| 1872 | |
| 1873 | if ( !isBackground() ) { |
| 1874 | std::string s = "from qtpy import QtGui"; |
| 1875 | bool ok = NATRON_PYTHON_NAMESPACE::interpretPythonScript(s, &err, 0); |
| 1876 | if (!ok) { |
| 1877 | QString message = tr("Failed to import qtpy.QtGui"); |
| 1878 | std::cerr << message.toStdString() << std::endl; |
| 1879 | appPTR->writeToErrorLog_mt_safe(QLatin1String("qtpy.QtGui"), QDateTime::currentDateTime(), message); |
| 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | |
| 1884 | QStringList foundInit; |
| 1885 | QStringList foundInitGui; |
| 1886 | Q_FOREACH(const QString &templatesSearchDir, templatesSearchPath) { |
| 1887 | QDir d(templatesSearchDir); |
| 1888 | |
| 1889 | findAllScriptsRecursive(d, allPlugins, &foundInit, &foundInitGui); |
| 1890 | } |
| 1891 | if ( foundInit.isEmpty() ) { |
| 1892 | QString message = tr("Info: init.py script not loaded (this is not an error)"); |
| 1893 | appPTR->setLoadingStatus(message); |
nothing calls this directly
no test coverage detected