Browse Source

wxGUI/extension: generate message error dialog when loading fails

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57156 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 years ago
parent
commit
a2f2ee722c
2 changed files with 11 additions and 5 deletions
  1. 3 0
      gui/wxpython/core/gcmd.py
  2. 8 5
      gui/wxpython/modules/extensions.py

+ 3 - 0
gui/wxpython/core/gcmd.py

@@ -149,6 +149,9 @@ class GException(Exception):
     def __str__(self):
     def __str__(self):
         return self.value
         return self.value
 
 
+    def __unicode__(self):
+        return self.value
+
 class Popen(subprocess.Popen):
 class Popen(subprocess.Popen):
     """!Subclass subprocess.Popen"""
     """!Subclass subprocess.Popen"""
     def __init__(self, args, **kwargs):
     def __init__(self, args, **kwargs):

+ 8 - 5
gui/wxpython/modules/extensions.py

@@ -26,7 +26,7 @@ import wx
 from grass.script import task as gtask
 from grass.script import task as gtask
 
 
 from core             import globalvar
 from core             import globalvar
-from core.gcmd        import GError, RunCommand
+from core.gcmd        import GError, RunCommand, GException
 from core.utils       import SetAddOnPath
 from core.utils       import SetAddOnPath
 from core.menutree    import TreeModel, ModuleNode
 from core.menutree    import TreeModel, ModuleNode
 from gui_core.widgets import GListCtrl, SearchModuleWidget
 from gui_core.widgets import GListCtrl, SearchModuleWidget
@@ -183,7 +183,11 @@ class InstallExtensionWindow(wx.Frame):
         """!Fetch list of available extensions"""
         """!Fetch list of available extensions"""
         wx.BeginBusyCursor()
         wx.BeginBusyCursor()
         self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
         self.SetStatusText(_("Fetching list of modules from GRASS-Addons SVN (be patient)..."), 0)
-        self.modelBuilder.Load(url = self.repo.GetValue().strip())
+        try:
+            self.modelBuilder.Load(url = self.repo.GetValue().strip())
+        except GException, e:
+            GError(unicode(e), parent = self, showTraceback = False)
+        
         self.tree.RefreshItems()
         self.tree.RefreshItems()
         self.SetStatusText("", 0)
         self.SetStatusText("", 0)
         wx.EndBusyCursor()
         wx.EndBusyCursor()
@@ -273,7 +277,7 @@ class ExtensionTreeModelBuilder:
                          svnurl = url,
                          svnurl = url,
                          flags = flags, quiet = True)
                          flags = flags, quiet = True)
         if not ret:
         if not ret:
-            return
+            raise GException(_("Unable to load extensions."))
         
         
         currentNode = None
         currentNode = None
         for line in ret.splitlines():
         for line in ret.splitlines():
@@ -311,8 +315,7 @@ class ExtensionTreeModelBuilder:
                 currentNode.data = {'command': module,
                 currentNode.data = {'command': module,
                                     'keywords': '',
                                     'keywords': '',
                                     'description': ''}        
                                     'description': ''}        
-
-
+        
 class UninstallExtensionWindow(wx.Frame):
 class UninstallExtensionWindow(wx.Frame):
     def __init__(self, parent, id = wx.ID_ANY,
     def __init__(self, parent, id = wx.ID_ANY,
                  title = _("Uninstall GRASS Addons extensions"), **kwargs):
                  title = _("Uninstall GRASS Addons extensions"), **kwargs):