Skip to content

Commit c99c444

Browse files
authored
triage_version.py: added --no-quiet, --no-stderr and --no-stdout for more granular output control (danmar#4713)
1 parent dee2ad8 commit c99c444

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tools/triage_py/triage_version.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
parser.add_argument('--check-library', action='store_true', help='passed through to binary if supported')
1818
parser.add_argument('--timeout', type=int, default=2, help='the amount of seconds to wait for the analysis to finish')
1919
parser.add_argument('--compact', action='store_true', help='only print versions with changes with --compare')
20+
parser.add_argument('--no-quiet', action='store_true', default=False, help='do not specify -q')
21+
parser.add_argument('--no-stderr', action='store_true', default=False, help='do not display stdout')
22+
parser.add_argument('--no-stdout', action='store_true', default=False, help='do not display stderr')
2023
args = parser.parse_args()
2124

2225
def sort_commit_hashes(commits):
@@ -36,6 +39,10 @@ def sort_commit_hashes(commits):
3639
print('error: --compact requires --compare')
3740
sys.exit(1)
3841

42+
if args.no_stdout and args.no_stderr:
43+
print('error: cannot specify --no-stdout and --no-stderr at once')
44+
sys.exit(1)
45+
3946
directory = args.dir
4047
input_file = args.infile
4148
git_repo = args.repo
@@ -99,7 +106,7 @@ def sort_commit_hashes(commits):
99106

100107
cmd = exe
101108
cmd += ' '
102-
if do_compare:
109+
if do_compare and not args.no_quiet:
103110
cmd += ' -q '
104111
if args.debug and Version(version) >= Version('1.45'):
105112
cmd += '--debug '
@@ -121,7 +128,13 @@ def sort_commit_hashes(commits):
121128
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=exe_path, universal_newlines=True)
122129
try:
123130
comm = p.communicate(timeout=args.timeout)
124-
out = comm[0] + '\n' + comm[1]
131+
out = ''
132+
if not args.no_stdout:
133+
out += comm[0]
134+
if not args.no_stderr and not args.no_stderr:
135+
out += '\n'
136+
if not args.no_stderr:
137+
out += comm[1]
125138
except subprocess.TimeoutExpired:
126139
out = "timeout"
127140
p.kill()

0 commit comments

Comments
 (0)