Browse Source

attempt to fix failure when loading broken addons
report errors when unable to parse addons interface
add message when some addons failed, suggest solution to the user
(merge https://trac.osgeo.org/grass/changeset/64499, https://trac.osgeo.org/grass/changeset/64504, https://trac.osgeo.org/grass/changeset/64532 from trunk)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@64628 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 10 years ago
parent
commit
944468ad32
1 changed files with 10 additions and 3 deletions
  1. 10 3
      gui/wxpython/core/toolboxes.py

+ 10 - 3
gui/wxpython/core/toolboxes.py

@@ -504,6 +504,7 @@ def _expandRuntimeModules(node):
     >>> etree.tostring(tree)
     '<items><module-item name="m.proj"><module>m.proj</module><description>Converts coordinates from one projection to another (cs2cs frontend).</description><keywords>miscellaneous,projection</keywords></module-item></items>'
     """
+    hasErrors = False
     modules = node.findall('.//module-item')
     for module in modules:
         name = module.get('name')
@@ -517,8 +518,13 @@ def _expandRuntimeModules(node):
             n.text = _escapeXML(desc)
             n = etree.SubElement(parent=module, tag='keywords')
             n.text = _escapeXML(','.join(keywords))
-
-
+            if not desc:
+                hasErrors = True
+    
+    if hasErrors:
+        sys.stderr.write(_("WARNING: Some addons failed when loading. "
+                           "Please consider to update your addons by running 'g.extension.all -f'.\n"))
+    
 def _escapeXML(text):
     """Helper function for correct escaping characters for XML.
 
@@ -539,7 +545,8 @@ def _loadMetadata(module):
     """
     try:
         task = gtask.parse_interface(module)
-    except ScriptError:
+    except (ScriptError, UnicodeDecodeError) as e:
+        sys.stderr.write("%s: %s\n" % (module, e))
         return '', ''
 
     return task.get_description(full=True), \