Line Code
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
#!/usr/bin/env python3

import xml.etree.ElementTree as ET
import argparse

def printGUID(root):
    for f in root.findall("File"):
        print(f.find("GUID").text)

def printExitCode(root):
    error = root.find("FrameworkError")
    if error is None:
        print("0")
        return
    print(error.get("ExitStatus"))

def main(opts):
    tree = ET.parse(opts.file)
    root = tree.getroot()
    if opts.guid:
        printGUID(root)
    if opts.exitCode:
        printExitCode(root)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Extract some values from the Framework Job Report")
    parser.add_argument("file", type=str,
                        help="Framework Job Report XML file")
    parser.add_argument("--guid", action="store_true",
                        help="GUID of the output file")
    parser.add_argument("--exitCode", action="store_true",
                        help="Job exit code")

    opts = parser.parse_args()
    main(opts)