<p>Hi,</p>
<p>how will this be solved? Then we could start backporting python lib etc to relbr7.</p>
<p>thanks<br>
Markus</p>
<div class="gmail_quote">On Sep 8, 2014 2:24 AM, "GRASS GIS" <<a href="mailto:trac@osgeo.org">trac@osgeo.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">#2410: Python ScriptError<br>
-------------------------+--------------------------------------------------<br>
Reporter: martinl | Owner: grass-dev@…<br>
Type: defect | Status: new<br>
Priority: normal | Milestone: 7.1.0<br>
Component: Python | Version: svn-trunk<br>
Keywords: ScriptError | Platform: Unspecified<br>
Cpu: Unspecified |<br>
-------------------------+--------------------------------------------------<br>
<br>
Comment(by zarch):<br>
<br>
Replying to [ticket:2410 martinl]:<br>
> In trunk Python Scripting Library is used !ScriptError from PyGRASS<br>
source:grass/trunk/lib/python/script/core.py#L36. It was introduced in<br>
r61187 by zarch. In relbr70 is still used it's own implementation of<br>
`ScriptError`<br>
source:grass/branches/releasebranch_7_0/lib/python/script/core.py#L70<br>
which defines attribute `value`. This attribute is accessed on many places<br>
of Python Scripting Library or wxGUI, eg.<br>
><br>
> {{{<br>
> except ScriptError as e:<br>
> self.errorMsg = e.value<br>
> }}}<br>
><br>
> Since `ScriptError` from PyGRASS doesn't have this attribute, it fails<br>
with<br>
><br>
> {{{<br>
> File "/opt/src/grass_trunk/dist.x86_64-unknown-linux-<br>
gnu/etc/python/grass/script/task.py", line 70, in __init__<br>
> self.errorMsg = e.value<br>
> AttributeError: 'ScriptError' object has no attribute 'value'<br>
> }}}<br>
<br>
Right I did this change, we can modify ScriptError back to:<br>
<br>
{{{<br>
class ScriptError(Exception):<br>
def __init__(self, msg):<br>
self.value = msg<br>
<br>
def __str__(self):<br>
return self.value<br>
<br>
# --- or alternatively<br>
class ScriptError(Exception):<br>
@property<br>
def value(self):<br>
return self.args[0]<br>
}}}<br>
<br>
or change the e.value to e.args[0]<br>
<br>
The value property seems to be used in:<br>
<br>
{{{<br>
$ grep --color=auto --exclude-dir={.svn,.git,.OBJ,locale,dist.x86_64<br>
-unknown-linux-gnu} -IrnE "\se\.value"<br>
lib/python/script/task.py:70: self.errorMsg = e.value<br>
gui/wxpython/vnet/vnet_utils.py:80: e = e.value<br>
gui/wxpython/vnet/vnet_utils.py:119: e = e.value<br>
gui/wxpython/psmap/instructions.py:1546: GError(message =<br>
e.value)<br>
gui/wxpython/psmap/instructions.py:1584: GError(message<br>
= e.value)<br>
gui/wxpython/psmap/instructions.py:1717: GError(message =<br>
e.value)<br>
gui/wxpython/mapwin/buffered.py:821: GError(message = e.value)<br>
gui/wxpython/location_wizard/wizard.py:2140: return e.value<br>
gui/wxpython/core/settings.py:48: print >> sys.stderr, e.value<br>
gui/wxpython/nviz/mapwindow.py:1355: message =<br>
e.value)<br>
gui/wxpython/nviz/mapwindow.py:1397: message =<br>
e.value)<br>
gui/wxpython/dbmgr/base.py:93: message = e.value)<br>
gui/wxpython/dbmgr/base.py:1814: message =<br>
_("Loading attribute data failed.\n\n%s") % e.value)<br>
gui/wxpython/dbmgr/base.py:1839: message =<br>
_("Loading attribute data failed.\n\n%s") % e.value)<br>
gui/wxpython/wxplot/histogram.py:189: message = e.value)<br>
gui/wxpython/wxplot/scatter.py:195: message = e.value)<br>
}}}<br>
<br>
Personally I think that we should change the ScriptError class definition.<br>
<br>
--<br>
Ticket URL: <<a href="http://trac.osgeo.org/grass/ticket/2410#comment:1" target="_blank">http://trac.osgeo.org/grass/ticket/2410#comment:1</a>><br>
GRASS GIS <<a href="http://grass.osgeo.org" target="_blank">http://grass.osgeo.org</a>><br>
<br>
_______________________________________________<br>
grass-dev mailing list<br>
<a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a></blockquote></div>