[GRASS-SVN] r49565 - in grass/trunk: gui/wxpython/core lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 6 12:06:43 EST 2011
Author: martinl
Date: 2011-12-06 09:06:43 -0800 (Tue, 06 Dec 2011)
New Revision: 49565
Modified:
grass/trunk/gui/wxpython/core/gcmd.py
grass/trunk/lib/python/core.py
grass/trunk/lib/python/task.py
Log:
attempt to fix #1496 - TODO: replace such ugly hacks with something more reasonable in the future
Modified: grass/trunk/gui/wxpython/core/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/core/gcmd.py 2011-12-06 15:53:50 UTC (rev 49564)
+++ grass/trunk/gui/wxpython/core/gcmd.py 2011-12-06 17:06:43 UTC (rev 49565)
@@ -506,8 +506,20 @@
Debug.msg(1, "gcmd.CommandThread(): %s" % ' '.join(self.cmd))
self.startTime = time.time()
+
+ # TODO: replace ugly hack bellow
+ args = self.cmd
+ if sys.platform == 'win32':
+ ext = os.path.splitext(self.cmd[0])[1] == '.py'
+ if ext or self.cmd[0] in globalvar.grassCmd['script']:
+ os.chdir(os.path.join(os.getenv('GISBASE'), 'scripts'))
+ if not ext:
+ args = [sys.executable, self.cmd[0] + '.py'] + self.cmd[1:]
+ else:
+ args = [sys.executable, self.cmd[0]] + self.cmd[1:]
+
try:
- self.module = Popen(self.cmd,
+ self.module = Popen(args,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
@@ -624,6 +636,12 @@
Debug.msg(2, "gcmd.RunCommand(): command started")
start = time.time()
+ if sys.platform == "win32":
+ if prog in globalvar.grassCmd['script']:
+ prog += globalvar.EXT_SCT
+ # else:
+ # prog += globalvar.EXT_BIN
+
ps = grass.start_command(prog, flags, overwrite, quiet, verbose, **kwargs)
if stdin:
Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py 2011-12-06 15:53:50 UTC (rev 49564)
+++ grass/trunk/lib/python/core.py 2011-12-06 17:06:43 UTC (rev 49565)
@@ -165,7 +165,10 @@
else:
options[opt] = val
args = make_command(prog, flags, overwrite, quiet, verbose, **options)
-
+ if sys.platform == 'win32' and os.path.splitext(prog)[1] == '.py':
+ os.chdir(os.path.join(os.getenv('GISBASE'), 'scripts'))
+ args.insert(0, sys.executable)
+
global debug_level
if debug_level > 0:
sys.stderr.write("D1/%d: %s.start_command(): %s\n" % (debug_level, __name__, ' '.join(args)))
Modified: grass/trunk/lib/python/task.py
===================================================================
--- grass/trunk/lib/python/task.py 2011-12-06 15:53:50 UTC (rev 49564)
+++ grass/trunk/lib/python/task.py 2011-12-06 17:06:43 UTC (rev 49565)
@@ -430,14 +430,17 @@
@param cmd command (name of GRASS module)
"""
- if sys.platform == 'win32' and os.path.splitext(cmd)[1] == '.py':
- args = [sys.executable, cmd, '--interface-description']
- else:
- args = [cmd, '--interface-description']
-
try:
- cmdout, cmderr = Popen(args, stdout = PIPE,
+ cmdout, cmderr = Popen([cmd, '--interface-description'], stdout = PIPE,
stderr = PIPE).communicate()
+ # TODO: replace ugly hack bellow
+ if not cmdout and sys.platform == 'win32':
+ if os.path.splitext(cmd)[1] == '':
+ cmd += '.py'
+
+ os.chdir(os.path.join(os.getenv('GISBASE'), 'scripts'))
+ cmdout, cmderr = Popen([sys.executable, cmd, '--interface-description'], stdout = PIPE,
+ stderr = PIPE).communicate()
except OSError, e:
raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
"\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : e }
More information about the grass-commit
mailing list