[GRASS-dev] [GRASS GIS] #2410: Python ScriptError

Markus Neteler neteler at osgeo.org
Sun Sep 14 10:33:20 PDT 2014


Hi,

how will this be solved? Then we could start backporting python lib etc to
relbr7.

thanks
Markus
On Sep 8, 2014 2:24 AM, "GRASS GIS" <trac at osgeo.org> wrote:

> #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  |
>
> -------------------------+--------------------------------------------------
>
> Comment(by zarch):
>
>  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]
>  }}}
>
>  or change the e.value to e.args[0]
>
>  The value property seems to be used in:
>
>  {{{
>  $ grep --color=auto --exclude-dir={.svn,.git,.OBJ,locale,dist.x86_64
>  -unknown-linux-gnu} -IrnE "\se\.value"
>  lib/python/script/task.py:70:                self.errorMsg = e.value
>  gui/wxpython/vnet/vnet_utils.py:80:        e = e.value
>  gui/wxpython/vnet/vnet_utils.py:119:        e = e.value
>  gui/wxpython/psmap/instructions.py:1546:            GError(message =
>  e.value)
>  gui/wxpython/psmap/instructions.py:1584:                    GError(message
>  = e.value)
>  gui/wxpython/psmap/instructions.py:1717:            GError(message =
>  e.value)
>  gui/wxpython/mapwin/buffered.py:821:            GError(message = e.value)
>  gui/wxpython/location_wizard/wizard.py:2140:            return e.value
>  gui/wxpython/core/settings.py:48:            print >> sys.stderr, e.value
>  gui/wxpython/nviz/mapwindow.py:1355:                       message =
>  e.value)
>  gui/wxpython/nviz/mapwindow.py:1397:                       message =
>  e.value)
>  gui/wxpython/dbmgr/base.py:93:                   message = e.value)
>  gui/wxpython/dbmgr/base.py:1814:                       message =
>  _("Loading attribute data failed.\n\n%s") % e.value)
>  gui/wxpython/dbmgr/base.py:1839:                           message =
>  _("Loading attribute data failed.\n\n%s") % e.value)
>  gui/wxpython/wxplot/histogram.py:189:                   message = e.value)
>  gui/wxpython/wxplot/scatter.py:195:                   message = e.value)
>  }}}
>
>  Personally I think that we should change the ScriptError class definition.
>
> --
> Ticket URL: <http://trac.osgeo.org/grass/ticket/2410#comment:1>
> GRASS GIS <http://grass.osgeo.org>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140914/1a33efb5/attachment.html>


More information about the grass-dev mailing list