File: reclientreport.py

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (64 lines) | stat: -rw-r--r-- 2,472 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# Copyright 2023 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.
"""This script is a wrapper around the //buildtools/reclient/reclientreport
binary that populates the log paths correctly for builds run via autoninja
Call this script with the same -C argument used for the autoninja build
Example usage:
$ reclientreport -C out/my-ninja-out
"""

import argparse
import os
import sys
import tarfile
import tempfile


# TODO(b/301574845): Remove once reclientreport binary saves all logs
def temp_impl_b_301574845(out_dir):
    '''Temporary implementation until b/301574845 is fixed'''
    log_dir = os.path.abspath(os.path.join(out_dir, '.reproxy_tmp', 'logs'))
    with tempfile.NamedTemporaryFile(prefix='reclientreport',
                                     suffix='.tar.gz',
                                     delete=False) as f:
        with tarfile.open(fileobj=f, mode='w:gz') as tar:
            tar.add(log_dir, arcname=os.path.basename(log_dir))
        print(f'Created log file at {f.name}. Please attach this to your bug '
              'report!')


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--ninja_out",
                        "-C",
                        required=True,
                        help="ninja out directory used for the autoninja build")
    parser.add_argument('args', nargs=argparse.REMAINDER)

    args, _ = parser.parse_known_args()
    temp_impl_b_301574845(args.ninja_out)
    #if sys.platform.startswith('win'):
    #    temp_win_impl__b_296402157(args.ninja_out)
    #    return
    #if args.args and args.args[0] == '--':
    #    args.args.pop(0)
    #if extras:
    #    args.args = extras + args.args

    #log_dir = os.path.join(args.ninja_out, '.reproxy_tmp', 'logs')
    #reclient_helper.set_reproxy_path_flags(args.ninja_out, make_dirs=False)
    #os.environ["RBE_proxy_log_dir"] = ",".join(
    #    os.path.join(log_dir, d) for d in os.listdir(log_dir))
    #reclient_bin_dir = reclient_helper.find_reclient_bin_dir()
    #code = subprocess.call([os.path.join(reclient_bin_dir, 'reclientreport')] +
    #                       args.args)
    #if code != 0:
    #    print("Failed to collect logs, make sure that %s/.reproxy_tmp exists" %
    #          args.ninja_out,
    #          file=sys.stderr)


if __name__ == '__main__':
    sys.exit(main())