download_proto_trace.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env vpython3
  2. # Copyright 2020 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. from __future__ import print_function
  6. import argparse
  7. import logging
  8. import os
  9. from core import path_util
  10. path_util.AddPyUtilsToPath()
  11. from cli_tools.tbmv3 import trace_downloader
  12. EXAMPLE_TRACE = ('https://storage.cloud.google.com/'
  13. 'chrome-telemetry-output/20201029T003106_99943/'
  14. 'v8.browsing_mobile/browse_shopping_amazon_2019/'
  15. 'retry_0/trace.html')
  16. def Main():
  17. logging.basicConfig(level=logging.WARN)
  18. parser = argparse.ArgumentParser(
  19. description='Downloads the proto trace for an cloud storage html '
  20. 'trace url.')
  21. parser.add_argument('html_trace_url',
  22. type=str,
  23. help='Looks like %s' % EXAMPLE_TRACE)
  24. parser.add_argument('--download-dir',
  25. type=str,
  26. default=trace_downloader.DEFAULT_TRACE_DIR,
  27. help='Directory to download the traces to.')
  28. args = parser.parse_args()
  29. if args.html_trace_url.endswith('/'):
  30. raise Exception('This is a directory, not a file url')
  31. path = trace_downloader.DownloadProtoTrace(args.html_trace_url,
  32. download_dir=args.download_dir)
  33. print('Downloaded to %s' % os.path.relpath(path))
  34. if __name__ == '__main__':
  35. Main()