Skip to content

Commit

Permalink
[processing] minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Oct 7, 2013
1 parent 503ee57 commit 0150fe7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
13 changes: 6 additions & 7 deletions python/plugins/processing/algs/SaveSelectedFeatures.py
Expand Up @@ -115,29 +115,28 @@ def processAlgorithm(self, progress):
# first available format from the provider is used, and the
# corresponding file extension appended.

provider = vectorLayer.dataProvider()

# vectorLayer.crs() is the layer crs. By default all resulting
# layers are assumed to be in the same crs are the inputs, and
# will be loaded with this assumptions when executed from the
# toolbox. The self.crs variable has to be canged in case this
# toolbox. The self.crs variable has to be changed in case this
# is not true, or in case there are no input layer from which
# the output crs can be infered


provider = vectorLayer.dataProvider()

writer = output.getVectorWriter(provider.fields(),
provider.geometryType(), vectorLayer.crs())

# Now we take the selected features and add them to the output
# layer
features = vector.features(vectorLayer)
total = len(features)
i = 0
total = len(features)
for (i, feat) in enumerate(features):
writer.addFeature(feat)

# We use the progress object to communicate with the user
progress.setPercentage(100 * i / float(total))
i += 1
progress.setPercentage(100 * i / float(total))
del writer

# There is nothing more to do here. We do not have to open the
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/processing/core/SilentProgress.py
Expand Up @@ -28,6 +28,9 @@

class SilentProgress:

def error(self, msg):
print msg

def setText(self, text):
pass

Expand Down
7 changes: 7 additions & 0 deletions python/plugins/processing/gui/MessageBarProgress.py
Expand Up @@ -28,6 +28,7 @@
from PyQt4.QtCore import *
from PyQt4 import QtGui
from processing import interface
from qgis.gui import *


class MessageBarProgress:
Expand All @@ -42,6 +43,12 @@ def __init__(self):
interface.iface.messageBar().pushWidget(self.progressMessageBar,
interface.iface.messageBar().INFO)

def error(self, msg):
interface.iface.messageBar().clearWidgets()
interface.iface.messageBar().pushMessage("Error", msg,
level = QgsMessageBar.CRITICAL,
duration = 3)

def setText(self, text):
pass

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/ProcessingToolbox.py
Expand Up @@ -99,7 +99,7 @@ def showPopupMenu(self, point):
executeAction = QAction(self.tr('Execute'), self.algorithmTree)
executeAction.triggered.connect(self.executeAlgorithm)
popupmenu.addAction(executeAction)
if alg.canRunInBatchMode and not self.allowOnlyOpenedLayers:
if alg.canRunInBatchMode and not alg.allowOnlyOpenedLayers:
executeBatchAction = QAction(
self.tr('Execute as batch process'),
self.algorithmTree)
Expand Down
Expand Up @@ -60,7 +60,7 @@ def runalg(alg, progress):
msg = 'Uncaught error executing ' + str(alg.name) \
+ '\nSee log for more information'
ProcessingLog.addToLog(sys.exc_info()[0], ProcessingLog.LOG_ERROR)
progress.error(e.msg)
progress.error(msg)
return False

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/modeler/ModelerAlgorithm.py
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -119,8 +120,7 @@ def openModel(self, filename):
self.algParameters = []
self.algOutputs = []
self.paramValues = {}
self.dependencies = []

self.dependencies = []
self.descriptionFile = filename
lines = codecs.open(filename, 'r', encoding='utf-8')
line = lines.readline().strip('\n').strip('\r')
Expand Down

0 comments on commit 0150fe7

Please sign in to comment.