From b1df5fc44c161d458fd41093f57f3cef852ea9c5 Mon Sep 17 00:00:00 2001 From: Oleg Alexandrov Date: Mon, 9 Dec 2024 11:33:48 -0800 Subject: [PATCH] Reduce the frequency of warnings --- src/asp/Python/asp_system_utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/asp/Python/asp_system_utils.py b/src/asp/Python/asp_system_utils.py index 25064b682..b05f837e7 100644 --- a/src/asp/Python/asp_system_utils.py +++ b/src/asp/Python/asp_system_utils.py @@ -294,6 +294,7 @@ def mkdir_p(path): # output variable name, the other values are read into the array of # variable values. def run_and_parse_output(cmd, args, sep, verbose, return_full_lines = False, **kw): + libexecpath = libexec_path(cmd) call = [libexecpath] call.extend(args) @@ -302,7 +303,8 @@ def run_and_parse_output(cmd, args, sep, verbose, return_full_lines = False, **k print (asp_string_utils.argListToString(call)) try: - p = subprocess.Popen(call, stdout=subprocess.PIPE, universal_newlines=True) + p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True) except OSError as e: raise Exception('%s: %s' % (libexecpath, e)) (stdout, stderr) = p.communicate() @@ -323,8 +325,11 @@ def run_and_parse_output(cmd, args, sep, verbose, return_full_lines = False, **k count = 0 for line in stdout.split('\n'): - # Print warning messages to stdout - if re.match(r"^Warning", line): print(line) + # Do not usually print warnings as they are verbose, and this function + # is invoked often. The main processes (such as stereo_pprc) will print + # the warnings. + if verbose and re.match(r"^Warning", line): + print(line) if return_full_lines: data[count] = line # return the entire line @@ -345,7 +350,8 @@ def run_with_return_code(cmd, verbose=False): print (asp_string_utils.argListToString(cmd)) try: - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True) except OSError as e: print('Error: %s: %s' % ( asp_string_utils.argListToString(cmd), e))