[GRASS-SVN] r45651 - grass/branches/develbranch_6/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Mar 12 16:29:23 EST 2011
Author: martinl
Date: 2011-03-12 13:29:23 -0800 (Sat, 12 Mar 2011)
New Revision: 45651
Modified:
grass/branches/develbranch_6/lib/python/core.py
Log:
pythonlib: force 'plain' format when raise_on_error is True
(merge r45650 from trunk)
Modified: grass/branches/develbranch_6/lib/python/core.py
===================================================================
--- grass/branches/develbranch_6/lib/python/core.py 2011-03-12 21:27:35 UTC (rev 45650)
+++ grass/branches/develbranch_6/lib/python/core.py 2011-03-12 21:29:23 UTC (rev 45651)
@@ -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