Files
chromium_depot_tools/ninjalog_uploader_wrapper.py
Takuto Ikuta 5c00a22f22 [ninjalog_uploader] add path for httplib2
This is to let httplib2 import its sock.py in __init__.py correctly.
This is pointed out in
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/8BF_cywS9JY/8g-HHmuqEQAJ

Also removed an unnecessary httplib2 import.

Change-Id: Iad0377ad282acd9e1e222890f522e4e62086dcaf
Reviewed-on: https://chromium-review.googlesource.com/c/1475255
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@google.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
2019-02-18 04:32:51 +00:00

117 lines
3.0 KiB
Python
Executable File

#!/usr/bin/env python
# Copyright 2018 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.
import os
import subprocess
import json
import sys
import ninjalog_uploader
THIS_DIR = os.path.dirname(__file__)
UPLOADER = os.path.join(THIS_DIR, 'ninjalog_uploader.py')
CONFIG = os.path.join(THIS_DIR, 'ninjalog.cfg')
VERSION = 2
def LoadConfig():
if os.path.isfile(CONFIG):
with open(CONFIG, 'rb') as f:
config = json.load(f)
if config['version'] == VERSION:
config['countdown'] -= 1
return config
return {
'is-googler': ninjalog_uploader.IsGoogler(
'chromium-build-stats.appspot.com'),
'countdown': 10,
'version': VERSION,
}
def SaveConfig(config):
with open(CONFIG, 'wb') as f:
json.dump(config, f)
def ShowMessage(countdown):
whitelisted = '\n'.join([' * %s' % config for config in
ninjalog_uploader.WHITELISTED_CONFIGS])
print """
Your ninjalog will be uploaded to build stats server. The uploaded log will be
used to analyze user side build performance.
The following information will be uploaded with ninjalog.
* OS (e.g. Win, Mac or Linux)
* number of cpu cores of building machine
* build targets (e.g. chrome, browser_tests)
* parallelism passed by -j flag
* following build configs
%s
Uploading ninjalog will be started after you run autoninja another %d time.
If you don't want to upload ninjalog, please run following command.
$ %s opt-out
If you want to allow upload ninjalog from next autoninja run, please run the
following command.
$ %s opt-in
If you have questions about this, please send mail to infra-dev@chromium.org
You can find a more detailed explanation in
%s
""" % (whitelisted, countdown, __file__, __file__,
os.path.abspath(os.path.join(THIS_DIR, "ninjalog.README.md")))
def main():
config = LoadConfig()
if len(sys.argv) == 2 and sys.argv[1] == 'opt-in':
config['opt-in'] = True
config['countdown'] = 0
SaveConfig(config)
print('ninjalog upload is opted in.')
return 0
if len(sys.argv) == 2 and sys.argv[1] == 'opt-out':
config['opt-in'] = False
SaveConfig(config)
print('ninjalog upload is opted out.')
return 0
SaveConfig(config)
if 'opt-in' in config and not config['opt-in']:
# Upload is opted out.
return 0
if not config.get("is-googler", False):
# Not googler.
return 0
if config.get("countdown", 0) > 0:
# Need to show message.
ShowMessage(config["countdown"])
return 0
if len(sys.argv) == 1:
# dry-run for debugging.
print("upload ninjalog dry-run")
return 0
# Run upload script without wait.
devnull = open(os.devnull, "w")
subprocess.Popen([sys.executable, UPLOADER] + sys.argv[1:],
stdout=devnull, stderr=devnull)
if __name__ == '__main__':
sys.exit(main())