[Numpy-svn] r3826 - trunk/numpy/distutils
numpy-svn at scipy.org
numpy-svn at scipy.org
Fri May 25 10:47:45 EDT 2007
Author: cookedm
Date: 2007-05-25 09:47:42 -0500 (Fri, 25 May 2007)
New Revision: 3826
Modified:
trunk/numpy/distutils/exec_command.py
trunk/numpy/distutils/log.py
trunk/numpy/distutils/misc_util.py
Log:
Add a numpy.distutils.log.good function, which when WARN messages would be
logged, logs a "nice" anti-warn version. Use this for finding executables
to report when we do actually find one.
Modified: trunk/numpy/distutils/exec_command.py
===================================================================
--- trunk/numpy/distutils/exec_command.py 2007-05-25 11:41:55 UTC (rev 3825)
+++ trunk/numpy/distutils/exec_command.py 2007-05-25 14:47:42 UTC (rev 3826)
@@ -159,7 +159,7 @@
if not os.path.islink(f_ext):
f_ext = realpath(f_ext)
if os.path.isfile(f_ext) and os.access(f_ext, os.X_OK):
- log.debug('Found executable %s' % f_ext)
+ log.good('Found executable %s' % f_ext)
return f_ext
log.warn('Could not locate executable %s' % orig_exe)
Modified: trunk/numpy/distutils/log.py
===================================================================
--- trunk/numpy/distutils/log.py 2007-05-25 11:41:55 UTC (rev 3825)
+++ trunk/numpy/distutils/log.py 2007-05-25 14:47:42 UTC (rev 3826)
@@ -4,7 +4,7 @@
from distutils.log import *
from distutils.log import Log as old_Log
from distutils.log import _global_log
-from misc_util import red_text, yellow_text, cyan_text, is_sequence, is_string
+from misc_util import red_text, yellow_text, cyan_text, green_text, is_sequence, is_string
def _fix_args(args,flag=1):
@@ -22,8 +22,29 @@
else:
print _global_color_map[level](msg)
sys.stdout.flush()
+
+ def good(self, msg, *args):
+ """If we'd log WARN messages, log this message as a 'nice' anti-warn
+ message.
+ """
+ if WARN >= self.threshold:
+ if args:
+ print green_text(msg % _fix_args(args))
+ else:
+ print green_text(msg)
+ sys.stdout.flush()
_global_log.__class__ = Log
+good = _global_log.good
+
+def set_threshold(level):
+ prev_level = _global_log.threshold
+ if prev_level > DEBUG:
+ # If we're running at DEBUG, don't change the threshold, as there's
+ # likely a good reason why we're running at this level.
+ _global_log.threshold = level
+ return prev_level
+
def set_verbosity(v):
prev_level = _global_log.threshold
if v < 0:
@@ -44,4 +65,4 @@
FATAL:red_text
}
-set_verbosity(1)
+set_verbosity(INFO)
Modified: trunk/numpy/distutils/misc_util.py
===================================================================
--- trunk/numpy/distutils/misc_util.py 2007-05-25 11:41:55 UTC (rev 3825)
+++ trunk/numpy/distutils/misc_util.py 2007-05-25 14:47:42 UTC (rev 3826)
@@ -65,7 +65,7 @@
# (likely we're building an egg)
d = os.path.abspath('.')
# hmm, should we use sys.argv[0] like in __builtin__ case?
-
+
if parent_path is not None:
d = rel_path(d, parent_path)
@@ -219,18 +219,37 @@
return 0
if terminal_has_colors():
- def red_text(s): return '\x1b[31m%s\x1b[0m'%s
- def green_text(s): return '\x1b[32m%s\x1b[0m'%s
- def yellow_text(s): return '\x1b[33m%s\x1b[0m'%s
- def blue_text(s): return '\x1b[34m%s\x1b[0m'%s
- def cyan_text(s): return '\x1b[35m%s\x1b[0m'%s
+ _colour_codes = dict(black=0, red=1, green=2, yellow=3,
+ blue=4, magenta=5, cyan=6, white=7)
+ def colour_text(s, fg=None, bg=None, bold=False):
+ seq = []
+ if bold:
+ seq.append('1')
+ if fg:
+ fgcode = 30 + _colour_codes.get(fg.lower(), 0)
+ seq.append(str(fgcode))
+ if bg:
+ bgcode = 40 + _colour_codes.get(fg.lower(), 7)
+ seq.append(str(bgcode))
+ if seq:
+ return '\x1b[%sm%s\x1b[0m' % (';'.join(seq), s)
+ else:
+ return s
else:
- def red_text(s): return s
- def green_text(s): return s
- def yellow_text(s): return s
- def cyan_text(s): return s
- def blue_text(s): return s
+ def colour_text(s, fg=None, bg=None):
+ return s
+def red_text(s):
+ return colour_text(s, 'red')
+def green_text(s):
+ return colour_text(s, 'green')
+def yellow_text(s):
+ return colour_text(s, 'yellow')
+def cyan_text(s):
+ return colour_text(s, 'cyan')
+def blue_text(s):
+ return colour_text(s, 'blue')
+
#########################
def cyg2win32(path):
More information about the Numpy-svn
mailing list