[GRASS-SVN] r62536 - in grass/trunk: gui/wxpython/docs/wxgui_sphinx lib/python/docs lib/python/exceptions lib/python/script scripts/g.extension scripts/r.grow

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 1 21:45:37 PDT 2014


Author: wenzeslaus
Date: 2014-11-01 21:45:37 -0700 (Sat, 01 Nov 2014)
New Revision: 62536

Modified:
   grass/trunk/gui/wxpython/docs/wxgui_sphinx/Makefile
   grass/trunk/lib/python/docs/Makefile
   grass/trunk/lib/python/exceptions/__init__.py
   grass/trunk/lib/python/script/core.py
   grass/trunk/scripts/g.extension/g.extension.py
   grass/trunk/scripts/r.grow/r.grow.py
Log:
revert r62535 (accidental commit of whole tree)

Modified: grass/trunk/gui/wxpython/docs/wxgui_sphinx/Makefile
===================================================================
--- grass/trunk/gui/wxpython/docs/wxgui_sphinx/Makefile	2014-11-02 04:42:47 UTC (rev 62535)
+++ grass/trunk/gui/wxpython/docs/wxgui_sphinx/Makefile	2014-11-02 04:45:37 UTC (rev 62536)
@@ -79,8 +79,8 @@
 wxguiapidoc:
 	@echo $(SPHINXAPIDOC)
 	@echo $(SPHINXBUILD)
-	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../../ ../../*/g.gui.*.py)
-
+	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../../)
+	
 wxguihtml:
 	$(call run_grass,$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR_HTML))
 	@echo

Modified: grass/trunk/lib/python/docs/Makefile
===================================================================
--- grass/trunk/lib/python/docs/Makefile	2014-11-02 04:42:47 UTC (rev 62535)
+++ grass/trunk/lib/python/docs/Makefile	2014-11-02 04:45:37 UTC (rev 62536)
@@ -61,7 +61,7 @@
 	@echo "SPHINXBUILD: Using <$(SPHINXBUILD)>"
 	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../imaging/)
 	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../exceptions/)
-	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../gunittest/ ../gunittest/multireport.py ../gunittest/multirunner.py ../gunittest/main.py)
+	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../gunittest/)
 	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../pydispatch/)
 	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../pygrass/)
 	$(call run_grass,$(SPHINXAPIDOC) -T -f -o src/ ../script/)

Modified: grass/trunk/lib/python/exceptions/__init__.py
===================================================================
--- grass/trunk/lib/python/exceptions/__init__.py	2014-11-02 04:42:47 UTC (rev 62535)
+++ grass/trunk/lib/python/exceptions/__init__.py	2014-11-02 04:45:37 UTC (rev 62536)
@@ -53,7 +53,6 @@
 
 
 # TODO: we inherit from subprocess to be aligned with check_call but it is needed?
-# perhaps it would be better to inherit from Exception or from ScriptError
 class CalledModuleError(subprocess.CalledProcessError):
     """Raised when a called module ends with error (non-zero return code)
 
@@ -63,7 +62,6 @@
     :param error: errors provided by the module (stderr)
     """
     def __init__(self, module, code, returncode, errors=None):
-        # CalledProcessError has undocumented constructor
         super(CalledModuleError, self).__init__(returncode, module)
         msg = _("Module run %s %s ended with error") % (module, code)
         msg += _("\nProcess ended with non-zero return code %s") % returncode

Modified: grass/trunk/lib/python/script/core.py
===================================================================
--- grass/trunk/lib/python/script/core.py	2014-11-02 04:42:47 UTC (rev 62535)
+++ grass/trunk/lib/python/script/core.py	2014-11-02 04:45:37 UTC (rev 62536)
@@ -29,7 +29,7 @@
 import types as python_types
 
 from utils import KeyValue, parse_key_val, basename, encode
-from grass.exceptions import ScriptError, CalledModuleError
+from grass.exceptions import ScriptError
 
 # i18N
 import gettext
@@ -344,7 +344,7 @@
 
 def run_command(*args, **kwargs):
     """Passes all arguments to start_command(), then waits for the process to
-    complete, returning its exit code. Similar to subprocess.check_call(), but
+    complete, returning its exit code. Similar to subprocess.call(), but
     with the make_command() interface.
 
     :param list args: list of unnamed arguments (see start_command() for details)
@@ -353,15 +353,7 @@
     :return: exit code (0 for success)
     """
     ps = start_command(*args, **kwargs)
-    returncode = ps.wait()
-    if returncode:
-        # TODO: construction of the whole command is far from perfect
-        args = make_command(*args, **kwargs)
-        raise CalledModuleError(module=None, code=' '.join(args),
-                                returncode=returncode)
-    else:
-        # the else is just for compatibility, remove before 7.1
-        return 0
+    return ps.wait()
 
 
 def pipe_command(*args, **kwargs):
@@ -410,15 +402,8 @@
 
     :return: stdout
     """
-    process = pipe_command(*args, **kwargs)
-    stdout, unused = process.communicate()
-    returncode = process.poll()
-    if returncode:
-        # TODO: construction of the whole command is far from perfect
-        args = make_command(*args, **kwargs)
-        raise CalledModuleError(module=None, code=' '.join(args),
-                                returncode=returncode)
-    return stdout
+    ps = pipe_command(*args, **kwargs)
+    return ps.communicate()[0]
 
 
 def parse_command(*args, **kwargs):
@@ -473,17 +458,10 @@
     :return: return code
     """
     stdin = kwargs['stdin']
-    process = feed_command(*args, **kwargs)
-    process.communicate(stdin)
-    returncode = process.poll()
-    if returncode:
-        # TODO: construction of the whole command is far from perfect
-        args = make_command(*args, **kwargs)
-        raise CalledModuleError(module=None, code=' '.join(args),
-                                returncode=returncode)
-    else:
-        # the else is just for compatibility, remove before 7.1
-        return 0
+    p = feed_command(*args, **kwargs)
+    p.stdin.write(stdin)
+    p.stdin.close()
+    return p.wait()
 
 
 def exec_command(prog, flags="", overwrite=False, quiet=False, verbose=False,
@@ -1066,13 +1044,9 @@
     if element == 'raster' or element == 'rast':
         verbose(_('Element type should be "cell" and not "%s"') % element)
         element = 'cell'
-    # g.findfile returns non-zero when file was not found
-    # se we ignore return code and just focus on stdout
-    process = start_command('g.findfile', flags='n',
-                            element=element, file=name, mapset=mapset,
-                            stdout=PIPE)
-    stdout = process.communicate()[0]
-    return parse_key_val(stdout)
+    s = read_command("g.findfile", flags='n', element=element, file=name,
+                     mapset=mapset)
+    return parse_key_val(s)
 
 # interface to g.list
 

Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2014-11-02 04:42:47 UTC (rev 62535)
+++ grass/trunk/scripts/g.extension/g.extension.py	2014-11-02 04:45:37 UTC (rev 62536)
@@ -47,16 +47,8 @@
 #% key_desc: url
 #% description: SVN Addons repository URL
 #% answer: http://svn.osgeo.org/grass/grass-addons/grass7
-#% required: no
 #%end
 #%option
-#% key: srcdir
-#% type: string
-#% key_desc: directory
-#% description: Directory with source code
-#% required: no
-#%end
-#%option
 #% key: prefix
 #% type: string
 #% key_desc: path
@@ -732,14 +724,11 @@
     return 0
 
 # install extension on other plaforms
-def install_extension_other(name, src_dir=None):
+def install_extension_other(name):
     gisbase = os.getenv('GISBASE')
     classchar = name.split('.', 1)[0]
     moduleclass = expand_module_class_name(classchar)
-    if not src_dir:
-        url = options['svnurl'] + '/' + moduleclass + '/' + name
-    else:
-        url = None
+    url = options['svnurl'] + '/' + moduleclass + '/' + name
     
     grass.message(_("Fetching <%s> from GRASS-Addons SVN repository (be patient)...") % name)
 
@@ -749,13 +738,9 @@
     else:
         outdev = sys.stdout
 
-    if url:
-        grass.message(_("Fetching <%s> from GRASS-Addons SVN (be patient)...") % name)
-        if grass.call(['svn', 'checkout',
-                       url], stdout = outdev) != 0:
-            grass.fatal(_("GRASS Addons <%s> not found") % name)
-    else:
-        grass.message(_("Instaling <%s> from directory <%s>...") % (name, src_dir))
+    if grass.call(['svn', 'checkout',
+                   url], stdout = outdev) != 0:
+        grass.fatal(_("GRASS Addons <%s> not found") % name)
 
     dirs = { 'bin'     : os.path.join(TMPDIR, name, 'bin'),
              'docs'    : os.path.join(TMPDIR, name, 'docs'),
@@ -795,10 +780,7 @@
         sys.stderr.write(' '.join(installCmd) + '\n')
         return 0
 
-    if url:
-        os.chdir(os.path.join(TMPDIR, name))
-    else:
-        os.chdir(src_dir)
+    os.chdir(os.path.join(TMPDIR, name))
 
     grass.message(_("Compiling..."))
     if 0 != grass.call(makeCmd,
@@ -1044,17 +1026,6 @@
             options['prefix'] = os.path.join(os.environ['HOME'], '.grass%s' % version[0], 'addons')
         else:
             options['prefix'] = os.environ['GRASS_ADDON_BASE']
-
-    src_dir = options['srcdir']
-    if src_dir:
-        if sys.platform != "win32":
-            install_extension_other(options['extension'], src_dir)
-            return 0
-        else:
-            grass.fatal(_("Cannot compile and install from source code on"
-                          " MS Windows (TODO: this is not true for Python"
-                          " except for the fact that make is not available)."))
-
     if 'svn.osgeo.org/grass/grass-addons/grass7' in options['svnurl']:
         # use pregenerated modules XML file
         xmlurl = "http://grass.osgeo.org/addons/grass%s" % version[0]

Modified: grass/trunk/scripts/r.grow/r.grow.py
===================================================================
--- grass/trunk/scripts/r.grow/r.grow.py	2014-11-02 04:42:47 UTC (rev 62535)
+++ grass/trunk/scripts/r.grow/r.grow.py	2014-11-02 04:45:37 UTC (rev 62536)
@@ -102,10 +102,7 @@
 
     if metric == 'euclidean':
         metric = 'squared'
-        if radius > 0:
-            radius = radius * radius
-        else:
-            radius = - (radius * radius)
+        radius = radius * radius
 
     #check if input file exists
     if not grass.find_file(input)['file']:



More information about the grass-commit mailing list