22 #include "qgspythonutils.h"
33 static QStringList *pluginList =
new QStringList();
41 QString pythonlibName( QStringLiteral(
"qgispython" ) );
42 #if defined(Q_OS_UNIX)
46 pythonlibName.prepend(
"lib" );
49 QgsMessageLog::logMessage( QStringLiteral(
"load library %1 (%2)" ).arg( pythonlibName, version ), __FILE__, Qgis::MessageLevel::Info );
50 QLibrary pythonlib( pythonlibName, version );
53 pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint );
54 if ( !pythonlib.load() )
56 pythonlib.setFileName( pythonlibName );
57 if ( !pythonlib.load() )
64 QgsMessageLog::logMessage( QStringLiteral(
"Python support library loaded successfully." ), __FILE__, Qgis::MessageLevel::Info );
65 typedef QgsPythonUtils*( *inst )();
66 inst pythonlib_inst = ( inst )
cast_to_fptr( pythonlib.resolve(
"instance" ) );
67 if ( !pythonlib_inst )
70 QgsDebugMsg( QStringLiteral(
"Couldn't resolve python support library's instance() symbol." ) );
74 QgsDebugMsg( QStringLiteral(
"Python support library's instance() symbol resolved." ) );
80 QgsDebugMsg( QStringLiteral(
"Python support ENABLED :-)" ) );
84 QgsDebugMsg( QStringLiteral(
"Python support FAILED :-(" ) );
90 bool atLeastOneEnabled =
false;
92 const auto constPluginList(
sPythonUtils->pluginList() );
93 for (
const QString &pluginName : constPluginList )
95 QString pluginService =
sPythonUtils->getPluginMetadata( pluginName, QStringLiteral(
"server" ) );
96 if ( pluginService == QLatin1String(
"True" ) )
102 atLeastOneEnabled =
true;
104 QgsMessageLog::logMessage( QStringLiteral(
"Server plugin %1 loaded!" ).arg( pluginName ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Info );
108 QgsMessageLog::logMessage( QStringLiteral(
"Error loading server plugin %1" ).arg( pluginName ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Critical );
113 QgsMessageLog::logMessage( QStringLiteral(
"Error starting server plugin %1" ).arg( pluginName ), QStringLiteral(
"Server" ), Qgis::MessageLevel::Critical );
static int versionInt()
Version number used for comparing versions using the "Check QGIS Version" function.
static QString libraryPath()
Returns the path containing qgis_core, qgis_gui, qgispython (and other) libraries.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
static QStringList & serverPlugins()
List of available server plugin names.
static QgsPythonUtils * sPythonUtils
Pointer to QgsPythonUtils.
static bool initPlugins(QgsServerInterface *interface)
Initializes the Python plugins.