[GRASS-SVN] r58680 - grass/branches/releasebranch_6_4/gui/scripts

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 12 04:56:22 PST 2014


Author: neteler
Date: 2014-01-12 04:56:22 -0800 (Sun, 12 Jan 2014)
New Revision: 58680

Modified:
   grass/branches/releasebranch_6_4/gui/scripts/g.extension.py
Log:
g.extension.py: backport of r58199 (ticket #2138)

Modified: grass/branches/releasebranch_6_4/gui/scripts/g.extension.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/scripts/g.extension.py	2014-01-12 11:08:30 UTC (rev 58679)
+++ grass/branches/releasebranch_6_4/gui/scripts/g.extension.py	2014-01-12 12:56:22 UTC (rev 58680)
@@ -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