[GRASS-SVN] r53674 - grass/trunk/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 3 07:48:33 PDT 2012


Author: glynn
Date: 2012-11-03 07:48:33 -0700 (Sat, 03 Nov 2012)
New Revision: 53674

Modified:
   grass/trunk/lib/python/core.py
Log:
Fix handling of debug_level (don't execute programs from top-level code)


Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py	2012-11-03 11:30:34 UTC (rev 53673)
+++ grass/trunk/lib/python/core.py	2012-11-03 14:48:33 UTC (rev 53674)
@@ -66,7 +66,6 @@
         return self.value
         
 raise_on_error = False # raise exception instead of calling fatal()
-debug_level = 0        # DEBUG level
 
 def call(*args, **kwargs):
     return Popen(*args, **kwargs).wait()
@@ -167,9 +166,8 @@
 
     args = make_command(prog, flags, overwrite, quiet, verbose, **options)
     
-    global debug_level
-    if debug_level > 0:
-        sys.stderr.write("D1/%d: %s.start_command(): %s\n" % (debug_level, __name__, ' '.join(args)))
+    if debug_level() > 0:
+        sys.stderr.write("D1/%d: %s.start_command(): %s\n" % (debug_level(), __name__, ' '.join(args)))
         sys.stderr.flush()
     
     return Popen(args, **popts)
@@ -1338,5 +1336,13 @@
     return data
 
 # get debug_level
-if find_program('g.gisenv', ['--help']):
-    debug_level = int(gisenv().get('DEBUG', 0))
+_debug_level = None
+
+def debug_level():
+    global _debug_level
+    if _debug_level is not None:
+        return _debug_level
+    if find_program('g.gisenv', ['--help']):
+        _debug_level = int(gisenv().get('DEBUG', 0))
+    else:
+        _debug_level = 0



More information about the grass-commit mailing list