@@ -210,14 +210,20 @@ bool QgsPythonUtilsImpl::checkQgisUser()
210
210
return true ;
211
211
}
212
212
213
- void QgsPythonUtilsImpl::doGlobalImports ()
213
+ void QgsPythonUtilsImpl::doCustomImports ()
214
214
{
215
- QString startupPath = QStandardPaths::locate ( QStandardPaths::AppDataLocation, " global_startup.py" );
216
- // runString( "if os.path.exists(" + startuppath + "): from global_startup import *\n" );
217
- if ( !startupPath.isEmpty () )
215
+ QStringList startupPaths = QStandardPaths::locateAll ( QStandardPaths::AppDataLocation, " startup.py" );
216
+ if ( startupPaths.isEmpty () )
218
217
{
219
- runString ( " import importlib.util" );
220
- runString ( QString ( " spec = importlib.util.spec_from_file_location('global_startup','%1')" ).arg ( startupPath ) );
218
+ return ;
219
+ }
220
+
221
+ runString ( " import importlib.util" );
222
+
223
+ QStringList::const_iterator iter = startupPaths.constBegin ();
224
+ for ( ; iter != startupPaths.constEnd (); ++iter )
225
+ {
226
+ runString ( QString ( " spec = importlib.util.spec_from_file_location('startup','%1')" ).arg ( *iter ) );
221
227
runString ( " module = importlib.util.module_from_spec(spec)" );
222
228
runString ( " spec.loader.exec_module(module)" );
223
229
}
@@ -238,7 +244,7 @@ void QgsPythonUtilsImpl::initPython( QgisInterface* interface )
238
244
exitPython ();
239
245
return ;
240
246
}
241
- doGlobalImports ();
247
+ doCustomImports ();
242
248
finish ();
243
249
}
244
250
@@ -264,7 +270,7 @@ void QgsPythonUtilsImpl::initServerPython( QgsServerInterface* interface )
264
270
// This is the other main difference with initInterface() for desktop plugins
265
271
runString ( " qgis.utils.initServerInterface(" + QString::number (( unsigned long ) interface ) + ' )' );
266
272
267
- doGlobalImports ();
273
+ doCustomImports ();
268
274
finish ();
269
275
}
270
276
0 commit comments