[auto_update] Add control script, allow disable.
Enable a sentinel file to enable/disable "depot_tools" auto-updating. This file, if present, indicates that automatic updating should not occur. Add a simple control script to enable/disable automatic updating. BUG=chromium:727917 TEST=local - Ran locally, --enable, --disable. R=iannucci@chromium.org, maruel@chromium.org, nodir@chromium.org Change-Id: Id30a17586248228849d046f79d7e0bc445d97f97 Reviewed-on: https://chromium-review.googlesource.com/521884 Commit-Queue: Daniel Jacques <dnj@chromium.org> Reviewed-by: Robbie Iannucci <iannucci@chromium.org> Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>changes/84/521884/5
parent
bbda9719b0
commit
74d7e13315
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2017 The Chromium Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
"""Small utility script to enable/disable `depot_tools` automatic updating."""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
DEPOT_TOOLS_ROOT = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
SENTINEL_PATH = os.path.join(DEPOT_TOOLS_ROOT, '.disable_auto_update')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
group = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
group.add_argument('--enable', action='store_true',
|
||||||
|
help='Enable auto-updating.')
|
||||||
|
group.add_argument('--disable', action='store_true',
|
||||||
|
help='Disable auto-updating.')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.enable:
|
||||||
|
if os.path.exists(SENTINEL_PATH):
|
||||||
|
os.unlink(SENTINEL_PATH)
|
||||||
|
if args.disable:
|
||||||
|
if not os.path.exists(SENTINEL_PATH):
|
||||||
|
with open(SENTINEL_PATH, 'w') as fd:
|
||||||
|
fd.write('Disabled by %s at %s\n' % (__file__, datetime.datetime.now()))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
||||||
Loading…
Reference in New Issue