[GRASS-SVN] r45767 - in grass/trunk: gui/wxpython gui/wxpython/gui_modules scripts/g.extension

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 26 15:25:42 EDT 2011


Author: martinl
Date: 2011-03-26 12:25:42 -0700 (Sat, 26 Mar 2011)
New Revision: 45767

Modified:
   grass/trunk/gui/wxpython/gui_modules/gdialogs.py
   grass/trunk/gui/wxpython/gui_modules/ghelp.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/wxgui.py
   grass/trunk/scripts/g.extension/g.extension.py
Log:
wxGUI: update install extensions window to install wxGUI extensions
(merge r45766 from devbr6)


Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2011-03-26 19:05:36 UTC (rev 45766)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2011-03-26 19:25:42 UTC (rev 45767)
@@ -956,7 +956,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/trunk/gui/wxpython/gui_modules/ghelp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/ghelp.py	2011-03-26 19:05:36 UTC (rev 45766)
+++ grass/trunk/gui/wxpython/gui_modules/ghelp.py	2011-03-26 19:25:42 UTC (rev 45767)
@@ -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,15 @@
         if not name:
             return
         log = self.parent.GetLogWindow()
-        log.RunCmd(['g.extension', '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'] + flags + ['extension=' + name,
+                                                 'svnurl=' + self.repo.GetValue().strip()])
+        
         self.OnCloseWindow(None)
         
     def OnUpdateStatusBar(self, event):
@@ -953,7 +984,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 +1000,8 @@
                  'r'  : 'raster',
                  'r3' : 'raster3D',
                  's'  : 'sites',
-                 'v'  : 'vector' }
+                 'v'  : 'vector',
+                 'wx' : 'wxGUI' }
         
         if name.has_key(c):
             return name[c]
@@ -1015,10 +1047,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/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-03-26 19:05:36 UTC (rev 45766)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2011-03-26 19:25:42 UTC (rev 45767)
@@ -2169,7 +2169,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/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2011-03-26 19:05:36 UTC (rev 45766)
+++ grass/trunk/gui/wxpython/wxgui.py	2011-03-26 19:25:42 UTC (rev 45767)
@@ -982,7 +982,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()
         

Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2011-03-26 19:05:36 UTC (rev 45766)
+++ grass/trunk/scripts/g.extension/g.extension.py	2011-03-26 19:25:42 UTC (rev 45767)
@@ -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



More information about the grass-commit mailing list