__main__.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/env vpython3
  2. # Copyright 2024 The Chromium Authors
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """Utility for opting in or out of metrics collection"""
  6. import argparse
  7. import sys
  8. import pathlib
  9. import config
  10. def main():
  11. parser = argparse.ArgumentParser(description=__doc__)
  12. parser.add_argument('--disable',
  13. '-d',
  14. dest='enable',
  15. action='store_false',
  16. default=None,
  17. help='Disable telemetry collection.')
  18. parser.add_argument('--enable',
  19. '-e',
  20. dest='enable',
  21. action='store_true',
  22. default=None,
  23. help='Enable telemetry collection.')
  24. args = parser.parse_args()
  25. if args.enable is not None:
  26. cfg = config.Config(config.DEFAULT_CONFIG_FILE)
  27. cfg.trace_config.update(args.enable, 'USER')
  28. cfg.flush()
  29. else:
  30. print('Error: --enable or --disable flag is required.')
  31. if __name__ == '__main__':
  32. sys.exit(main())