[GRASS-SVN] r54087 - grass/trunk/lib/python/pygrass/modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Nov 28 04:11:48 PST 2012
Author: zarch
Date: 2012-11-28 04:11:47 -0800 (Wed, 28 Nov 2012)
New Revision: 54087
Modified:
grass/trunk/lib/python/pygrass/modules/__init__.py
Log:
If is not able to get the xml of a module suggest to the user to check if the module exist
Modified: grass/trunk/lib/python/pygrass/modules/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/__init__.py 2012-11-28 09:24:47 UTC (rev 54086)
+++ grass/trunk/lib/python/pygrass/modules/__init__.py 2012-11-28 12:11:47 UTC (rev 54087)
@@ -20,6 +20,7 @@
import grass
+from pygrass.errors import GrassError
#
# this dictionary is used to extract the value of interest from the xml
@@ -384,9 +385,13 @@
"""
def __init__(self, cmd, *args, **kargs):
self.name = cmd
- # call the command with --interface-description
- get_cmd_xml = subprocess.Popen([cmd, "--interface-description"],
- stdout=subprocess.PIPE)
+ try:
+ # call the command with --interface-description
+ get_cmd_xml = subprocess.Popen([cmd, "--interface-description"],
+ stdout=subprocess.PIPE)
+ except OSError:
+ str_err = "Module %r not found, please check that the module exist"
+ raise GrassError(str_err % self.name)
# get the xml of the module
self.xml = get_cmd_xml.communicate()[0]
# transform and parse the xml into an Element class:
More information about the grass-commit
mailing list