[GRASS-SVN] r45650 - grass/trunk/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Mar 12 16:27:35 EST 2011
Author: martinl
Date: 2011-03-12 13:27:35 -0800 (Sat, 12 Mar 2011)
New Revision: 45650
Modified:
grass/trunk/lib/python/core.py
Log:
pythonlib: force 'plain' format when raise_on_error is True
Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py 2011-03-12 21:08:38 UTC (rev 45649)
+++ grass/trunk/lib/python/core.py 2011-03-12 21:27:35 UTC (rev 45650)
@@ -189,9 +189,15 @@
"""
if get_raise_on_error():
kwargs['stderr'] = PIPE
+ env = os.getenv('GRASS_MESSAGE_FORMAT')
+ os.environ['GRASS_MESSAGE_FORMAT'] = 'plain'
+
ps = start_command(*args, **kwargs)
+
if get_raise_on_error():
err = ps.communicate()[1]
+ if env:
+ os.environ['GRASS_MESSAGE_FORMAT'] = env
if ps.returncode != 0:
raise ScriptError(_("Error in %s(%s): %s") % ('run_command', args[0], _get_error(err)))
return ps.returncode
@@ -246,9 +252,15 @@
"""
if get_raise_on_error():
kwargs['stderr'] = PIPE
+ env = os.getenv('GRASS_MESSAGE_FORMAT')
+ os.environ['GRASS_MESSAGE_FORMAT'] = 'plain'
+
ps = pipe_command(*args, **kwargs)
+
if get_raise_on_error():
out, err = ps.communicate()
+ if env:
+ os.environ['GRASS_MESSAGE_FORMAT'] = env
if ps.returncode != 0:
raise ScriptError(_("Error in %s(%s): %s") % ('read_command', args[0], _get_error(err)))
return _decode(out)
@@ -298,10 +310,16 @@
stdin = kwargs['stdin']
if get_raise_on_error():
kwargs['stderr'] = PIPE
+ env = os.getenv('GRASS_MESSAGE_FORMAT')
+ os.environ['GRASS_MESSAGE_FORMAT'] = 'plain'
+
p = feed_command(*args, **kwargs)
p.stdin.write(stdin)
+
if get_raise_on_error():
err = p.communicate()[1]
+ if env:
+ os.environ['GRASS_MESSAGE_FORMAT'] = env
p.stdin.close()
if p.returncode != 0:
raise ScriptError(_("Error in %s(%s): %s") % ('write_command', args[0], _get_error(err)))
@@ -309,7 +327,7 @@
else:
p.stdin.close()
return p.wait()
-
+
def exec_command(prog, flags = "", overwrite = False, quiet = False, verbose = False, env = None, **kwargs):
"""!Interface to os.execvpe(), but with the make_command() interface.
@@ -416,11 +434,6 @@
tmp_raise = raise_on_error
raise_on_error = raise_exp
- if raise_on_error:
- os.environ['GRASS_MESSAGE_FORMAT'] = 'plain'
- else:
- os.environ['GRASS_MESSAGE_FORMAT'] = 'standard'
-
return tmp_raise
def get_raise_on_error():
More information about the grass-commit
mailing list