Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
|
jbudorick
2016/07/29 00:52:39
This name is too generic. If this wrapper is speci
nicholaslin
2016/07/29 20:50:20
Done. Should the folder be renamed as well?
| |
| 2 # Copyright 2016 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 import argparse | |
| 7 import sys | |
| 8 import os | |
| 9 import subprocess | |
| 10 import logging | |
| 11 | |
| 12 | |
| 13 def CommandParser(): | |
| 14 # Parses the command line arguments being passed in | |
| 15 parser = argparse.ArgumentParser() | |
| 16 parser.add_argument('--logdog-bin-cmd', | |
| 17 help=('Command for running logdog butler binary')) | |
|
ghost stip (do not use)
2016/07/29 01:09:08
you don't need the parens here. it can be just hel
ghost stip (do not use)
2016/07/29 01:09:08
required=True
IIUC, all of these should be requir
nicholaslin
2016/07/29 20:50:19
Done.
nicholaslin
2016/07/29 20:50:20
I'll make logdog arguments required.
I was think
| |
| 18 parser.add_argument('--project', | |
| 19 help=('Name of logdog project')) | |
| 20 parser.add_argument('--output', | |
|
ghost stip (do not use)
2016/07/29 01:09:08
nit: rework the --output flag to just be server na
nicholaslin
2016/07/29 20:50:20
Done.
| |
| 21 help=('Format of logdog output')) | |
| 22 parser.add_argument('--service-account-json', | |
| 23 help=('Location of authentication json')) | |
| 24 parser.add_argument('--prefix', | |
| 25 help=('Prefix to be used for logdog stream')) | |
| 26 parser.add_argument('--source', | |
| 27 help=('Location of file for logdog to stream')) | |
| 28 parser.add_argument('--name', | |
| 29 help=('Name to be used for logdog stream')) | |
| 30 return parser | |
| 31 | |
| 32 | |
| 33 def CreateUrl(project, prefix, name): | |
| 34 url_prefix = prefix.replace('/', '%2F') | |
| 35 return ('https://luci-logdog-dev.appspot.com/v/?s=%s%%2F' | |
|
ghost stip (do not use)
2016/07/29 01:09:08
use args.logdog_server as specified above
nicholaslin
2016/07/29 20:50:20
Done.
| |
| 36 '%s%%2F%%2B%%2F%s' % (project, url_prefix, name)) | |
| 37 | |
| 38 | |
| 39 def main(): | |
| 40 parser = CommandParser() | |
| 41 args, test_cmd = parser.parse_known_args(sys.argv[1:]) | |
|
ghost stip (do not use)
2016/07/29 01:09:08
if not test_cmd:
parser.error('must specify a co
nicholaslin
2016/07/29 20:50:20
Done.
| |
| 42 if args.logdog_bin_cmd: | |
|
jbudorick
2016/07/29 00:52:40
When would we use this wrapper without a logdog_bi
ghost stip (do not use)
2016/07/29 01:09:07
should make required in the parser
nicholaslin
2016/07/29 20:50:20
I'll rework this file to only consider the case wh
| |
| 43 subprocess.check_call(test_cmd) | |
| 44 if '${SWARMING_TASK_ID}' in args.prefix: | |
| 45 args.prefix = args.prefix.replace('${SWARMING_TASK_ID}', | |
| 46 os.environ.get('SWARMING_TASK_ID')) | |
|
jbudorick
2016/07/29 00:52:40
nit: indentation is off here. either indent to the
nicholaslin
2016/07/29 20:50:20
Done.
| |
| 47 url = CreateUrl(args.project, args.prefix, args.name) | |
| 48 logging.info('Logcats are located at: %s', url) | |
| 49 logdog_cmd = [args.logdog_bin_cmd, '-project', args.project, | |
| 50 '-output', args.output, '-prefix', args.prefix] | |
|
ghost stip (do not use)
2016/07/29 01:09:08
'-output', 'logdog,host=%s' % args.logdog_server,
nicholaslin
2016/07/29 20:50:20
Done.
| |
| 51 stream_cmd = ['stream', '-source', args.source, '-stream', | |
| 52 ('-name=%s'% args.name)] | |
|
jbudorick
2016/07/29 00:52:40
nits: no parens, space before %
nicholaslin
2016/07/29 20:50:20
Done.
| |
| 53 if args.service_account_json: | |
|
nicholaslin
2016/07/29 20:50:20
Requiring all logdog arguments, so taking this par
| |
| 54 cmd = (logdog_cmd + ['-service-account-json', args.service_account_json] | |
| 55 + stream_cmd) | |
| 56 else: | |
| 57 cmd = logdog_cmd + stream_cmd | |
| 58 return subprocess.call(cmd) | |
| 59 return subprocess.call(test_cmd) | |
| 60 | |
| 61 | |
| 62 if __name__ == '__main__': | |
| 63 sys.exit(main()) | |
| OLD | NEW |