#2410: Python ScriptError
-------------------------+--------------------------------------------------
Reporter: martinl | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.1.0
Component: Python | Version: svn-trunk
Keywords: ScriptError | Platform: Unspecified
Cpu: Unspecified |
-------------------------+--------------------------------------------------
In trunk Python Scripting Library is used !ScriptError from PyGRASS
source:grass/trunk/lib/python/script/core.py#L36. It was introduced in
r61187 by zarch. In relbr70 is still used it's own implementation of
`ScriptError`
source:grass/branches/releasebranch_7_0/lib/python/script/core.py#L70
which defines attribute `value`. This attribute is accessed on many places
of Python Scripting Library or wxGUI, eg.
{{{
except ScriptError as e:
self.errorMsg = e.value
}}}
Since `ScriptError` from PyGRASS doesn't have this attribute, it fails
with
{{{
File "/opt/src/grass_trunk/dist.x86_64-unknown-linux-
gnu/etc/python/grass/script/task.py", line 70, in __init__
self.errorMsg = e.value
AttributeError: 'ScriptError' object has no attribute 'value'
}}}
Replying to [ticket:2410 martinl]:
> In trunk Python Scripting Library is used !ScriptError from PyGRASS
source:grass/trunk/lib/python/script/core.py#L36. It was introduced in
r61187 by zarch. In relbr70 is still used it's own implementation of
`ScriptError`
source:grass/branches/releasebranch_7_0/lib/python/script/core.py#L70
which defines attribute `value`. This attribute is accessed on many places
of Python Scripting Library or wxGUI, eg.
>
> {{{
> except ScriptError as e:
> self.errorMsg = e.value
> }}}
>
> Since `ScriptError` from PyGRASS doesn't have this attribute, it fails
with
>
> {{{
> File "/opt/src/grass_trunk/dist.x86_64-unknown-linux-
gnu/etc/python/grass/script/task.py", line 70, in __init__
> self.errorMsg = e.value
> AttributeError: 'ScriptError' object has no attribute 'value'
> }}}
Right I did this change, we can modify ScriptError back to:
{{{
class ScriptError(Exception):
def __init__(self, msg):
self.value = msg
def __str__(self):
return self.value
# --- or alternatively
class ScriptError(Exception): @property
def value(self):
return self.args[0]
}}}
In trunk Python Scripting Library is used !ScriptError from PyGRASS
source:grass/trunk/lib/python/script/core.py#L36. It was introduced in
r61187 by zarch. In relbr70 is still used it’s own implementation of ScriptError
source:grass/branches/releasebranch_7_0/lib/python/script/core.py#L70
which defines attribute value. This attribute is accessed on many places
of Python Scripting Library or wxGUI, eg.
{{{
except ScriptError as e:
self.errorMsg = e.value
}}}
Since ScriptError from PyGRASS doesn’t have this attribute, it fails
with
{{{
File “/opt/src/grass_trunk/dist.x86_64-unknown-linux-
gnu/etc/python/grass/script/task.py”, line 70, in init
self.errorMsg = e.value
AttributeError: ‘ScriptError’ object has no attribute ‘value’
}}}
Right I did this change, we can modify ScriptError back to:
{{{
class ScriptError(Exception):
def init(self, msg):
self.value = msg
def str(self):
return self.value
— or alternatively
class ScriptError(Exception): @property
def value(self):
return self.args[0]
}}}