mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
aecb2b779b
This made Python 2's print behave like Python 3's print(). In some cases, where we had: from __future__ import print_function """Intended module documentation...""" this will have the side effect of making the intended module documentation work as the actual module documentation (i.e. becoming __doc__), because it is once again the first statement in the module. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer@samba.org>
|
|
# Copyright (C) 2016 Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
|
|
# Published under the GNU GPL, v3 or later
|
|
import optparse
|
|
import os
|
|
import signal
|
|
import sys
|
|
import json
|
|
|
|
sys.path.insert(0, "bin/python")
|
|
|
|
|
|
def json_formatter(src_f, dest_f):
|
|
"""We're not even pretending to be a TestResult subclass; just read
|
|
from stdin and look for elapsed-time tags."""
|
|
results = {}
|
|
|
|
for line in src_f:
|
|
line = line.strip()
|
|
if line[:14] == 'elapsed-time: ':
|
|
name, time = line[14:].rsplit(':', 1)
|
|
results[name] = float(time)
|
|
|
|
json.dump(results, dest_f,
|
|
sort_keys=True, indent=2, separators=(',', ': '))
|
|
|
|
|
|
def main():
|
|
parser = optparse.OptionParser("format-subunit-json [options]")
|
|
parser.add_option("--verbose", action="store_true",
|
|
help="ignored, for compatibility")
|
|
parser.add_option("--immediate", action="store_true",
|
|
help="ignored, for compatibility")
|
|
parser.add_option("--prefix", type="string", default=".",
|
|
help="Prefix to write summary.json to")
|
|
opts, args = parser.parse_args()
|
|
|
|
fn = os.path.join(opts.prefix, "summary.json")
|
|
f = open(fn, 'w')
|
|
json_formatter(sys.stdin, f)
|
|
f.close()
|
|
print()
|
|
print("A JSON file summarising these tests performance found in:")
|
|
print(" ", fn)
|
|
|
|
|
|
def handle_sigint(sig, stack):
|
|
sys.exit(0)
|
|
|
|
signal.signal(signal.SIGINT, handle_sigint)
|
|
main()
|