Alexander Schulze | 64f5f26 | 2022-02-23 01:17:28 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Dan Jacques | 74d7e13 | 2017-06-01 15:17:15 -0700 | [diff] [blame] | 2 | # Copyright (c) 2017 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. |
Dan Jacques | 74d7e13 | 2017-06-01 15:17:15 -0700 | [diff] [blame] | 5 | """Small utility script to enable/disable `depot_tools` automatic updating.""" |
| 6 | |
| 7 | import argparse |
| 8 | import datetime |
| 9 | import os |
| 10 | import sys |
| 11 | |
Dan Jacques | 74d7e13 | 2017-06-01 15:17:15 -0700 | [diff] [blame] | 12 | DEPOT_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__)) |
| 13 | SENTINEL_PATH = os.path.join(DEPOT_TOOLS_ROOT, '.disable_auto_update') |
| 14 | |
| 15 | |
| 16 | def main(): |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 17 | parser = argparse.ArgumentParser() |
| 18 | group = parser.add_mutually_exclusive_group(required=True) |
| 19 | group.add_argument('--enable', |
| 20 | action='store_true', |
| 21 | help='Enable auto-updating.') |
| 22 | group.add_argument('--disable', |
| 23 | action='store_true', |
| 24 | help='Disable auto-updating.') |
| 25 | args = parser.parse_args() |
Dan Jacques | 74d7e13 | 2017-06-01 15:17:15 -0700 | [diff] [blame] | 26 | |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 27 | if args.enable: |
| 28 | if os.path.exists(SENTINEL_PATH): |
| 29 | os.unlink(SENTINEL_PATH) |
| 30 | if args.disable: |
| 31 | if not os.path.exists(SENTINEL_PATH): |
| 32 | with open(SENTINEL_PATH, 'w') as fd: |
| 33 | fd.write('Disabled by %s at %s\n' % |
| 34 | (__file__, datetime.datetime.now())) |
| 35 | return 0 |
Dan Jacques | 74d7e13 | 2017-06-01 15:17:15 -0700 | [diff] [blame] | 36 | |
| 37 | |
| 38 | if __name__ == '__main__': |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 39 | sys.exit(main()) |