[GRASS-dev] [GRASS-SVN] r66995 - grass-addons/grass7/vector/v.in.natura2000

Hi Helmut,

On Tue, Dec 1, 2015 at 5:11 AM, <svn_grass@osgeo.org> wrote:

+try:
+ import pyspatialite.dbapi2 as db
+except ImportError:
+ grass.warning( "pyspatialite has to be installed." )

better than this is the approach taken in v.flexture where you let parser
run and then you import the special dependencies. v.class.mlpy and
especially v.class.ml are more complicated cases where the dependencies are
spread more through the code but similar approach is still applicable.

As you can see from v.flexture, there was an idea to provide a way how to
install the dependencies but this might be too difficult and suggestions in
the error message or manual might be just the right thing to do.

Vaclav

https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.flexure/v.flexure.py
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.mlpy/v.class.mlpy.py
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.ml/v.class.ml.py

On Tue, Dec 1, 2015 at 7:24 PM, Vaclav Petras <wenzeslaus@gmail.com> wrote:

Hi Helmut,

On Tue, Dec 1, 2015 at 5:11 AM, <svn_grass@osgeo.org> wrote:

+try:
+ import pyspatialite.dbapi2 as db
+except ImportError:
+ grass.warning( "pyspatialite has to be installed." )

better than this is the approach taken in v.flexture where you let parser
run and then you import the special dependencies. v.class.mlpy and
especially v.class.ml are more complicated cases where the dependencies are
spread more through the code but similar approach is still applicable.

As you can see from v.flexture, there was an idea to provide a way how to
install the dependencies but this might be too difficult and suggestions in
the error message or manual might be just the right thing to do.

Vaclav

https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.flexure/v.flexure.py
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.mlpy/v.class.mlpy.py
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.ml/v.class.ml.py

FWIW, today I have added a termcolor check to g.search.modules, just
within the code.

https://trac.osgeo.org/grass/changeset/67001

Only if the user requested -c (colorize) the check is executed (hence,
after the parser was called).

Hope this makes sense,
Markus

Hi Vaclav,

wenzeslaus wrote

Hi Helmut,

On Tue, Dec 1, 2015 at 5:11 AM, &lt;

svn_grass@

&gt; wrote:

+try:
+ import pyspatialite.dbapi2 as db
+except ImportError:
+ grass.warning( "pyspatialite has to be installed." )

better than this is the approach taken in v.flexture where you let parser
run and then you import the special dependencies. v.class.mlpy and
especially v.class.ml are more complicated cases where the dependencies
are
spread more through the code but similar approach is still applicable.

As you can see from v.flexture, there was an idea to provide a way how to
install the dependencies but this might be too difficult and suggestions
in
the error message or manual might be just the right thing to do.

Vaclav

https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.flexure/v.flexure.py
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.mlpy/v.class.mlpy.py
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.ml/v.class.ml.py

thanks for your hints.

as I'm not a python guru, I've changed it like this way to catch if
dependency pyspatalite isn't installed:

https://trac.osgeo.org/grass/changeset?reponame=&new=67009%40grass-addons%2Fgrass7%2Fvector%2Fv.in.natura2000%2Fv.in.natura2000.py&old=66995%40grass-addons%2Fgrass7%2Fvector%2Fv.in.natura2000%2Fv.in.natura2000.py

or

https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.in.natura2000/v.in.natura2000.py#L151

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Re-GRASS-SVN-r66995-grass-addons-grass7-vector-v-in-natura2000-tp5239422p5239706.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On Wed, Dec 2, 2015 at 4:08 PM, Helmut Kudrnovsky <hellik@web.de> wrote:

> better than this is the approach taken in v.flexture where you let parser
> run and then you import the special dependencies. v.class.mlpy and
> especially v.class.ml are more complicated cases where the dependencies
> are
> spread more through the code but similar approach is still applicable.
>
> As you can see from v.flexture, there was an idea to provide a way how to
> install the dependencies but this might be too difficult and suggestions
> in
> the error message or manual might be just the right thing to do.
>
> Vaclav
>
>
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.flexure/v.flexure.py
>
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.mlpy/v.class.mlpy.py
>
https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.class.ml/v.class.ml.py

thanks for your hints.

as I'm not a python guru, I've changed it like this way to catch if
dependency pyspatalite isn't installed:

Thanks. This is pretty good. (Except for the indent, use pep8.)

https://trac.osgeo.org/grass/changeset?reponame=&new=67009%40grass-addons%2Fgrass7%2Fvector%2Fv.in.natura2000%2Fv.in.natura2000.py&old=66995%40grass-addons%2Fgrass7%2Fvector%2Fv.in.natura2000%2Fv.in.natura2000.py

or

https://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.in.natura2000/v.in.natura2000.py#L151