blob: 452ddd5308c9b7fcb54256cfb0cfb1bd6eac035a [file] [log] [blame]
Alexander Schulze64f5f262022-02-23 01:17:28 +00001#!/usr/bin/env python3
Dan Jacques74d7e132017-06-01 15:17:15 -07002# 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 Jacques74d7e132017-06-01 15:17:15 -07005"""Small utility script to enable/disable `depot_tools` automatic updating."""
6
7import argparse
8import datetime
9import os
10import sys
11
Dan Jacques74d7e132017-06-01 15:17:15 -070012DEPOT_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__))
13SENTINEL_PATH = os.path.join(DEPOT_TOOLS_ROOT, '.disable_auto_update')
14
15
16def main():
Mike Frysinger124bb8e2023-09-06 05:48:55 +000017 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 Jacques74d7e132017-06-01 15:17:15 -070026
Mike Frysinger124bb8e2023-09-06 05:48:55 +000027 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 Jacques74d7e132017-06-01 15:17:15 -070036
37
38if __name__ == '__main__':
Mike Frysinger124bb8e2023-09-06 05:48:55 +000039 sys.exit(main())