[GRASS-SVN] r49914 - in grass/branches/develbranch_6/gui: scripts wxpython/xml

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 25 19:38:35 EST 2011


Author: martinl
Date: 2011-12-25 16:38:34 -0800 (Sun, 25 Dec 2011)
New Revision: 49914

Added:
   grass/branches/develbranch_6/gui/scripts/g.extension.rebuild.all.py
Modified:
   grass/branches/develbranch_6/gui/scripts/g.extension.py
   grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
Log:
wxGUI: backport g.extension.rebuild.all from trunk
       various minor changes in g.extension


Modified: grass/branches/develbranch_6/gui/scripts/g.extension.py
===================================================================
--- grass/branches/develbranch_6/gui/scripts/g.extension.py	2011-12-26 00:22:39 UTC (rev 49913)
+++ grass/branches/develbranch_6/gui/scripts/g.extension.py	2011-12-26 00:38:34 UTC (rev 49914)
@@ -18,7 +18,7 @@
 #############################################################################
 
 #%module
-#% label: Tool to maintain the extensions in local GRASS installation.
+#% label: Maintains GRASS Addons extensions in local GRASS installation.
 #% description: Downloads, installs extensions from GRASS Addons SVN repository into local GRASS installation or removes installed extensions.
 #% keywords: general, installation, extensions
 #%end
@@ -498,7 +498,7 @@
     grass.message(_("Fetching <%s> from GRASS-Addons SVN (be patient)...") % options['extension'])
     
     os.chdir(tmpdir)
-    if grass.verbosity() == 0:
+    if grass.verbosity() <= 2:
         outdev = open(os.devnull, 'w')
     else:
         outdev = sys.stdout
@@ -541,7 +541,7 @@
     
     os.chdir(os.path.join(tmpdir, options['extension']))
     
-    grass.message(_("Compiling <%s>...") % options['extension'])    
+    grass.message(_("Compiling..."))
     if options['extension'] not in gui_list:
         ret = grass.call(makeCmd,
                          stdout = outdev)
@@ -556,7 +556,7 @@
     if flags['i'] or options['extension'] in gui_list:
         return
     
-    grass.message(_("Installing <%s>...") % options['extension'])
+    grass.message(_("Installing..."))
     
     return grass.call(installCmd,
                       stdout = outdev)

Added: grass/branches/develbranch_6/gui/scripts/g.extension.rebuild.all.py
===================================================================
--- grass/branches/develbranch_6/gui/scripts/g.extension.rebuild.all.py	                        (rev 0)
+++ grass/branches/develbranch_6/gui/scripts/g.extension.rebuild.all.py	2011-12-26 00:38:34 UTC (rev 49914)
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       g.extension.rebuild.all
+#
+# AUTHOR(S):   	Martin Landa <landa.martin gmail.com>
+#
+# PURPOSE:      Rebuild locally installed GRASS Addons extensions 
+#
+# COPYRIGHT:    (C) 2011 by Martin Landa, and the GRASS Development Team
+#
+#               This program is free software under the GNU General
+#               Public License (>=v2). Read the file COPYING that
+#               comes with GRASS for details.
+#
+#############################################################################
+
+#%module
+#% label: Rebuilds all locally installed GRASS Addons extensions.
+#% description: By default only extensions built against different GIS Library are rebuilt.
+#% keywords: general
+#% keywords: installation
+#% keywords: extensions
+#%end
+#%flag
+#% key: f
+#% description: Force to rebuild all extensions
+#% end
+
+import os
+import sys
+
+try:
+    import xml.etree.ElementTree as etree
+except ImportError:
+    import elementtree.ElementTree as etree # Python <= 2.4
+
+import grass.script as grass
+
+def get_extensions():
+    addon_base = os.getenv('GRASS_ADDON_PATH')
+    if not addon_base:
+        grass.fatal(_("%s not defined") % "GRASS_ADDON_PATH")
+    fXML = os.path.join(addon_base, 'modules.xml')
+    if not os.path.exists(fXML):
+        return []
+
+    # read XML file
+    fo = open(fXML, 'r')
+    try:
+        tree = etree.fromstring(fo.read())
+    except StandardError, e:
+        grass.error(_("Unable to parse metadata file: %s") % e)
+        fo.close()
+        return []
+    
+    fo.close()
+    
+    libgis_rev = grass.version()['libgis_revision']
+    ret = list()
+    for tnode in tree.findall('task'):
+        gnode = tnode.find('libgis')
+        if gnode is not None and \
+                gnode.get('revision', '') != libgis_rev:
+            ret.append(tnode.get('name'))
+    
+    return ret
+
+def main():
+    if flags['f']:
+        extensions = grass.read_command('g.extension.py',
+                                        quiet = True, flags = 'a').splitlines()
+    else:
+        extensions = get_extensions()
+    
+    if not extensions:
+        grass.info(_("Nothing to rebuild."))
+        return 0
+    
+    for ext in extensions:
+        grass.message('-' * 60)
+        grass.message(_("Reinstalling extension <%s>...") % ext)
+        grass.message('-' * 60)
+        grass.run_command('g.extension.py',
+                          extension = ext)
+    
+    return 0
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    sys.exit(main())


Property changes on: grass/branches/develbranch_6/gui/scripts/g.extension.rebuild.all.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2011-12-26 00:22:39 UTC (rev 49913)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2011-12-26 00:38:34 UTC (rev 49914)
@@ -862,6 +862,13 @@
 	      <command>g.extension</command>
 	    </menuitem>
 	    <menuitem>
+	      <label>Update installed extensions</label>
+	      <help>Rebuilds all locally installed GRASS Addons extensions.</help>
+	      <keywords>general,installation,extensions</keywords>
+	      <handler>OnMenuCmd</handler>
+	      <command>g.extension.rebuild.all.py</command>
+	    </menuitem>
+	    <menuitem>
 	      <label>Remove extension</label>
 	      <help>Removes installed GRASS AddOns extension.</help>
 	      <keywords>general,extensions</keywords>



More information about the grass-commit mailing list