[GRASS-SVN] r58199 - grass/branches/develbranch_6/gui/scripts

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Nov 11 18:30:59 PST 2013


Author: hamish
Date: 2013-11-11 18:30:59 -0800 (Mon, 11 Nov 2013)
New Revision: 58199

Modified:
   grass/branches/develbranch_6/gui/scripts/g.extension.py
Log:
try to get python addon scripts working in WinGrass; it seems '.py' in the .bat filename works from the msys cmd line, but without '.py' in the .bat filename works from the wxgui command console. argh..

Modified: grass/branches/develbranch_6/gui/scripts/g.extension.py
===================================================================
--- grass/branches/develbranch_6/gui/scripts/g.extension.py	2013-11-11 22:52:41 UTC (rev 58198)
+++ grass/branches/develbranch_6/gui/scripts/g.extension.py	2013-11-12 02:30:59 UTC (rev 58199)
@@ -618,14 +618,25 @@
     if os.path.exists(os.path.join(options['prefix'], 'scripts', options['extension'] + '.py')):
         shutil.move(os.path.join(options['prefix'], 'scripts', options['extension'] + '.py'),
                     os.path.join(options['prefix'], options['extension'] + '.py'))
-    if sys.platform == 'win32' and \
-            os.path.exists(os.path.join(options['prefix'], 'bin', options['extension']) + EXT_SCT):
-        shutil.move(os.path.join(options['prefix'], 'bin', options['extension']) + EXT_SCT,
-                    os.path.join(options['prefix'], options['extension']) + EXT_SCT)
-        # fix script path
-        for line in fileinput.FileInput(os.path.join(options['prefix'], options['extension']) + EXT_SCT,
-                                        inplace = True):
+    if sys.platform == 'win32':
+        is_python_script = False
+        if os.path.exists(os.path.join(options['prefix'], 'bin', options['extension']) + EXT_SCT):
+            shutil.move(os.path.join(options['prefix'], 'bin', options['extension']) + EXT_SCT,
+                        os.path.join(options['prefix'], options['extension']) + EXT_SCT)
+        elif os.path.exists(os.path.join(options['prefix'], 'bin', options['extension']) + '.py' + EXT_SCT):
+            shutil.move(os.path.join(options['prefix'], 'bin', options['extension']) + '.py' + EXT_SCT,
+                        os.path.join(options['prefix'], options['extension']) + EXT_SCT)
+            is_python_script = True
+
+        # fix script path. may be it is better to just write out a new
+        #   windows_launch.bat template manually, since it's just a one-liner.
+        for line in fileinput.FileInput(os.path.join(options['prefix'],
+                                       options['extension']) + EXT_SCT,
+                                       inplace = True):
             line = line.replace("/scripts", "")
+            line = line.replace("%GISBSASE%", options['prefix'])
+            if is_python_script:
+                line = line.replace("GRASS_SH", "GRASS_PYTHON")
             print line
     
     # move man/ into docs/



More information about the grass-commit mailing list