This command adds a plugin to active plugins and calls initProcessing(),
initializing only Processing related components of that plugin.
The new initProcessing() hook should be implemented by plugins
which provide Processing providers or algorithm, and should only
implement code which is required to load the provider and algorithms.
Strictly no GUI related code should be used here, that MUST
be moved out of initializers and deferred to the plugin's
initGui implementation.
Prevents crashes when PyQt4 modules are imported in QGIS 3.x.
This instantly segfaults QGIS. Throwing an exception makes it
easier to identify the cause as a faulty plugin, and shows
exactly where the bad import is located.
This error hook should only ever be used from QGIS app, never
from standalone scripts and applications, so we should default
to not using it and only install it when initializing python
from app.
Otherwise default behavior for standalone scripts based on
PyQGIS is to silently swallow exceptions - this leaves script
developers *no clues* to go off to debug their applications,
meaning that errors which would usually take a couple of seconds
to fix become horrible exercises in frustration for those
unaware of QGIS' exception handling and the
QGIS_DISABLE_MESSAGE_HOOKS environment variable.
Refs #19111
__import__(name, ..., fromlist, ...) always returns the top-level package if `import x.y.z` is used (here `x`), and the module given by `name` if `from x.y.z import a` is used, here `x.y.z`. Differentiating between these two cases can be done by looking at the `fromlist` argument. By not tracking modules correctly, plugin unloading/reloading was broken if a module hierarchy within a plugin was used and `from` was not exclusively used.
called when the task has completed (successfully or otherwise).
This allows for simpler task design when the signal/slot
based approach is not required. Just implement run() with your
heavy lifting, and finished() to do whatever follow up stuff
should happen after the task is complete. finished is always
called from the main thread, so it's safe to do GUI operations
here.
Python based tasks using the simplified QgsTask.fromFunction
approach can now set a on_finished argument to a function
to call when the task is complete.
eg:
def calculate(task):
# pretend this is some complex maths and stuff we want
# to run in the background
return 5*6
def calculation_finished(result, value=None):
if result == QgsTask.ResultSuccess:
iface.messageBar().pushMessage(
'the magic number is {}'.format(value))
elif result == QgsTask.ResultFail:
iface.messageBar().pushMessage(
'couldn\'t work it out, sorry')
task = QgsTask.fromFunction('my task', calculate,
on_finished=calculation_finished)
QgsTaskManager.instance().addTask(task)
Multiple values can also be returned, eg:
def calculate(task):
return (4, 8, 15)
def calculation_finished(result, count=None, max=None, sum=None):
# here:
# count = 4
# max = 8
# sum = 15
task = QgsTask.fromFunction('my task', calculate,
on_finished=calculation_finished)
QgsTaskManager.instance().addTask(task)
* Remove deprecated Qgis::WKBType and API cleanup
Renames QgsWKBTypes to QgsWkbTypes
Replaces usage of the enums:
* Qgis::WKBType with QgsWkbTypes::Type
* Qgis::GeometryType with QgsWkbTypes::GeometryType
Their values should be forward compatible (a fact that was already
explited up to now by casting between the types)
Renames some SSLxxx to SslXxx and URIxxx to UriXxx
* Fix build warnings and simplify type handling
* Add a fixer to rewrite imports
* The forgotten rebase conflictThe forgotten rebase conflicts
* QgsDataSourcURI > QgsDataSourceUri
* QgsWKBTypes > QgsWkbTypes
* Qgis.WKBGeom > QgsWkbTypes.Geom
* Further python fixes
* Guess what... Qgis::wkbDimensions != QgsWkbTypes::wkbDimensions
* Fix tests
* Python 3 updates
* [travis] pull request caching cannot be disabled
so at least use it in r/w mode
* Fix python3 print in plugins
Custom utils._import was never called, because
builtins was correctly imported (even if it missed __import__)
and _import was then monkey patched to builtins instead of __builtin__
Tested on python 2
* pyqtwrappers update (add QtNetwork, QtXml, QtSql, QtTest, uic)
* 2to3 updates
* move QPyNullVariant/NULL to PyQt.QtCore
* add global unicode/basestring/long for Python3
* expand QtGui, QtCore module and star exports
* Qscintilla2
* replace Set import with set builtin