aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/binary_search_perforce.py
diff options
context:
space:
mode:
authorCassidy Burden <cburden@google.com>2016-06-10 10:22:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-10 14:42:35 -0700
commitacb7a1933e5e0834592d59fd00547a3926c0e880 (patch)
tree7e68ab89daf3d92bbe68a666a4f4d5f882cc52bf /binary_search_tool/binary_search_perforce.py
parenta02937d6530b19b5635119a3f40169a604b0ca26 (diff)
downloadtoolchain-utils-acb7a1933e5e0834592d59fd00547a3926c0e880.tar.gz
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 <cburden@google.com> Tested-by: Cassidy Burden <cburden@google.com> Reviewed-by: Caroline Tice <cmtice@google.com> Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'binary_search_tool/binary_search_perforce.py')
-rwxr-xr-xbinary_search_tool/binary_search_perforce.py26
1 files changed, 16 insertions, 10 deletions
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()