[GRASS-SVN] r45766 - in grass/branches/develbranch_6/gui: scripts wxpython wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 26 15:05:36 EDT 2011


Author: martinl
Date: 2011-03-26 12:05:36 -0700 (Sat, 26 Mar 2011)
New Revision: 45766

Modified:
   grass/branches/develbranch_6/gui/scripts/g.extension.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: update install extensions window to install wxGUI extensions


Modified: grass/branches/develbranch_6/gui/scripts/g.extension.py
===================================================================
--- grass/branches/develbranch_6/gui/scripts/g.extension.py	2011-03-26 18:39:55 UTC (rev 45765)
+++ grass/branches/develbranch_6/gui/scripts/g.extension.py	2011-03-26 19:05:36 UTC (rev 45766)
@@ -308,7 +308,9 @@
     else:
         url = svnurl + '/gui/wxpython/' + module
         if not flags['s']:
-            grass.fatal(_("Installation of wxGUI extension requires -%s flag") % 's') 
+            grass.warning(_("Installation of wxGUI extension requires -%s flag. "
+                            "Trying to use system administrator rights.") % 's') 
+            flags['s'] = True
     
     grass.message(_("Fetching '%s' from GRASS-Addons SVN (be patient)...") % module)
     global tmpdir

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2011-03-26 18:39:55 UTC (rev 45765)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2011-03-26 19:05:36 UTC (rev 45766)
@@ -954,7 +954,7 @@
         self.list.LoadData()
 
         self.optionBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
-                                      label=_(" Options "))
+                                      label="%s" % _("Options"))
         
         cmd = self._getCommand()
         task = menuform.GUI().ParseInterface(cmd = [cmd])

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py	2011-03-26 18:39:55 UTC (rev 45765)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py	2011-03-26 19:05:36 UTC (rev 45766)
@@ -39,6 +39,7 @@
 import globalvar
 import gdialogs
 import utils
+import menuform
 
 class HelpFrame(wx.Frame):
     """!GRASS Quickstart help window"""
@@ -784,8 +785,9 @@
 
 class InstallExtensionWindow(wx.Frame):
     def __init__(self, parent, id = wx.ID_ANY,
-                 title = _("Fetch & install new extension from GRASS Addons"), **kwargs):
+                 title = _("Fetch & install extension from GRASS Addons"), **kwargs):
         self.parent = parent
+        self.options = dict() # list of options
         
         wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
         
@@ -807,6 +809,21 @@
         
         self.tree   = ExtensionTree(parent = self.panel, log = parent.GetLogWindow())
         
+        self.optionBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
+                                      label = " %s " % _("Options"))
+        task = menuform.GUI().ParseInterface(cmd = ['g.extension.py'])
+        for f in task.get_options()['flags']:
+            name = f.get('name', '')
+            desc = f.get('label', '')
+            if not desc:
+                desc = f.get('description', '')
+            if not name and not desc:
+                continue
+            if name in ('l', 'f', 'g'):
+                continue
+            self.options[name] = wx.CheckBox(parent = self.panel, id = wx.ID_ANY,
+                                             label = desc)
+        
         self.statusbar = self.CreateStatusBar(0)
         
         self.btnFetch = wx.Button(parent = self.panel, id = wx.ID_ANY,
@@ -847,6 +864,11 @@
         treeSizer = wx.StaticBoxSizer(self.treeBox, wx.HORIZONTAL)
         treeSizer.Add(item = self.tree, proportion = 1,
                       flag = wx.ALL | wx.EXPAND, border = 1)
+
+        # options
+        optionSizer = wx.StaticBoxSizer(self.optionBox, wx.VERTICAL)
+        for key in self.options.keys():
+            optionSizer.Add(item = self.options[key], proportion = 0)
         
         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
         btnSizer.Add(item = self.btnClose, proportion = 0,
@@ -859,6 +881,8 @@
                   flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
         sizer.Add(item = treeSizer, proportion = 1,
                   flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
+        sizer.Add(item = optionSizer, proportion = 0,
+                        flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
         sizer.Add(item = btnSizer, proportion = 0,
                   flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
         
@@ -871,8 +895,13 @@
         if not name:
             return
         log = self.parent.GetLogWindow()
-        log.RunCmd(['g.extension.py', 'extension=' + name,
-                    'svnurl=' + self.repo.GetValue().strip()])
+        flags = list()
+        for key in self.options.keys():
+            if self.options[key].IsChecked():
+                flags.append('-%s' % key)
+        
+        log.RunCmd(['g.extension.py'] + flags + ['extension=' + name,
+                                                 'svnurl=' + self.repo.GetValue().strip()])
         self.OnCloseWindow(None)
         
     def OnUpdateStatusBar(self, event):
@@ -953,7 +982,7 @@
         for prefix in ('display', 'database',
                        'general', 'imagery',
                        'misc', 'postscript', 'paint',
-                       'raster', 'raster3D', 'sites', 'vector'):
+                       'raster', 'raster3D', 'sites', 'vector', 'wxGUI'):
             self.AppendItem(parentId = self.root,
                             text = prefix)
         self._loaded = False
@@ -969,7 +998,8 @@
                  'r'  : 'raster',
                  'r3' : 'raster3D',
                  's'  : 'sites',
-                 'v'  : 'vector' }
+                 'v'  : 'vector',
+                 'wx' : 'wxGUI' }
         
         if name.has_key(c):
             return name[c]
@@ -1015,10 +1045,18 @@
                 else:
                     mdict[prefix][name][key] = value
             else:
-                prefix, name = line.strip().split('.', 1)
+                try:
+                    prefix, name = line.strip().split('.', 1)
+                except:
+                    prefix = 'unknown'
+                    name = line.strip()
+                
+                if self._expandPrefix(prefix) == prefix:
+                    prefix = 'unknown'
+                    
                 if not mdict.has_key(prefix):
                     mdict[prefix] = dict()
-                
+                    
                 mdict[prefix][name] = { 'command' : prefix + '.' + name }
         
         for prefix in mdict.keys():

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2011-03-26 18:39:55 UTC (rev 45765)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2011-03-26 19:05:36 UTC (rev 45766)
@@ -1987,7 +1987,7 @@
                                      stderr = grass.PIPE).communicate()
     except OSError, e:
         raise gcmd.GException, _("Unable to fetch interface description for command '%s'. "
-                                 "Details: %s") % (cmd, e.value)
+                                 "Details: %s") % (cmd, e)
     if cmderr and cmderr[:7] != 'WARNING':
         raise gcmd.GException, _("Unable to fetch interface description for command '%s'. "
                                  "Details: %s") % (cmd, cmderr)

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-03-26 18:39:55 UTC (rev 45765)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-03-26 19:05:36 UTC (rev 45766)
@@ -1041,7 +1041,7 @@
         
     def OnInstallExtension(self, event):
         """!Install extension from GRASS Addons SVN repository"""
-        win = InstallExtensionWindow(self, size = (550, 400))
+        win = InstallExtensionWindow(self, size = (650, 550))
         win.CentreOnScreen()
         win.Show()
 



More information about the grass-commit mailing list