Skip to content

Commit

Permalink
Merge pull request #1031 from rldhont/headless_processing
Browse files Browse the repository at this point in the history
Some changes to allow Processing to be run headless

It replaces legendInterface with QgsMapLayerRegistry, which is a better option
  • Loading branch information
volaya committed Dec 20, 2013
2 parents 0ad5cc9 + a09892f commit cbcd28a
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 cbcd28a

Please sign in to comment.