110 Commits

Author SHA1 Message Date
Alex
eda36d4796 Allow using spatialite function on geopackge in dbmanager
Enables Spatialite's amphibious mode for Geopackages, allowing the use of geospatial functions on geopackages in the DB manager.
2019-11-14 10:41:36 -05:00
Bas Couwenberg
2628c480c5 Don't include revision in sources.
Prevent changes to files that weren't changed between releases.
This eases review of the changes between releases significantly.
2019-05-17 16:47:47 +02:00
Alessandro Pasotti
46a4435e65 Use a function to access plugins_metadata_parser global object 2019-05-10 10:21:05 +02:00
Mathieu Pellerin
eacc506a5a Add a REGEXP function in spatialite_connect() python function
This enables DB Manager and the Spatialite Execute SQL algorithm
to use the 'string REGEXP pattern' syntax.
2019-05-06 22:07:00 +07:00
Nyall Dawson
c0105bdfcf Fix exception when reloading plugins 2019-04-26 16:56:30 +10:00
David Marteau
6af744da82 Remove plugin module path when unloading
Unloading plugin must remove added module path
    in order to prevent wrong package import when reloading
2019-04-24 16:09:09 +02:00
Juergen E. Fischer
3d7c711db0 fix #21872 (refs #21774; partly reverts e57d1e06f0 and 507e327c0c)
src/python/qgspythonutilsimpl.cpp:596 produces "lost sys.stdout" when
qgis.utils.updateAvailablePlugins() returns.
2019-04-17 22:30:01 +02:00
Alessandro Pasotti
e57d1e06f0 Fix plugin loading from zip (dependencies followup) 2019-04-09 15:21:09 +02:00
Juergen E. Fischer
eabf56bfb3 fix #21774 2019-04-05 01:15:16 +02:00
Alessandro Pasotti
b85d5af0c0 Add test for plugin dependencies
Also made minor changes to the function and
class names, to be more consistent with QGIS
naming conventions.
2019-03-18 09:20:06 +01:00
Nyall Dawson
2f82bab1d9 Add Python utils method to start a Processing specific plugin
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.
2019-03-02 12:06:59 +10:00
Nathan Woodrow
87d2da13fb
[FEATURE][needs-docs] Add new @alg decorator for nicer python processing scripts. (#8586)
@alg()
@alg.help()
@alg.input()
@alg.output()
2018-12-10 16:35:52 +10:00
Ted Meyer
a1d6f29e87 Use time.process_time() instead of time.clock()
time.clock is set to be deprecated in python3.8,
and was replaced by time.process_time in python3.3
2018-10-25 20:48:48 +10:00
Chris Mayo
70a37bf981 Tidy installer_data.py and utils.py
- Fix unused and missing imports
- Only import configparser is needed for Python 3
- Unnecessary string u prefix for Python 3
- Comment typo
2018-09-06 05:56:09 +10:00
Nyall Dawson
36cfaac8af Even more descriptive error 2018-06-29 10:46:09 +10:00
Marco Bernasocchi
96764beff2 more informative error message 2018-06-29 10:46:09 +10:00
Nyall Dawson
dbac3b4922 [python] Block imports of PyQt4 modules
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.
2018-06-29 10:46:09 +10:00
Nyall Dawson
4e38d0696e Documentation 2018-06-06 06:27:33 +10:00
Nyall Dawson
40a2062ec1 [python] Don't install error hook by default
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
2018-06-06 06:27:33 +10:00
Matthias Kuhn
cb008699df
Merge pull request #6101 from letmaik/patch-1
Fix tracking of imported modules (and plugin reloading)
2018-05-07 11:25:17 +02:00
Denis Rouzaud
3dc3d9d1b2 unite QgsMessageLog::Level and QgsMessageBar::MessageLevel in Qgis::MessageLevel
make enum items lower case
remove unused QgsMessageLog::None and All
2018-02-06 08:56:40 -04:00
Maik Riechert
19592dc8d7
Fix tracking of imported modules
__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.
2018-01-18 23:26:36 +00:00
Juergen E. Fischer
24e6366815 mod_spatialite added to osgeo4w 2017-11-05 21:03:08 +01:00
Juergen E. Fischer
e523780945 add loading of spatialite on windows and remove remaining references to
pyspatialite (followup 39816cf84)
2017-10-29 20:32:43 +01:00
gacarrillor
6402160526 Use sqlite3 instead of pyspatialite for SpatiaLite connections 2017-10-29 10:46:54 -05:00
David Marteau
40b916c7a3 Disable message hook and import override at runtime 2017-10-17 09:40:22 +02:00
Nyall Dawson
acbba3a387 Fix excepthook handling in standalone scripts 2017-09-24 07:47:45 +10:00
Nathan Woodrow
df7c3df473 Revert "Ignore some python warnings for now"
Doesn't work on all platforms

This reverts commit f0e53db254f38071e87b993b580ea050b19f4b17.
2017-09-04 14:22:24 +10:00
Nathan Woodrow
f0e53db254 Ignore some python warnings for now
shhhh Qt5
2017-09-04 12:30:26 +10:00
Mario Baranzini
78af413dcc Remove python future compatibility layer 2017-08-07 10:27:15 +02:00
Matthias Kuhn
3dc6daaffa
Fix typo 2017-07-31 09:35:28 +02:00
Matthias Kuhn
973d3515d1
Avoid endless wait cursors 2017-07-30 21:51:22 +02:00
Harrissou Sant-anna
6fab688298 Use SpatiaLite right spelling when needed 2017-07-07 01:26:38 +02:00
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