diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-06-19 08:47:06 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-06-22 12:50:34 -0700 |
commit | b6740cf1d1fe847ae0064f7d7a5be1b24dcf4779 (patch) | |
tree | be5b945c09dac0159d5466c832832d42ded5f7fd /lib | |
parent | 4608b674e512595f934fe942187847abae950bb4 (diff) | |
download | spack-b6740cf1d1fe847ae0064f7d7a5be1b24dcf4779.tar.gz spack-b6740cf1d1fe847ae0064f7d7a5be1b24dcf4779.tar.bz2 spack-b6740cf1d1fe847ae0064f7d7a5be1b24dcf4779.tar.xz spack-b6740cf1d1fe847ae0064f7d7a5be1b24dcf4779.zip |
Make debug and verbose output work properly.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/tty/__init__.py | 22 | ||||
-rw-r--r-- | lib/spack/spack/util/executable.py | 16 |
2 files changed, 31 insertions, 7 deletions
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py index fcbafa82a7..3f413cd46e 100644 --- a/lib/spack/llnl/util/tty/__init__.py +++ b/lib/spack/llnl/util/tty/__init__.py @@ -29,10 +29,20 @@ from StringIO import StringIO from llnl.util.tty.color import * -debug = False -verbose = False +_debug = False +_verbose = False indent = " " +def set_debug(flag): + global _debug + _debug = flag + + +def set_verbose(flag): + global _verbose + _verbose = flag + + def msg(message, *args): cprint("@*b{==>} %s" % cescape(message)) for arg in args: @@ -50,13 +60,13 @@ def info(message, *args, **kwargs): def verbose(message, *args): - if verbose: + if _verbose: info(message, *args, format='c') -def debug(*args): - if debug: - info("Debug: " + message, *args, format='*g') +def debug(message, *args): + if _debug: + info(message, *args, format='g') def error(message, *args): diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index d65f7ed922..2b1b24b728 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -38,6 +38,7 @@ class Executable(object): self.exe = name.split(' ') self.returncode = None + def add_default_arg(self, arg): self.exe.append(arg) @@ -61,7 +62,7 @@ class Executable(object): "Consider removing them") cmd = self.exe + list(args) - tty.verbose(" ".join(cmd)) + tty.debug(" ".join(cmd)) try: proc = subprocess.Popen( @@ -80,6 +81,19 @@ class Executable(object): except subprocess.CalledProcessError, e: if fail_on_error: raise + + def __eq__(self, other): + return self.exe == other.exe + + + def __neq__(self, other): + return not (self == other) + + + def __hash__(self): + return hash((type(self),) + tuple(self.exe)) + + def __repr__(self): return "<exe: %s>" % self.exe |