[Qgis-user] How do I pass parameters to grass7 algorithms with Processing.run?

Nyall Dawson nyall.dawson at gmail.com
Mon Apr 9 17:20:58 PDT 2018


On 10 April 2018 at 01:03, Stephen Bosch <posting at vodacomm.ca> wrote:

> The input types are described with terms like
> "<QgsProcessingParameterVectorLayer>"; what does this mean exactly? Do I
> need to pass class instances?

Nope, strings/ints/layer refs/etc are fine. The class is shown in the
help to indicate what values are acceptable (e.g. you can't use a
layer reference for a point parameter!)

> I've tried calling the algorithm this way:
>
>> file_grid_r = processing.run("grass7:v.to.rast", {'INPUT': grid_v, 'type':
>> 0, 'use': 1, 'GRASS_REGION_PARAMETER': extent}, feedback=None)
>

Looks correct

> But it fails. On the console, I see
>
>> sys:1: ResourceWarning: unclosed <socket.socket fd=3,
>> family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0,
>> laddr=('127.0.0.1', 41358), raddr=('127.0.0.1', 37307)>

That can be ignored - it's unrelated.
>
> If I step through the code in PyCharm and trace the exception, I see an
> AttributeError: 'NoneType' object has no attribute 'messageBar'.

Where is this thrown? I suspect the problem is because you're passing
"feedback=None" and somewhere there's code which is expecting a valid
feedback object. Can you let me know which line the exception is
thrown on and I'll fix?

In the meantime try passing a feedback object:

   feedback = QgsProcessingFeedback()


Nyall

> I'm not sure if this is a bug in QGIS or whether there is something wrong
> with my parameters.
>
> Do you have any suggestions or ideas?
>
> Thanks
>
> Stephen
>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the Qgis-user mailing list