Skip to content

Commit

Permalink
[Feature][Processing] Headless
Browse files Browse the repository at this point in the history
To use QGIS Processing in python scripts out of QGIS.
The changes made concern the dependence to legendInterface. In cases
where the interface.iface is null (None) QGIS Processing uses the
QgsMapLayerRegistry instance.
  • Loading branch information
rldhont committed Dec 19, 2013
1 parent 0ad5cc9 commit a09892f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion python/plugins/processing/core/Processing.py
Expand Up @@ -34,6 +34,7 @@
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.ProcessingLog import ProcessingLog
from processing.core.SilentProgress import SilentProgress
from processing.gui.AlgorithmClassification import AlgorithmDecorator
from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.RenderingStyles import RenderingStyles
Expand Down Expand Up @@ -347,7 +348,9 @@ def runAlgorithm(algOrName, onFinish, *args):
elif cursor.shape() != Qt.WaitCursor:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

progress = MessageBarProgress()
progress = SilentProgress()
if not interface.iface == None :
progress = MessageBarProgress()
ret = UnthreadedAlgorithmExecutor.runalg(alg, progress)
if onFinish is not None and ret:
onFinish(alg, progress)
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/processing/core/SilentProgress.py
Expand Up @@ -48,3 +48,6 @@ def setDebugInfo(self, _):

def setConsoleInfo(self, _):
pass

def close(self):
pass
6 changes: 3 additions & 3 deletions python/plugins/processing/tools/dataobjects.py
Expand Up @@ -65,7 +65,7 @@ def getSupportedOutputTableExtensions():


def getRasterLayers():
layers = interface.iface.legendInterface().layers()
layers = QgsMapLayerRegistry.instance().mapLayers().values()
raster = list()

for layer in layers:
Expand All @@ -76,7 +76,7 @@ def getRasterLayers():


def getVectorLayers(shapetype=[-1]):
layers = interface.iface.legendInterface().layers()
layers = QgsMapLayerRegistry.instance().mapLayers().values()
vector = []
for layer in layers:
if layer.type() == layer.VectorLayer:
Expand All @@ -96,7 +96,7 @@ def getAllLayers():


def getTables():
layers = interface.iface.legendInterface().layers()
layers = QgsMapLayerRegistry.instance().mapLayers().values()
tables = list()
for layer in layers:
if layer.type() == layer.VectorLayer:
Expand Down

0 comments on commit a09892f

Please sign in to comment.