mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-17 00:09:36 -04:00
Add QgsPythonUtilsImpl::initGDAL() and run it from QGIS app
fixes #57344
This commit is contained in:
parent
07067d37b5
commit
79dab4461e
@ -12523,6 +12523,7 @@ void QgisApp::loadPythonSupport()
|
|||||||
// init python runner
|
// init python runner
|
||||||
QgsPythonRunner::setInstance( new QgsPythonRunnerImpl( mPythonUtils ) );
|
QgsPythonRunner::setInstance( new QgsPythonRunnerImpl( mPythonUtils ) );
|
||||||
|
|
||||||
|
mPythonUtils->initGDAL();
|
||||||
// QgsMessageLog::logMessage( tr( "Python support ENABLED :-) " ), QString(), Qgis::MessageLevel::Info );
|
// QgsMessageLog::logMessage( tr( "Python support ENABLED :-) " ), QString(), Qgis::MessageLevel::Info );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -218,6 +218,11 @@ class PYTHON_EXPORT QgsPythonUtils
|
|||||||
*/
|
*/
|
||||||
virtual bool unloadPlugin( const QString &packageName ) = 0;
|
virtual bool unloadPlugin( const QString &packageName ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize GDAL Python, turning on its exceptions.
|
||||||
|
* \since QGIS 3.38
|
||||||
|
*/
|
||||||
|
virtual void initGDAL() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -755,3 +755,12 @@ QStringList QgsPythonUtilsImpl::listActivePlugins()
|
|||||||
evalString( QStringLiteral( "'\\n'.join(qgis.utils.active_plugins)" ), output );
|
evalString( QStringLiteral( "'\\n'.join(qgis.utils.active_plugins)" ), output );
|
||||||
return output.split( QChar( '\n' ), Qt::SkipEmptyParts );
|
return output.split( QChar( '\n' ), Qt::SkipEmptyParts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsPythonUtilsImpl::initGDAL()
|
||||||
|
{
|
||||||
|
runString("from osgeo import gdal, ogr, osr");
|
||||||
|
// To avoid FutureWarning with GDAL >= 3.7.0
|
||||||
|
runString("gdal.UseExceptions()");
|
||||||
|
runString("ogr.UseExceptions()");
|
||||||
|
runString("osr.UseExceptions()");
|
||||||
|
}
|
||||||
|
@ -92,6 +92,7 @@ class QgsPythonUtilsImpl : public QgsPythonUtils
|
|||||||
bool canUninstallPlugin( const QString &packageName ) final;
|
bool canUninstallPlugin( const QString &packageName ) final;
|
||||||
bool unloadPlugin( const QString &packageName ) final;
|
bool unloadPlugin( const QString &packageName ) final;
|
||||||
bool isPluginEnabled( const QString &packageName ) const final;
|
bool isPluginEnabled( const QString &packageName ) const final;
|
||||||
|
void initGDAL() final;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user