Hi Nyall:

On Tue, Apr 10, 2018 at 2:20 AM, Nyall Dawson <nyall.daw...@gmail.com>

> On 10 April 2018 at 01:03, Stephen Bosch <post...@vodacomm.ca> wrote:
> > 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=('', 41358), raddr=('', 37307)>
> That can be ignored - it's unrelated.

(Messages like this occur only when the process exits with a code other
than 0.)

I should add that, without using the debugger, I wouldn't be able to see
the error at all. Is that intended behaviour? Is there any way to turn it
on? The absence of exceptions and tracebacks make things fail silently,
which can have nasty consequences.

> >
> > 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?

It is thrown in line 42 of MessageBarProgress.py:
__init__ [MessageBarProgress.py:42]  id:94435226437000

In the meantime try passing a feedback object:
>    feedback = QgsProcessingFeedback()

That seemed to correct the messageBar error, thanks.

After correcting the statement to the following:

file_grid_r = QgsRasterLayer()
> processing.run("grass7:v.to.rast", {'input': grid_v, 'type': 0, 'use': 1,
>                                     'GRASS_REGION_PARAMETER': extent,
>                                     'output': file_grid_r,
>                                     'GRASS_REGION_CELLSIZE_PARAMETER':
> 0.008333,
>                                     'GRASS_SNAP_TOLERANCE_PARAMETER': -1,
>                                     'GRASS_MIN_AREA_PARAMETER': 0.000100},
>                              feedback=QgsProcessingFeedback())

 I get the message

Unable to execute algorithm
> Incorrect parameter value for output

I've tried a couple of variations (specifying 'output' as an index and
assigning it to a variable while setting 'output': None in the dictionary,
for example) and get the same error.

In my 2.x code, I just used the index and assigned the return to a
variable. The implementation of v.to.rast for QGIS 3 Processing seems to
require a value for output, and simply putting an variable doesn't work
either (it complains that the variable is undefined).

With a few more hints, I'm sure I'll get the hang of this ;-)


Qgis-user mailing list
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to