mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-09 00:04:30 -05:00
When processing is initialized in external scripts, ensure the GRASS,
SAGA and OTB providers are included by default Fixes #45935
This commit is contained in:
parent
93c0510f3e
commit
dd368a4289
@ -85,7 +85,7 @@ to change due to centralization.
|
|||||||
static const char *QGIS_ORGANIZATION_DOMAIN;
|
static const char *QGIS_ORGANIZATION_DOMAIN;
|
||||||
static const char *QGIS_APPLICATION_NAME;
|
static const char *QGIS_APPLICATION_NAME;
|
||||||
|
|
||||||
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString profileFolder = QString(), QString platformName = "desktop" ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &profileFolder = QString(), const QString &platformName = "desktop" )];
|
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString profileFolder = QString(), QString platformName = "external" ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &profileFolder = QString(), const QString &platformName = "desktop" )];
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for QgsApplication.
|
Constructor for QgsApplication.
|
||||||
|
|
||||||
|
|||||||
@ -114,6 +114,33 @@ class Processing(object):
|
|||||||
p = c()
|
p = c()
|
||||||
if QgsApplication.processingRegistry().addProvider(p):
|
if QgsApplication.processingRegistry().addProvider(p):
|
||||||
Processing.BASIC_PROVIDERS.append(p)
|
Processing.BASIC_PROVIDERS.append(p)
|
||||||
|
|
||||||
|
if QgsApplication.platform() == 'external':
|
||||||
|
# for external applications we must also load the builtin providers stored in separate plugins
|
||||||
|
try:
|
||||||
|
from grassprovider.Grass7AlgorithmProvider import Grass7AlgorithmProvider
|
||||||
|
p = Grass7AlgorithmProvider()
|
||||||
|
if QgsApplication.processingRegistry().addProvider(p):
|
||||||
|
Processing.BASIC_PROVIDERS.append(p)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
from otbprovider.OtbAlgorithmProvider import OtbAlgorithmProvider
|
||||||
|
p = OtbAlgorithmProvider()
|
||||||
|
if QgsApplication.processingRegistry().addProvider(p):
|
||||||
|
Processing.BASIC_PROVIDERS.append(p)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
from sagaprovider.SagaAlgorithmProvider import SagaAlgorithmProvider
|
||||||
|
p = SagaAlgorithmProvider()
|
||||||
|
if QgsApplication.processingRegistry().addProvider(p):
|
||||||
|
Processing.BASIC_PROVIDERS.append(p)
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
# And initialize
|
# And initialize
|
||||||
ProcessingConfig.initialize()
|
ProcessingConfig.initialize()
|
||||||
ProcessingConfig.readSettings()
|
ProcessingConfig.readSettings()
|
||||||
|
|||||||
@ -107,6 +107,21 @@ class TestProcessingGeneral(unittest.TestCase):
|
|||||||
# Python should NOT have ownership
|
# Python should NOT have ownership
|
||||||
self.assertFalse(sip.ispyowned(layer))
|
self.assertFalse(sip.ispyowned(layer))
|
||||||
|
|
||||||
|
def testProviders(self):
|
||||||
|
"""
|
||||||
|
When run from a standalone script (like this test), ensure that the providers from separate plugins are available
|
||||||
|
"""
|
||||||
|
providers = [p.id() for p in QgsApplication.processingRegistry().providers()]
|
||||||
|
self.assertIn('qgis', providers)
|
||||||
|
self.assertIn('native', providers)
|
||||||
|
self.assertIn('gdal', providers)
|
||||||
|
self.assertIn('project', providers)
|
||||||
|
self.assertIn('script', providers)
|
||||||
|
self.assertIn('model', providers)
|
||||||
|
self.assertIn('grass7', providers)
|
||||||
|
self.assertIn('saga', providers)
|
||||||
|
self.assertIn('otb', providers)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
nose2.main()
|
nose2.main()
|
||||||
|
|||||||
@ -181,7 +181,7 @@ class CORE_EXPORT QgsApplication : public QApplication
|
|||||||
* \param profileFolder optional string representing the profile to load at startup
|
* \param profileFolder optional string representing the profile to load at startup
|
||||||
* \param platformName the QGIS platform name, e.g., "desktop", "server", "qgis_process" or "external" (for external CLI scripts)
|
* \param platformName the QGIS platform name, e.g., "desktop", "server", "qgis_process" or "external" (for external CLI scripts)
|
||||||
*/
|
*/
|
||||||
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString profileFolder = QString(), QString platformName = "desktop" ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &profileFolder = QString(), const QString &platformName = "desktop" )];
|
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString profileFolder = QString(), QString platformName = "external" ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &profileFolder = QString(), const QString &platformName = "desktop" )];
|
||||||
% MethodCode
|
% MethodCode
|
||||||
// The Python interface is a list of argument strings that is modified.
|
// The Python interface is a list of argument strings that is modified.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user