[GRASS-SVN] r49917 - in grass/branches/develbranch_6/gui/wxpython: gcp lmgr location_wizard modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 26 09:15:28 EST 2011


Author: martinl
Date: 2011-12-26 06:15:28 -0800 (Mon, 26 Dec 2011)
New Revision: 49917

Modified:
   grass/branches/develbranch_6/gui/wxpython/gcp/manager.py
   grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
   grass/branches/develbranch_6/gui/wxpython/location_wizard/wizard.py
   grass/branches/develbranch_6/gui/wxpython/modules/vclean.py
   grass/branches/develbranch_6/gui/wxpython/vdigit/wxdigit.py
Log:
wxGUI: improve OnRunScript - check permission and GRASS_ADDON_PATH
       (merge r49915 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gcp/manager.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gcp/manager.py	2011-12-26 14:09:47 UTC (rev 49916)
+++ grass/branches/develbranch_6/gui/wxpython/gcp/manager.py	2011-12-26 14:15:28 UTC (rev 49917)
@@ -947,7 +947,7 @@
 
         if self.list.GetItemCount() <= minNumOfItems:
             GMessage(parent = self,
-                     message=_("At least %d GCPs required. Operation cancelled.") % minNumOfItems)
+                     message=_("At least %d GCPs required. Operation canceled.") % minNumOfItems)
             return
 
         key = self.list.DeleteGCPItem()
@@ -2071,7 +2071,7 @@
             
             if len(values) == 0:
                 GError(parent = self,
-                       message=_("Invalid coordinate value. Operation cancelled."))
+                       message=_("Invalid coordinate value. Operation canceled."))
             else:
                 for i in range(len(values)):
                     if values[i] != coords[i]:

Modified: grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py	2011-12-26 14:09:47 UTC (rev 49916)
+++ grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py	2011-12-26 14:15:28 UTC (rev 49917)
@@ -21,6 +21,7 @@
 import sys
 import os
 import tempfile
+import stat
 try:
     import xml.etree.ElementTree as etree
 except ImportError:
@@ -574,13 +575,50 @@
         
         if not filename:
             return False
-
+        
         if not os.path.exists(filename):
             GError(parent = self,
                    message = _("Script file '%s' doesn't exist. "
-                               "Operation cancelled.") % filename)
+                               "Operation canceled.") % filename)
             return
+
+        # check permission
+        if not os.access(filename, os.X_OK):
+            dlg = wx.MessageDialog(self,
+                                   message = _("Script <%s> is not executable. "
+                                               "Do you want to set the permissions "
+                                               "that allows you to run this script "
+                                               "(note that you must be the owner of the file)?" % \
+                                                   os.path.basename(filename)),
+                                   caption = _("Set permission?"),
+                                   style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+            if dlg.ShowModal() != wx.ID_YES:
+                return
+            dlg.Destroy()
+            try:
+                mode = stat.S_IMODE(os.lstat(filename)[stat.ST_MODE])
+                os.chmod(filename, mode | stat.S_IXUSR)
+            except OSError:
+                GError(_("Unable to set permission. Operation canceled."), parent = self)
+                return
         
+        # check GRASS_ADDON_PATH
+        addonPath = os.getenv('GRASS_ADDON_PATH', [])
+        if addonPath:
+            addonPath = addonPath.split(os.pathsep)
+        dirName = os.path.dirname(filename)
+        if dirName not in addonPath:
+            addonPath.append(dirName)
+            dlg = wx.MessageDialog(self,
+                                   message = _("Directory '%s' is not defined in GRASS_ADDON_PATH. "
+                                               "Do you want add this directory to GRASS_ADDON_PATH?") % \
+                                       dirName,
+                                   caption = _("Update Addons path?"),
+                                   style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+            if dlg.ShowModal() == wx.ID_YES:
+                os.environ['GRASS_ADDON_PATH'] = os.pathsep.join(addonPath)
+                RunCommand('g.gisenv', set = 'ADDON_PATH=%s' % os.environ['GRASS_ADDON_PATH'])
+        
         self.goutput.WriteCmdLog(_("Launching script '%s'...") % filename)
         self.goutput.RunCmd([filename], switchPage = True)
         
@@ -1675,6 +1713,6 @@
     def MsgNoLayerSelected(self):
         """!Show dialog message 'No layer selected'"""
         wx.MessageBox(parent = self,
-                      message = _("No map layer selected. Operation cancelled."),
+                      message = _("No map layer selected. Operation canceled."),
                       caption = _("Message"),
                       style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)

Modified: grass/branches/develbranch_6/gui/wxpython/location_wizard/wizard.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/location_wizard/wizard.py	2011-12-26 14:09:47 UTC (rev 49916)
+++ grass/branches/develbranch_6/gui/wxpython/location_wizard/wizard.py	2011-12-26 14:15:28 UTC (rev 49917)
@@ -1816,7 +1816,7 @@
                                           "Details: %(err)s") % \
                            { 'loc' : self.startpage.location,
                              'err' : msg })
-        else: # -> cancelled
+        else: # -> canceled
             self.wizard.Destroy()
             GMessage(parent = self.parent,
                      message = _("Location wizard canceled. "

Modified: grass/branches/develbranch_6/gui/wxpython/modules/vclean.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/modules/vclean.py	2011-12-26 14:09:47 UTC (rev 49916)
+++ grass/branches/develbranch_6/gui/wxpython/modules/vclean.py	2011-12-26 14:15:28 UTC (rev 49917)
@@ -461,7 +461,7 @@
                 err.append(_("'%s' not defined") % name)
         if err:
             GError(_("Some parameters not defined. Operation "
-                     "cancelled.\n\n%s") % '\n'.join(err),
+                     "canceled.\n\n%s") % '\n'.join(err),
                    parent = self)
             return
 

Modified: grass/branches/develbranch_6/gui/wxpython/vdigit/wxdigit.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/vdigit/wxdigit.py	2011-12-26 14:09:47 UTC (rev 49916)
+++ grass/branches/develbranch_6/gui/wxpython/vdigit/wxdigit.py	2011-12-26 14:15:28 UTC (rev 49917)
@@ -55,7 +55,7 @@
             message = _('Unable to open vector map <%s>.') % name
         else:
             message =  _('No vector map open for editing.')
-        GError(message + ' ' + _('Operation cancelled.'),
+        GError(message + ' ' + _('Operation canceled.'),
                parent  = self.parent,
                caption = self.caption)
 
@@ -71,7 +71,7 @@
         """!Reading line failed
         """
         GError(message = _('Reading feature id %d failed. '
-                           'Operation cancelled.') % line,
+                           'Operation canceled.') % line,
                parent  = self.parent,
                caption = self.caption)
 
@@ -79,7 +79,7 @@
         """!No dblink available
         """
         GError(message = _('Database link %d not available. '
-                           'Operation cancelled.') % dblink,
+                           'Operation canceled.') % dblink,
                parent  = self.parent,
                caption = self.caption)
 
@@ -87,7 +87,7 @@
         """!Staring driver failed
         """
         GError(message = _('Unable to start database driver <%s>. '
-                           'Operation cancelled.') % driver,
+                           'Operation canceled.') % driver,
                parent  = self.parent,
                caption = self.caption)
 
@@ -95,7 +95,7 @@
         """!Opening database failed
         """
         GError(message = _('Unable to open database <%(db)s> by driver <%(driver)s>. '
-                           'Operation cancelled.') % { 'db' : database, 'driver' : driver},
+                           'Operation canceled.') % { 'db' : database, 'driver' : driver},
                parent  = self.parent,
                caption = self.caption)
 
@@ -103,7 +103,7 @@
         """!Sql query failed
         """
         GError(message = _("Unable to execute SQL query '%s'. "
-                           "Operation cancelled.") % sql,
+                           "Operation canceled.") % sql,
                parent  = self.parent,
                caption = self.caption)
 
@@ -111,7 +111,7 @@
         """!Dead line
         """
         GError(message = _("Feature id %d is marked as dead. "
-                           "Operation cancelled.") % line,
+                           "Operation canceled.") % line,
                parent  = self.parent,
                caption = self.caption)
 
@@ -119,7 +119,7 @@
         """!Unknown feature type
         """
         GError(message = _("Unsupported feature type %d. "
-                           "Operation cancelled.") % ftype,
+                           "Operation canceled.") % ftype,
                parent  = self.parent,
                caption = self.caption)
         



More information about the grass-commit mailing list