OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
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 """Wrapper for adding logdog streaming support to swarming tasks.""" | |
7 | |
8 import argparse | |
9 import sys | |
10 import os | |
11 import subprocess | |
12 import logging | |
13 | |
14 | |
15 def CommandParser(): | |
16 # Parses the command line arguments being passed in | |
17 parser = argparse.ArgumentParser() | |
18 parser.add_argument('--logdog-bin-cmd', required=True, | |
19 help='Command for running logdog butler binary') | |
20 parser.add_argument('--project', required=True, | |
21 help='Name of logdog project') | |
22 parser.add_argument('--logdog-server', required=True, | |
23 default='luci-logdog.appspot.com', | |
dnj
2016/07/29 22:35:34
Please use "services-dot-luci-logdog.appspot.com"
nicholaslin
2016/07/29 23:54:06
Done, but clicking on this seems to show an empty
dnj
2016/07/30 15:47:48
Yeah it's a services endpoint, not a user-facing e
nicholaslin
2016/08/02 22:05:13
Got it. The streams go to services-dot-luci-logdog
| |
24 help='URL of logdog server, https:// is assumed.') | |
25 parser.add_argument('--service-account-json', required=True, | |
26 help='Location of authentication json') | |
27 parser.add_argument('--prefix', required=True, | |
28 help='Prefix to be used for logdog stream') | |
29 parser.add_argument('--source', required=True, | |
30 help='Location of file for logdog to stream') | |
31 parser.add_argument('--name', required=True, | |
32 help='Name to be used for logdog stream') | |
33 return parser | |
34 | |
35 | |
36 def CreateUrl(server, project, prefix, name): | |
37 url_prefix = prefix.replace('/', '%2F') | |
38 return ('https://%s/v/?s=%s%%2F%s%%2F%%2B%%2F%s' | |
ghost stip (do not use)
2016/07/29 21:56:40
lmao
dnj
2016/07/29 22:35:34
Er can we use something like urllib.quote (https:/
nicholaslin
2016/07/29 23:54:06
Done.
| |
39 % (server, project, url_prefix, name)) | |
40 | |
41 | |
42 def main(): | |
43 parser = CommandParser() | |
44 args, test_cmd = parser.parse_known_args(sys.argv[1:]) | |
45 if not test_cmd: | |
46 parser.error('Must specify command to run after the logdog flags') | |
47 subprocess.check_call(test_cmd) | |
ghost stip (do not use)
2016/07/29 21:56:40
we should do result = subprocess.call(test_cmd)
a
nicholaslin
2016/07/29 23:54:06
Done.
| |
48 if '${SWARMING_TASK_ID}' in args.prefix: | |
49 args.prefix = args.prefix.replace('${SWARMING_TASK_ID}', | |
50 os.environ.get('SWARMING_TASK_ID')) | |
51 url = CreateUrl(args.logdog_server, args.project, args.prefix, args.name) | |
52 logging.info('Logcats are located at: %s', url) | |
53 logdog_cmd = [args.logdog_bin_cmd, '-project', args.project, | |
54 '-output', 'logdog,host=%s' % args.logdog_server, | |
55 '-prefix', args.prefix, | |
56 '-service-account-json', args.service_accont_json, | |
57 'stream', '-source', args.source, | |
dnj
2016/07/29 22:35:34
I see we gave up on the "serve" approach w/ the li
| |
58 '-stream', '-name=%s' % args.name] | |
59 return subprocess.call(logdog_cmd) | |
60 | |
61 | |
62 if __name__ == '__main__': | |
63 sys.exit(main()) | |
OLD | NEW |