77 Commits

Author SHA1 Message Date
Juergen E. Fischer
c77172ed3d fix more flake8 warnings 2017-03-05 10:21:24 +01:00
Juergen E. Fischer
f00a87cb8a update translation strings 2017-03-05 10:21:24 +01:00
Juergen E. Fischer
96c31a1f0e remove python version checks 2017-03-03 17:41:58 +01:00
Nyall Dawson
6d4392a0f7 Allow QgsTask subclasses to defined a finished function, which is
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)
2016-12-05 14:08:11 +10:00
Nyall Dawson
eb34079c01 Don't crash when python exceptions occur in non-main thread 2016-12-05 14:08:11 +10:00
Mathieu Pellerin
eefeef573d fix a couple of python warnings (#3526) 2016-09-23 07:36:05 +02:00
Mathieu Pellerin
e7c9400b06 [plugin manager] fix broken QDirIterator next() call, make it pyqt5 5.7 compatible (#3517) 2016-09-22 09:25:32 +02:00
Hugo Mercier
5c3a43e286 Fix spatialite access with python3 2016-09-05 13:43:00 +02:00
Matthias Kuhn
bb79d13e82 Remove deprecated Qgis::WKBType and API cleanup (#3325)
* 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
2016-08-04 09:10:08 +02:00
Nyall Dawson
1a2231f10c Rename QGis class to Qgis, for capitalisation consistency 2016-07-21 22:01:38 +10:00
Matthias Kuhn
d0feea57c1 [py3] Followup bad0d3e: Don't decode unencoded strings 2016-06-07 10:21:53 +02:00
Matthias Kuhn
bad0d3e4b6 Properly handle filsystem character encoding when showing warnings
Fix #14567
2016-06-06 20:55:22 +02:00
Denis Rouzaud
8071acd064 move PyQt compat folder to python/qgis 2016-04-29 14:10:26 +02:00
elpaso
2d3b813d22 Fixes an error when unloading 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
2016-03-25 12:17:58 +01:00
Matthias Kuhn
02c5637155 py2/py3 compat patches 2016-03-22 09:17:16 +01:00
Juergen E. Fischer
271750fd53 switch bindings to pyqt wrappers 2016-03-21 17:00:26 +01:00
Juergen E. Fischer
fb3fcfa3a0 Python3/Qt5/2to3 updates:
* 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
2016-03-14 20:38:20 +01:00
Juergen E. Fischer
ae52aabd70 more spelling fixes 2016-01-24 20:16:28 +01:00
elpaso
66061e0ef2 Uninstall custom excepthook for server 2015-12-16 15:13:11 +01:00
Juergen E. Fischer
b65b59596a make python error handling translatable 2015-10-23 08:29:46 +02:00
Nathan Woodrow
18df00375e Use front window to show python error if there is message bar 2015-10-23 09:36:07 +10:00
Juergen E. Fischer
e694474f62 indentation update 2015-10-03 21:42:13 +02:00
Nathan Woodrow
28196684af Show Python error stack trace when in blocking dialog 2015-10-01 22:57:27 +10:00
Nathan Woodrow
1e6c8908b2 Add stack trace button to message bar for Python errors 2015-10-01 11:54:13 +10:00
Nathan Woodrow
216821ff38 Don't spam message bar with more of the same error 2015-09-28 17:33:13 +10:00
Nathan Woodrow
6cf2dd0a4c Fix annoying blocking Python error dialog 2015-09-28 17:14:06 +10:00
Juergen E. Fischer
b39055b39c indentation update (now including autopep8) 2015-08-22 14:29:41 +02:00
Matthias Kuhn
a37b3e27d5 Remove executable flag on a bunch of files 2015-07-20 15:45:44 +02:00
Juergen E. Fischer
956c155e8f fix python pep8 warnings and fix some revealed errors
pep8 --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701 \
     --exclude="ui_*.py,debian/*,python/ext-libs/*" \
     .
2015-02-01 20:46:47 +01:00
Nathan Woodrow
7942325fd7 Remove qgsfunction from qgis.utils.
Import from qgis.core so we don't break API
2014-11-29 23:36:18 +10:00
Nathan Woodrow
e14b7e4868 Reform qgis.uitls file 2014-11-29 23:18:18 +10:00
elpaso
f2608b308f Added serve python plugins 2014-11-26 16:02:32 +01:00
Denis Rouzaud
9ebb69e70b followup 0181df555378eabbf58a29b76e687c54178ca5f1 2014-09-17 16:31:41 +02:00
Nathan Woodrow
0181df5553 Add timing for plugin loading 2014-09-18 09:38:52 +10:00
*_*
1357c14f57 Fix for http://hub.qgis.org/issues/9020 2014-06-09 04:34:18 +09:00
Juergen E. Fischer
6685932c09 show python errors in monospace 2014-03-21 09:20:48 +01:00
Juergen E. Fischer
91ecc5f31b add 'warning' to the respective python message log tab 2014-02-24 02:03:42 +01:00
Tim Sutton
ba4e438c05 Fix from Salvatore to fix project macros 2013-09-11 17:41:23 +02:00
Nathan Woodrow
b287661c91 Don't return null on failed metadata load 2013-06-12 14:26:00 +10:00
Juergen E. Fischer
8609a41deb allow utf8 in metadata.txt 2013-06-09 10:56:35 +02:00
Nathan Woodrow
e6f98362dc Merge master 2013-06-08 15:59:04 +10:00
Borys Jurgiel
eda9cd3380 [Plugin Manager] Better cope with broken plugins 2013-06-06 23:41:52 +02:00
Nathan Woodrow
17d424340e Start sipapi update 2013-05-29 22:08:16 +10:00
Tim Sutton
6c3f418988 Use ~.qgis2 and ~/.config/QuantumGIS/QGIS2.conf for settings for QGIS 2. Added unit test for memory provider. 2013-04-01 13:15:09 +02:00
Martin Dobias
32de07dc4d Remove the support for reading python plugin metadata from __init__.py
From now on, plugins must have metadata.txt file (with INI format)
that is used for storing of metadata. This has two advantages:
- plugins do not need to be loaded in order to read metadata
- repository can parse the metadata more easily
2013-03-19 00:10:51 +01:00
Martin Dobias
41dc7544d0 Do not load metadata from __init__.py 2013-03-19 00:10:51 +01:00
Juergen E. Fischer
0a0a430b0e include stack trace in logged python warning messages 2013-01-31 16:37:23 +01:00
Juergen E. Fischer
994dc1cc21 - [API] introduce QgsMessageLog::MessageLevel and change logMessage() level
parameter to that type
- change default level to WARNING
- change startup messages to INFO
- don't unhide the warning button for INFO messages
- fix warnings produced by python code
2013-01-26 14:16:39 +01:00
Juergen E. Fischer
f2029b4ec4 log python warnings and enabled deprecation warnings 2013-01-24 03:08:20 +01:00
Juergen E. Fischer
9721736fd8 remove trailing blanks 2012-12-10 00:12:07 +01:00