Make debug and verbose output work properly.
This commit is contained in:
parent
4608b674e5
commit
b6740cf1d1
3 changed files with 34 additions and 8 deletions
|
@ -77,8 +77,10 @@ for cmd in spack.cmd.commands:
|
|||
args = parser.parse_args()
|
||||
|
||||
# Set up environment based on args.
|
||||
spack.verbose = args.verbose
|
||||
tty.set_verbose(args.verbose)
|
||||
tty.set_debug(args.debug)
|
||||
spack.debug = args.debug
|
||||
|
||||
spack.spack_working_dir = working_dir
|
||||
if args.mock:
|
||||
from spack.packages import PackageDB
|
||||
|
|
|
@ -29,10 +29,20 @@
|
|||
|
||||
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):
|
||||
|
|
|
@ -38,6 +38,7 @@ def __init__(self, name):
|
|||
self.exe = name.split(' ')
|
||||
self.returncode = None
|
||||
|
||||
|
||||
def add_default_arg(self, arg):
|
||||
self.exe.append(arg)
|
||||
|
||||
|
@ -61,7 +62,7 @@ def __call__(self, *args, **kwargs):
|
|||
"Consider removing them")
|
||||
|
||||
cmd = self.exe + list(args)
|
||||
tty.verbose(" ".join(cmd))
|
||||
tty.debug(" ".join(cmd))
|
||||
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
|
@ -80,6 +81,19 @@ def __call__(self, *args, **kwargs):
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue