Bug report #8069

Ftools random points: a python error

Added by Filipe Dias over 11 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Processing/QGIS
Affected QGIS version:master Regression?:
Operating System: Easy fix?:
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:16908

Description

Steps to reproduce
Vector
Random points
Use value from input field (in this case "id" which is NULL)
Define output
Run

Python error:

An error has occured while executing Python code:

Traceback (most recent call last):
  File "/usr/share/qgis/python/plugins/fTools/tools/doRandPoints.py", line 124, in accept
    self.randomize(inLayer, outPath, minimum, design, value)
  File "/usr/share/qgis/python/plugins/fTools/tools/doRandPoints.py", line 225, in randomize
    add = ( 100.00 - 70.00 ) / len(points)
ZeroDivisionError: float division by zero

Python version:
2.7.3 (default, Aug  1 2012, 05:25:23) 
[GCC 4.6.3]

QGIS version:
1.9.0-Master Master, exported

Python path: ['/usr/share/qgis/python/plugins/sextante', '/usr/share/qgis/python', '/home/fd/.qgis2/python', '/home/fd/.qgis2/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '/usr/share/qgis/python/plugins/fTools/tools']

test.zip (1.05 KB) Filipe Dias, 2013-06-15 05:13 AM

Associated revisions

Revision 56210eb0
Added by Nathan Woodrow over 11 years ago

Merge pull request #711 from ddanielvaz/bugfixes

Bugfixes for fTools.

Fix #8218
Fix #8069
Fix #7073

History

#1 Updated by Filipe Dias over 11 years ago

  • Operating System set to Linux
  • OS version set to Ubuntu 12.04

#2 Updated by Filipe Dias over 11 years ago

Im using the latest version before the SIP update.

#3 Updated by Giovanni Manghi over 11 years ago

  • Status changed from Open to Feedback

Filipe Dias wrote:

Im using the latest version before the SIP update.

then you should re-test after updating, the code of the core python plugins have already been changed, so testing not the latest revision does not make sense anyway.

#4 Updated by Giovanni Manghi over 11 years ago

  • OS version deleted (Ubuntu 12.04)
  • Status changed from Feedback to Open
  • Target version set to Version 2.0.0
  • Operating System deleted (Linux)

If you choose a column with no values (and it should have something to work) then the error is the one you report.

Anyway on the latest revision it fails with

An error has occured while executing Python code:

Traceback (most recent call last):
  File "/usr/share/qgis/python/plugins/fTools/tools/doRandPoints.py", line 94, in accept
    if outPath.contains("\\\\"):
AttributeError: 'unicode' object has no attribute 'contains'

Python version:
2.7.3 (default, Aug  1 2012, 05:25:23) 
[GCC 4.6.3]

even when choosing a column that makes sense.

#5 Updated by Filipe Dias over 11 years ago

Of course it should not be empty. But a warning message should be displayed (e.g. The selected field has NULL values) instead of a Python error.

#6 Updated by Giovanni Manghi over 11 years ago

Hi Filipe,

Filipe Dias wrote:

Of course it should not be empty. But a warning message should be displayed (e.g. The selected field has NULL values) instead of a Python error.

yes of course, that situation would need to be trapped, but that is not would not be enough to make this a blocker. On the other hand the tools nows fail anyway so after all this is really a regression.

#7 Updated by Matthias Kuhn over 11 years ago

  • Priority changed from Severe/Regression to Normal

The error (unicode object has no attribute contains) should be resolved. I will leave it open for the missing check for suitable values and an appropriate warning.

#8 Updated by Daniel Vaz over 11 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#9 Updated by Giovanni Manghi over 11 years ago

  • Status changed from Closed to In Progress
  • Pull Request or Patch supplied changed from No to Yes

#10 Updated by Filipe Dias over 11 years ago

Yes it's better to close the ticket only when the pull request is merged. Thanks for fixing this Daniel.

#11 Updated by Daniel Vaz over 11 years ago

Sorry about closing the bug...

#12 Updated by Nathan Woodrow over 11 years ago

  • Status changed from In Progress to Closed

#13 Updated by Giovanni Manghi over 7 years ago

The "ftools" category is being removed from the tracker, changing the category of this ticket to "Processing/QGIS" to not leave the category orphaned.

Also available in: Atom PDF