blob: 1bc537c01b3c1dcfc33ef98e460422f080bbd062 [file] [log] [blame]
Dan Jacques74d7e132017-06-01 15:17:15 -07001#!/usr/bin/env python
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.
5
6"""Small utility script to enable/disable `depot_tools` automatic updating."""
7
8import argparse
9import datetime
10import os
11import sys
12
13
14DEPOT_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__))
15SENTINEL_PATH = os.path.join(DEPOT_TOOLS_ROOT, '.disable_auto_update')
16
17
18def main():
19 parser = argparse.ArgumentParser()
20 group = parser.add_mutually_exclusive_group(required=True)
21 group.add_argument('--enable', action='store_true',
22 help='Enable auto-updating.')
23 group.add_argument('--disable', action='store_true',
24 help='Disable auto-updating.')
25 args = parser.parse_args()
26
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' % (__file__, datetime.datetime.now()))
34 return 0
35
36
37if __name__ == '__main__':
38 sys.exit(main())