Skip to content

Commit cbcd28a

Browse files
committed
Merge pull request #1031 from rldhont/headless_processing
Some changes to allow Processing to be run headless It replaces legendInterface with QgsMapLayerRegistry, which is a better option
2 parents 0ad5cc9 + a09892f commit cbcd28a

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

python/plugins/processing/core/Processing.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from processing.core.ProcessingConfig import ProcessingConfig
3535
from processing.core.GeoAlgorithm import GeoAlgorithm
3636
from processing.core.ProcessingLog import ProcessingLog
37+
from processing.core.SilentProgress import SilentProgress
3738
from processing.gui.AlgorithmClassification import AlgorithmDecorator
3839
from processing.gui.MessageBarProgress import MessageBarProgress
3940
from processing.gui.RenderingStyles import RenderingStyles
@@ -347,7 +348,9 @@ def runAlgorithm(algOrName, onFinish, *args):
347348
elif cursor.shape() != Qt.WaitCursor:
348349
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
349350

350-
progress = MessageBarProgress()
351+
progress = SilentProgress()
352+
if not interface.iface == None :
353+
progress = MessageBarProgress()
351354
ret = UnthreadedAlgorithmExecutor.runalg(alg, progress)
352355
if onFinish is not None and ret:
353356
onFinish(alg, progress)

python/plugins/processing/core/SilentProgress.py

+3
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ def setDebugInfo(self, _):
4848

4949
def setConsoleInfo(self, _):
5050
pass
51+
52+
def close(self):
53+
pass

python/plugins/processing/tools/dataobjects.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def getSupportedOutputTableExtensions():
6565

6666

6767
def getRasterLayers():
68-
layers = interface.iface.legendInterface().layers()
68+
layers = QgsMapLayerRegistry.instance().mapLayers().values()
6969
raster = list()
7070

7171
for layer in layers:
@@ -76,7 +76,7 @@ def getRasterLayers():
7676

7777

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

9797

9898
def getTables():
99-
layers = interface.iface.legendInterface().layers()
99+
layers = QgsMapLayerRegistry.instance().mapLayers().values()
100100
tables = list()
101101
for layer in layers:
102102
if layer.type() == layer.VectorLayer:

0 commit comments

Comments
 (0)