From acb7a1933e5e0834592d59fd00547a3926c0e880 Mon Sep 17 00:00:00 2001 From: Cassidy Burden Date: Fri, 10 Jun 2016 10:22:05 -0700 Subject: Add verbose option to binary search tool Ignore most output from binary search tool and provide option to see full output with the -V or --verbose option. Full output will still logged even without the --verbose option. TEST=Ran binary_search_tool_tester and cros_pkg Change-Id: I02d958f79813083b48d989c9881536ad025bb1dc Reviewed-on: https://chrome-internal-review.googlesource.com/264075 Commit-Ready: Cassidy Burden Tested-by: Cassidy Burden Reviewed-by: Caroline Tice Reviewed-by: Han Shen --- binary_search_tool/binary_search_perforce.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'binary_search_tool/binary_search_perforce.py') diff --git a/binary_search_tool/binary_search_perforce.py b/binary_search_tool/binary_search_perforce.py index 5e58223d..39da8e2b 100755 --- a/binary_search_tool/binary_search_perforce.py +++ b/binary_search_tool/binary_search_perforce.py @@ -12,6 +12,8 @@ import tempfile from cros_utils import command_executer from cros_utils import logger +verbose = True + def _GetP4ClientSpec(client_name, p4_paths): p4_string = "" for p4_path in p4_paths: @@ -87,7 +89,7 @@ class BinarySearcher(object): (self.sorted_list[self.current], self.current, status)) - logger.GetLogger().LogOutput(message) + logger.GetLogger().LogOutput(message, print_to_console=verbose) assert status == 0 or status == 1 or status == 2 self.index_log.append(self.current) self.status_log.append(status) @@ -117,7 +119,8 @@ class BinarySearcher(object): if index not in self.skipped_indices: return False logger.GetLogger().LogOutput( - "All skipped indices between: %d and %d\n" % (self.lo, self.hi)) + "All skipped indices between: %d and %d\n" % (self.lo, self.hi), + print_to_console=verbose) return True # Does a better job with chromeos flakiness. @@ -164,12 +167,12 @@ class BinarySearcher(object): message = ("Estimated tries: min: %d max: %d\n" % (1 + math.log(self.hi - self.lo, 2), self.hi - self.lo - len(self.skipped_indices))) - logger.GetLogger().LogOutput(message) + logger.GetLogger().LogOutput(message, print_to_console=verbose) message = ("lo: %d hi: %d current: %d version: %s\n" % (self.lo, self.hi, self.current, self.sorted_list[self.current])) - logger.GetLogger().LogOutput(message) - logger.GetLogger().LogOutput(str(self)) + logger.GetLogger().LogOutput(message, print_to_console=verbose) + logger.GetLogger().LogOutput(str(self), print_to_console=verbose) return self.sorted_list[self.current] def SetLoRevision(self, lo_revision): @@ -405,18 +408,21 @@ def Main(argv): status = ce.RunCommand(command) message = ("Revision: %s produced: %d status\n" % (current_revision, status)) - logger.GetLogger().LogOutput(message) + logger.GetLogger().LogOutput(message, print_to_console=verbose) terminated = p4gccbs.SetStatus(status) num_tries -= 1 - logger.GetLogger().LogOutput(str(p4gccbs)) + logger.GetLogger().LogOutput(str(p4gccbs), print_to_console=verbose) if not terminated: - logger.GetLogger().LogOutput("Tries: %d expired." % num_tries) - logger.GetLogger().LogOutput(str(p4gccbs.bs)) + logger.GetLogger().LogOutput("Tries: %d expired." % num_tries, + print_to_console=verbose) + logger.GetLogger().LogOutput(str(p4gccbs.bs), + print_to_console=verbose) except (KeyboardInterrupt, SystemExit): logger.GetLogger().LogOutput("Cleaning up...") finally: - logger.GetLogger().LogOutput(str(p4gccbs.bs)) + logger.GetLogger().LogOutput(str(p4gccbs.bs), + print_to_console=verbose) status = p4gccbs.Cleanup() -- cgit v1.2.3